cameraproject() help

BlitzMax Modules Forums/MiniB3D/cameraproject() help

HI, I am having problem with cameraproject() and projectX(),projectY(). I wanted to keep the mouse pointing to the entity selected. Simply using "movemouse projectedX(),projectedY()" does not work.
I don't know what I am doing wrong, because the following code works in blitz3d but not in minib3d. The returned value seems wrong (I think). The projectY() and projectx() are not returning the equivalent 2d position. Maybe someone could tell me what I am doing wrong. I would apreciate any help.
This code ilustrate the problem, the mouse pointer moves in a different direction than the entity:
Import sidesign.minib3d

Strict

Graphics3D 640,480,0,2

Local cam:TCamera=CreateCamera()
PositionEntity cam,0,2,-10
Local light:TLight=CreateLight(1)

Local cube1:TMesh=CreateCube()
EntityPickMode cube1,2

PositionEntity cube1,-6,0,0

While Not KeyDown(KEY_ESCAPE)		
	MoveEntity cube1,0.01,0.005,0.005

	CameraProject cam,EntityX(cube1,1),EntityY(cube1,1),EntityZ(cube1,1)
	MoveMouse ProjectedX#(),ProjectedY#()

	RenderWorld
	text 10,10,ProjectedX()
	text 10,30,ProjectedY()
	Flip

Wend
End


Getting the same problem. Would be nice to solve this. Anyone?

Seems a couple of values need inverting.

Change:

EntityZ(cube1,1) to -EntityZ(cube1,1)

And:

ProjectedY() to 480-ProjectedY()

Will be fixed in the next version.

Thanks, Simonh. That was what I needed.

CameraProject cam,EntityX(cube1,1),EntityY(cube1,1),-EntityZ(cube1,1)
MoveMouse ProjectedX#(),GraphicsHeight()-ProjectedY#()


Is it possible to store a list of Projected co-ordinates? How can I store the x,y screen location of multiple objects?

You create an array or a TList of custom "types", you call cameraproject as many times as necessary and you store x,y in the array/list. There are too many ways of doing it, Depending on what you want to achieve you will have to choose one, you could extend TEntity type to include projected coordinates for example, etcetera.

Doh! I thought you had to call ProjectedX,Y,Z after UpdateWorld, making only useful for 1 object. Thanks.