Changing Camera Position does not change renderd image

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
SimonHawe
Posts: 12
Joined: Wed Aug 27, 2008 1:57 pm

Changing Camera Position does not change renderd image

Post by SimonHawe »

Hi to all,
when I move my camera around, and changing its position, target vector up vector etc. nothing happens, the output remains the same. I placed the camera on different initial positions and get different initial views but nothing changes when i move it around, that's pretty weird. Can you image why it does not work?
Simon
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

How do you render your scene? Do you have the while loop constantly rendering?

Are you sure the render is being updated?

Are you sure the camera is being moved? How do you know the camera's being moved if you don't see a change on screen?

If you code isn't too big you could post it here.
Image Image Image
SimonHawe
Posts: 12
Joined: Wed Aug 27, 2008 1:57 pm

Post by SimonHawe »

I render my scene to texture and the drawAll is called constantly in the while loop.
I know my camera has been moved from camera->getAbsolutePosition(). What do you mean be render is being updated? Perhaps i miss something at this point. But it is really strange because I have moved around cameras before.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Presumably you repeatedly render it back to the texture yes? Not just once..?

If you show us your render code where you render to the texture and how you render that texture onto the screen then we can probably help more :)
Image Image Image
SimonHawe
Posts: 12
Joined: Wed Aug 27, 2008 1:57 pm

Post by SimonHawe »

Code: Select all

ITexture * renderTarget = driver->createRenderTargetTexture(dimension2di(16,16));

	while(device->run())
		{
			
			driver->beginScene(false, true, video::SColor(0,200,200,200));
			m_lookVector = vector3df(0, 1, 0);
			for(int outerLoop = 0; outerLoop < m_nbrOfFacets; ++outerLoop)
			{
				for(int innerLoop = 0; innerLoop <= m_nbrOfFacetsV; innerLoop ++)
				{
					if(innerLoop != 0){
						m_lookVector.rotateXZBy(RADTODEG*(sign*m_angle),m_turnCenter);
						m_upVector.rotateXZBy(RADTODEG*(sign*m_angle),m_turnCenter);
						m_currentX	+=	(sign*m_stepping);
						accumulator	+=	m_angle;
					}


					camera->setTarget(camera->getAbsolutePosition() - m_lookVector);
					driver->setRenderTarget(renderTarget, true, true);
					smgr->drawAll();

					driver->setRenderTarget(0, false, false);
					rect<s32> sourceRect(0, 0, m_stepping-1, m_stepping-1);
					rect<s32> destRect(m_currentX-1, m_currentY-1,m_currentX+m_stepping-1, m_currentY+m_stepping-1);
					driver->draw2DImage(renderTarget, destRect, sourceRect);

				}

				m_lookVector.rotateXZBy(RADTODEG*(sign*(core::PI - accumulator)),m_turnCenter);
				m_lookVector.rotateXYBy(RADTODEG*(sign*(m_facetFov)),m_turnCenter);
				m_currentY	   -=	m_stepping;
				accumulator		=	0;
				sign		    =	sign*(-1);
				m_radius		=	sqrt(pow(m_lookVector.X,2)+pow(m_lookVector.Z,2));
				m_angle			=	acos(1-pow(m_sphereStep,2)/(2*pow(m_radius,2)));
				m_nbrOfFacetsV	=	round(core::PI/m_angle);
				if(m_nbrOfFacetsV == 32)
					m_nbrOfFacetsV = 31;
				m_currentX		=	256 - sign*(m_stepping*(m_nbrOfFacetsV+1))/2 - ((sign>0)? 0 : m_stepping);
			}

			if(receiver.IsKeyDown(KEY_LEFT))
				m_rotangle -= 30.f;
			if(receiver.IsKeyDown(KEY_RIGHT)){
				m_rotangle += 30.f;
			}
			
			camera->setPosition(core::vector3df(20+m_rotangle,20,10)); 
			camera->updateAbsolutePosition();
			driver->endScene();
		}

		
I left out not important things not used for rendering.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Code: Select all

m_lookVector = vector3df(0, 1, 0);

//...
m_lookVector.rotateXZBy(RADTODEG*(sign*m_angle),m_turnCenter);
m_upVector.rotateXZBy(RADTODEG*(sign*m_angle),m_turnCenter);
At a quick glance, it looks like you're rotating a Y vector around the Y axis. In other words, it's going to remain (0,1,0).

I'd imagine that you want to start with a (0, 0, 1) look vector.

In fact, I'm pretty sure. :P
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
SimonHawe
Posts: 12
Joined: Wed Aug 27, 2008 1:57 pm

Post by SimonHawe »

yes, but that is only the point once because i will then rotate this vector around z and this turned vector will be turned around y, but you are right it is once turend without being turned :) But anyway I can not move the camera :(
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Ah, right, I didn't see the m_lookVector.rotateXYBy().

What value does m_upVector start at? I don't see it being re-initialised to anything, let alone to a different value than (0,1,0).

Sorry, I'm not seeing much else wrong with this. I'm far more useful with a complete compilable, debuggable example, hint, hint.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
SimonHawe
Posts: 12
Joined: Wed Aug 27, 2008 1:57 pm

Post by SimonHawe »

solved the problem was just a dumb mistake, i reckon i have been working to long today :oops:
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Image

I need closure on that anecdote!
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Taymo
Posts: 55
Joined: Mon May 22, 2006 1:06 am
Location: Colorado Springs - CTU
Contact:

Post by Taymo »

I feel rogerBorg's pain, and why not just use Irrlicht's awesome addCameraSceneNodeFPS() function and forget about the camera for now. You're doing the same thing it's doing anyways..

edit* even with the render target stuff you could add an FPS camera and grab it's values after you've moved.
Ride the Spiral Development:
spiralride.blogspot.com
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Joking aside, you'll get more help from the community if you engage a bit more. A simple acknowledgement of the render to texture implementation that I took some time to provide would have been appreciated. Not demanded, just appreciated.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
SimonHawe
Posts: 12
Joined: Wed Aug 27, 2008 1:57 pm

Post by SimonHawe »

@rogerBorg, yes sorry for not saying thank you, even I do not really use your code anymore but it showed me that render to texture is much faster and without your help I reckon i would not have mentioned that and I hope you will keep on helping me. Thanks a lot.

@Taymon, what are you talking about? I had a completly stupid error in my code which had nothing to do with fps camera and i do not need an fps camera, it was just an reinitialization problem and as i already said I did not want to waist your time but after coding 15 hours sometimes you start missing things.[/list]
Post Reply