Changing Camera Position does not change renderd image
Changing Camera Position does not change renderd image
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
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
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.
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.
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();
}
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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);
I'd imagine that you want to start with a (0, 0, 1) look vector.
In fact, I'm pretty sure.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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.
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
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
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.
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
spiralride.blogspot.com
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
@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]
@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]