Moving an object but keeping its perspective

Blitz3D Forums/Blitz3D Beginners Area/Moving an object but keeping its perspective

hockings(Posted 2006) [#1]
I have a square (which will later be a map). When its drawn straight in front of the camera I see (excuse the poor ascii art - I have to put dots around everything to get the output to look right)

......
..__..
./__\.
......

When I do a moveentity and move it so it's in the top right corner of the screen, it now looks like

.....
.._.
./.|.
/--|.
.....

How do I move it to the top left of the screen, but get it to stay looking like it's drawn in the middle of the screen?

Thanks!


Matty(Posted 2006) [#2]
Use cameraprojmode command to set the camera to orthographic instead of perspective.


hockings(Posted 2006) [#3]
Can I apply it to only one object though? Eg. I would like the map to be orthographic, but the rest to be normal.


Matty(Posted 2006) [#4]
There are a number of ways around this.
One of them is to render the scene in multiple passes. Or to do so with multiple cameras, one in orthographic mode the other in perspective and only show some objects in orthographic mode and only show others in perspective mode.


hockings(Posted 2006) [#5]
Matty,
I'd appreciate some more info on this.

My thought after looking at this last night would be that I could have two cameras as you state, and just draw the objects a long way from each other so one camera doesn't see what the other camera can see.
If anyone has a better way, please let me know.

Your point on rendering the scene in multiple passes has me lost though so an explaination would be appreciated!

Cheers!
Shane


Buggy(Posted 2006) [#6]
I can't find cameraprojmode anywhere... is it in one of the newer versions of Blitz?


H&K(Posted 2006) [#7]
Not sure about this, but if the square is very far away, and the parallax movement change is small, then the projection distortion will be minute. BUT
I personaly would just make your square 2d, and putit on the "HUD" overlay, and not bother with "Double/Multiple passes"


hockings(Posted 2006) [#8]
Buggy,
I'm running the latest blitz3d version and it's there, I'm not sure when it was added.

H&K, The square is close. I want a map that can be rotated by the player and them to be able to click on it which updates the view in the main part of the window. The map will have 3d objects on it, so I have to do it in 3d.


mindstorms(Posted 2006) [#9]
You could always use a sprite in back of the 3d objects, oriented so it is always facing the camera...I think


hockings(Posted 2006) [#10]
I thought about doing that, but this will end up looking 1000 times better! :D The idea behind it is that your map is used for designing a racing track, when you click a square you get a view of the piece in your main window which you can do some modifications on. I could do all the combinations (rollercoaster tycoon style) in 2d, but this will take up a lot less space (and in my opinion, look a lot cooler!) if I can get it to work.


Beaker(Posted 2006) [#11]
Create 2 cameras.
Use CameraViewport to position/size the render from the 2nd one.
Use CameraClsMode (eg. CameraClsMode cam2,False,True) on the 2nd one to prevent it wiping out the first render.


hockings(Posted 2006) [#12]
Beaker. Thanks a lot for the reply. I don't understand it (this is my first attempt at 3D), but I'll give it a try and see what happens.


Beaker(Posted 2006) [#13]
Graphics3D 640,480
SetBuffer BackBuffer()


cam1 = CreateCamera()
	sphere = CreateSphere(4,cam1)
		MoveEntity sphere,0,0,2
		EntityColor sphere,255,0,0
		ScaleEntity sphere,2,2,0.2

cam2 = CreateCamera()
	CameraClsMode cam2,False,True
	CameraViewport cam2, 0,0,160,120
	MoveEntity cam2,1000,1000,1000
	cube = CreateCube(cam2)
		MoveEntity cube,0,0,4
		EntityColor cube,0,255,0


While Not KeyDown(1)
	RenderWorld
	Flip
	Wend
End



Buggy(Posted 2006) [#14]
I don't see why a sprite that looks3D wouldn't work... well, does maskimage work for sprites? If not, then how do people mask the crap out of sprites?


mindstorms(Posted 2006) [#15]
I am runing into this effect as well. When I change to orthographic, it seems as if nothing shows up at all?


hockings(Posted 2006) [#16]
All,
Beaker had the correct solution to the problem. A second camera set directly in front of the object gives the right perspective, then move that camera to the top left of the screen with CameraViewPort.

Thanks Beaker!!!

Buggy - they would work except that I'm having the object (a map) so that you can move the camera all around it. A freeform camera doesn't work with sprites.

Mindstorms - I found I had to move the camera once in that mode to be able to see my object.


mindstorms(Posted 2006) [#17]
Is there any change in zoom when you change the mode of a camera? I am not seeing anything that I placed except the background, and that seems to be moving at warp speed. Am I missing something?


hockings(Posted 2006) [#18]
I'm no expert on camera mode 2 other than what I found when playing around with it. I found what the notes in the doco say though :-
Use 'CameraZoom' to control the scale of graphics rendered with orthographic projection. As a general rule, using orthographic projection with the default camera zoom setting of 1 will result in graphics that are too 'zoomed-in' - changing the camera zoom to 0.1 should fix this


Try setting camera zoom for the camera you're using to 0.1 and see if you can see your object.