Ok, I wrote a test program to try and figure out why this isn't working. I also created a youtube video of this program running, so people could see the results I am getting. (they don't make any sense to me)
I am using Minib3d v0.52 along with Minib3d extended
This is the you tube video of what happens when I run the code below: http://www.youtube.com/watch?v=0uMw33ge86s (you won't be able to read the text unless you press the HD mode button)
'Example file for problems I having with "CameraProject()"
Import "includes/bbvkey.bmx"
Import sidesign.minib3d
Global GFXW = 1024
Global GFXH = 768
'Global GFXD = 32
Global GFXM = 2
'Global GFXR = 60
Graphics3D GFXW, GFXH, GFXD, GFXM, GFXR
'camera control globals
'----------------------
Global forward:Float,straferight:Float,strafeleft:Float,backward:Float
Global x:Float, y:Float, z:Float
'make the camera
'---------------
camera = createcamera()
light = createlight()
positionentity light, 0, 50, 0
rotateentity light,-40,30,0
'make a room
'-----------
cube = createcube()
scaleentity cube, - 55, - 55, - 55
entitycolor cube,80,190,70
'make our sphere so we can see the 3d location to be transformed
'---------------------------------------------------------------
sphere = createsphere()
Global SPHEREX=15:Float
Global SPHEREY=3:Float
Global SPHEREZ=13:Float
positionentity sphere, SPHEREX, SPHEREY, SPHEREZ
entitycolor sphere, 255, 0, 0
'===================
'**** Main Loop ****
'===================
While Not vkeyhit(1) = True
'----------------------------------------
'------- Camera Project Stuff -------
'----------------------------------------
CameraProject camera, SPHEREX, SPHEREY, SPHEREZ
sphere_projx = projectedx()
sphere_projy = projectedy()
'----------------------------------------
'just some camera controls
'-------------------------
mxs = (MouseX() - GFXW / 2) 'see how far the mouse has been moved
mys = (MouseY() - GFXH / 2)
MoveMouse (GFXW / 2), (GFXH / 2) 'put the mouse back in the middle of the screen
camerapitch = (camerapitch + mys)
camerayaw = (camerayaw + mxs)
If vKeyDown(17)
forward = .03
Else
forward = 0
EndIf
If vKeyDown(31)
backward = -.03
Else
backward= 0
EndIf
If vKeyDown(30)
strafeleft = -.03
Else
strafeleft = 0
EndIf
If vKeyDown(32)
straferight = .03
Else
straferight = 0
EndIf
z = (forward + backward)
x = (strafeleft + straferight)
rotateentity camera, camerapitch/5, -camerayaw/5, 0
moveentity camera,x,y,z
UpdateWorld
RenderWorld
Text 3, 10, "Move the camera around with the WASD keys and Mouse."
Text 3, 25, "Is Projected(X) returning the 2d transformation of the red sphere correctly?"
Text 3, 40, "(This is set at 1024 * 768)"
Text 3, 130, "ProjectedX() = " + sphere_projx
Text 3, 160, "ProjectedY() = " + sphere_projy
Flip(False)
Wend
End
could someone else run this and see if the projectedx() projectedy() make sense?
|