Problem with Mouse Coordinates

Blitz3D Forums/Blitz3D Beginners Area/Problem with Mouse Coordinates

AuzingLG(Posted 2003) [#1]
Hi! I am using a modified version of the code (code archives\3d graphics), where the Mouse coordinates are converted into 3d coordinates. But it results in a "Memory Accses Violation". Here is the code:
[CODE]Function Project2DTo3DOrtho(mx,my)
;Check the mouse is in the 3d window
;If mx>=100 And mx<=700 And my=>100 And my<=500

;Get mouse position in relation to the 3d viewport
vx=mx;-100
vy=my;-100

;Get the 2d position of the origin
CameraProject camera,0,0,0
x#=ProjectedX()
y#=ProjectedY()

;Get the 2d position of 1,1,1
CameraProject camera,1,1,1
x1#=ProjectedX()
y1#=ProjectedY()

;Take one from the other to find the distance
dx#=x1-x
dy#=y1-y

;World position is :
wpx#=(vx-x)/dx
wpy#=(vy-y)/dy

;Looking down the Z Axis
Text 0,0,"Cursor is at World position X : "+wpx
Text 0,12," Y : "+wpy

;EndIf
End Function[/CODE]Please help me.

Sorry for my bad english, I'm a boy living in Austria


Gabriel(Posted 2003) [#2]
You need a global entity called camera.

Global camera=CreateCamera()