Cameraproject Problem

Blitz3D Forums/Blitz3D Programming/Cameraproject Problem

Ash_UK(Posted 2006) [#1]
Hi all. I am having a slight problem with the Cameraproject command. I have an inffinite plane (grid) and I would like to have the users movement of the mouse (in 2D co-ords) to move the cursor in the 3D window (3D co-ords). The problem I have is that when I move the mouse, it seems to work fine. But when the cursor object goes below the origin, either on the X or Z origin, it doesn't move any further. I know that in 3D, co-ordinates go below the origin so you can have -50 on the X-axis for example. I just don't know how to get the cursor to move properly with it.

The sort of effect I am after is similar to that of 3D Max, or other 3D modelling packages, where you can place your objects using the cursor gizmo.

I would really appriciate it if someone could help me out here :)

Thanks people


Stevie G(Posted 2006) [#2]
Can you show us a stripped down version of what you have so far?

Stevie


Ash_UK(Posted 2006) [#3]
okey dokey :) here you go:


Graphics3D 800,600
SetBuffer BackBuffer()


cam = CreateCamera()
	CameraRange cam,1,1000
	
light = CreateLight()
plane = CreatePlane()
ball = CreateSphere()
	PositionEntity ball,0,MeshHeight(ball)/2,0


plane_tex = LoadTexture("textures/plane_tex.png",2)
EntityTexture plane,plane_tex

CameraClsMode cam,0,1
ClsColor 195,195,255

MoveEntity cam,0,2,-10


While Not KeyHit(1)
Cls

	CameraProject cam,MouseX(),0,MouseY()
	
	If KeyDown(200) Then MoveEntity cam,0,0,0.1
	If KeyDown(208) Then MoveEntity cam,0,0,-0.1
	If KeyDown(205) Then TurnEntity cam,0,-1,0
	If KeyDown(203) Then TurnEntity cam,0,1,0
	
	UpdateWorld
	RenderWorld
	
	Color 0,0,0
	Rect 0,0,800,50
	Color 255,255,255
	
	Text ProjectedX(),ProjectedY(),"3D DESIGNER"
	
	MoveMouse 0,0
	Flip

Wend
End



As you can see, its the text thats acting as the mouse cursor.

Thanks again for any help


Stevie G(Posted 2006) [#4]
Sorry, but I'm not really sure what your attempting to achieve here?

You're axis issue is simply because the mousex() and mousey() positions will be in the region 0-799 and 0-599 respectively. When you project this coord into 3d space you will always be positive in the x direction and positive in the z direction. You could do something like this ...

Cx# = Mousex() - graphicswidth()*.5
Cz# = mousey() - graphicsheight()*.5
Cameraproject cam , Cx, 0 , Cz

and ...

MoveMouse graphicswidth()*.5, graphicsheight()*.5


If you can explain better it'd help?

Stevie


Ash_UK(Posted 2006) [#5]
Hi Stevie :) Sorry for the delay in replying.

I am trying to program a kitchen designer program. It will hopefully allow the user to build a 3D kitchen. I would like to be able to place the 3D objects by using the mouse, just like in a 3D modeller program. Also, the user should be able to draw out the boundaries of the kitchen. I don't know how i'm going to do that either :)

Thanks for your help on this one Stevie :) I hope this explains it a bit better

Ash


big10p(Posted 2006) [#6]
http://www.blitzbasic.com/codearcs/codearcs.php?code=379


Ash_UK(Posted 2006) [#7]
Heeyyy thanks big :) This has helped me out a lot. Many many thanks. And thank you again Stevie for your help, much appriciated.

Ash