Need Help : Stop Background Zoom

Blitz3D Forums/Blitz3D Programming/Need Help : Stop Background Zoom

-Rick-(Posted 2004) [#1]
I'm having trouble with a zoom effect in my program. I've tried searching the forums but one word searches leave alot of stuff to sift thru. I'm thinking this might be a basic thing that I'm overlooking.

I have a space scene, my skybox is textured onto a small sphere that my camera sits within. I have the skybox z-order to be drawn first. When I increase or decrease zoom the skybox is effected as well and I dont want this. I want my starfield to remain the same as the rest of the stuff zooms in and out.

I've been messing with turning the cameraclsmode on and off and hiding my skybox and processing an extra renderworld in various setups but I havent quite gotten it. I've managed to keep the skybox from zooming but the rest of the stuff doesnt clearscreen and I end up with my screen overwriting itself - OR - I get the zoom to work in and out by my skybox vanishes entirely.

Can anyone help out with this?


Warren(Posted 2004) [#2]
One solution would be to create a second camera to sit inside the skybox mesh. Send that camera and mesh somewhere in the world where they won't be seen by the normal camera.

Then you can scale/zoom the main camera all you want and the skybox would be unaffected.


-Rick-(Posted 2004) [#3]
Sigh...30 minutes of explaining that didnt work and what I tried just went down the drain when i hit the wrong key and this page backed up one and all i'd typed was 'forgotten'...sigh.

Needless to say I didnt figure it out. I yielded the same result. Either the Background "skybox" vanishes entirely or I actually do manage it to maintain its normal size while the rest of the scene zooms, but with no clearscreen going on everything leaves afterimages of itself.

Can you explain a bit more on how to merge two camera's into the one shot? Multiple camera windows I've done, but never mixed two cameras together for 1 scene. Below is my attempts with just 1 camera.

While Not Done
.
.
.
ShowEntity Universe              ;Make sure we see skybox
CameraClsMode Camera,False,True  ;Turn of screen clearing
EntityOrder Universe,0           ;Draw skybox normaly, since
                                 ;it is so small it draws
                                 ;only our skybox
CameraZoom camera,1              ;Image skybox at x1
UpdateWorld()                    ;Computer Everything
Hide Universe                    ;Now we want to see thru
                                 ;skybox
EntityOrder Universe,1           ;
CameraZoom camera,czoom          ;Zoom the scene
.
.
.
Flip()
UpdateWorld()
RenderWorld()
Wend

This is basically what I'm doing. I've altered this many times trying to hammer it out - adding in extra UpdateWorlds to clear the screen area before turning of screen clearing again, hiding entities, altering z-orders, etc. I'm definatly missing something.


Floyd(Posted 2004) [#4]
You are not drawing anything while CameraZoom is set to 1.
Replace the first UpdateWorld with RenderWorld.


-Rick-(Posted 2004) [#5]
Floyd said
"You are not drawing anything while CameraZoom is set to 1."


Not true, its drawing ONLY my skybox since the z-order has been set back to normal and its drawing it at the correct zoom size. My skybox sphere is much smaller than the surrounding environment so it is all that the camera sees when i change its EntityOrder to 0 (the camera is located at center of the skybox sphere - sorry if I didnt make that clear)

If I run as shown up there then everything works the way i want (background remains x1 zoom while rest of stuff enlarger/shrinks as i change zoom) exept that all (but background) leaves afterimages from what appears to be no clear screen command going on. Its like I need to add a clearscreen command in somewhere.

If I change the "UpdateWorld()" to "RenderWorld()" then I lose all other images and entities and see only the background skybox (not zooming at least).

Here's the entirety of the code for the zoom snippette :

	If MouseDown(1) Then czoom = czoom + .1
	If MouseDown(2) Then czoom = czoom - .1
	If czoom < 1 Then czoom = 1
	If czoom > 50 Then czoom = 50
			
	ShowEntity universe                ;Skybox/Background
	CameraClsMode camera,False,True
	EntityOrder universe,0
	CameraZoom camera,1
	;RenderWorld()
	UpdateWorld()
	HideEntity universe
	EntityOrder universe,1
	CameraZoom camera,czoom
		
	If MouseDown(3) Then
		CameraClsMode camera,True,True
		showentity Universe
		czoom = 1
		CameraZoom camera,czoom
		PanelMode = 1
		MoveMouse GraphicsWidth()/2 - 3,GraphicsHeight()/2 -3 
	EndIf

It feels to me like I'm getting the effect I want, but missing a crucial screen clear somewhere so it keeps writing the images overtop of each other. Here's a screenshot of that effect : Note how the background is stable while all other entities leave a ghost as their zoom or position changes.




-Rick-(Posted 2004) [#6]
Still struggling over this :( Anyone with any other ideas?


_PJ_(Posted 2004) [#7]

It feels to me like I'm getting the effect I want, but missing a crucial screen clear somewhere so it keeps writing the images overtop of each other. Here's a screenshot of that effect : Note how the background is stable while all other entities leave a ghost as their zoom or position changes.


That's messing with the CameraCls that does that.

As a workaround...

instead of using camera zoom, I actually move the camera towards the focal entity. The original camera position and orientation is stored, and the use of pivots is handy.

What effect are you trying to achieve using CameraZoom?



Can you explain a bit more on how to merge two camera's into the one shot? Multiple camera windows I've done, but never mixed two cameras together for 1 scene. Below is my attempts with just 1 camera.


You can render each camera view onto the buffer before flipping.

ShowEntity camera1
HideEntity camera2
UpdateWorld
Renderworld

ShowEntity camera2
HideEntity camera1
UpdateWorld
Renderworld

Flip




-Rick-(Posted 2004) [#8]
instead of using camera zoom, I actually move the camera towards the focal entity.


<stunned look> I never thought of that. I think that might be the easiest way for me to go. Thanks Malice!


-Rick-(Posted 2004) [#9]
Success!

At first i attemtped to move my camera and simulate a zoom. Unfortunatly this would allow my camera to pass thru objects that were too close and I really didnt like that. Made a quick attempt to detect collisions but just didnt really want to go that route.

Re-looked at what Malice said and applied the Render and Update World commands, this time without the '()' and I applied them twice. Bang on the first try! I KNEW it was simply a matter of placing things in the right place :)

There is one small hitch that I can live with and that is some discrepancy with drawing to the viewport. Some stuff wrote out ( a few text lines giving info like FPS, and other test values), but others didnt appear (text displaying magnify level, the "dash panel". A small matter that I'm sure I'll figure out and probably has to do with when and where things are drawn.

Heres the working code :

	ShowEntity universe			;Show Skybox
	CameraClsMode camera,False,True		;Turn off Camera Cls
	EntityOrder universe,0			;Normal z-order for skybox
	CameraZoom camera,1			;Magnify skybox in Normal Zoom
	UpdateWorld				;Since skybox obscures rest of Scene
	RenderWorld				;   we only draw the skybox here
	HideEntity universe		        ;Hide skybox
	EntityOrder universe,1			;Set z-order to First draw again
	CameraZoom camera,czoom			;Zoom our camera to desired Zoom amount
	UpdateWorld				;Draw the zoomed scene over top our
	RenderWorld 				;   unzoomed skybox

Huge Thanks to you guys! This was one of those things that just annoyed me so much!


Damien Sturdy(Posted 2004) [#10]
ruddy heck i just had this problem. woo. an answer before i posted! nice ^.^


_PJ_(Posted 2004) [#11]
Place ALL of your TEXT after the final RENDER statement and BEFORE the Flip command.


aCiD2(Posted 2004) [#12]
Malice, unless its 3d text... :P


_PJ_(Posted 2004) [#13]
There's always one!!!

Yeah, good point.

By the way, looking at that screenshot, I keep thinking of the old, Captain blood game, or maybe original star-trek special effects heheh! It's got some class of its own, really!


-Rick-(Posted 2004) [#14]
Here's a screeny from the current program. I've only just started it and most of this is just starter gfx that I intend to improve on. I'm making a Tour program for our Solar System (and possibly other discovered system with planets) for kids interested in Astronomy (my 6 yr old daughter loves it).

I thought it a solid project for 3d work and something interesting to get me back into programming blitz.



The sun is NOT labeled JUPITER there, heh, its actually behind the sun. Yet one other mini bug to work out with LOS ;)



Once I've worked up a proper working program and get happy with my gfx I'll post more screenshots in the Show Art section and explain more on the program. Thanks for all your help everybody!