
Then in the second one I have moved the camera just a little bit and they go away!

Code: Select all
node = sceneMgr->getRootSceneNode()->createChildSceneNode("DefaultOgreNode");
ent = sceneMgr->createEntity("DefaultOgre", "ogrehead.mesh");
node->attachObject(ent);
Ogre::ManualObject *manObj = sceneMgr->createManualObject("DefaultManObj");
node = node->createChildSceneNode("DefaultManObjNode");
node->attachObject(manObj);
manObj->setBoundingBox(aabb);
manObj->setUseIdentityProjection(true);
manObj->setUseIdentityView(true);
manObj->begin("ManualColor",Ogre::RenderOperation::OT_TRIANGLE_FAN);
manObj->position(-0.30, -0.20, 0);
manObj->position(-0.30, 0.20, 0);
manObj->position( 0.30, 0.20, 0);
manObj->position( 0.30, -0.20, 0);
manObj->index(0);
manObj->index(1);
manObj->index(2);
manObj->index(3);
manObj->end();
Code: Select all
manObj->setUseIdentityProjection(true);
manObj->setUseIdentityView(true);
Interesting option. Will give that a crank. Can you comment on the cost of such an operation given that we may have thousands of such banners looking at the camera. Presumably the lookAt function needs to be called with each frame update (assuming that the camera is moved during a frame update) for each banner that must look at the camera in this fashion.sinbad wrote:To make them behave like billboards, you could use SceneNode::lookAt or SceneNode::setAutoTracking to get the node the manual object is attached to to constantly track the camera position.
Thanks for that description.The view space transform what takes an object from world space to a space where the camera is at the origin, facing down the -Z axis. The projection matrix converts the wedge-shaped frustum to a homogenous cube {-1, +1} in all directions (well, actually it's {0,1} for Z in freaky D3D), which clearly squashes objects at the far end of the frustum. Setting each of these to identity clear does different things - an identity view means that it doesn't matter where the camera is, and an identity projection means that objects must already be scaled within that homogenous cube to be visible.
Code: Select all
Ogre::SceneNode *camNode = sceneMgr->getRootSceneNode()->createChildSceneNode("CameraNode");
camNode->setPosition(0, 100, 100);
Ogre::SceneNode *pitchNode = camNode->createChildSceneNode("PitchNode");
pitchNode->attachObject(camera);
pitchNode->pitch(Ogre::Degree(-30));
Ogre::AxisAlignedBox aabb;
aabb.setInfinite();
/*
** Create three copies of the same setup to test different settings
** This one will not have anything other than defualt settings
*/
node = sceneMgr->getRootSceneNode()->createChildSceneNode("DefaultOgreNode", Ogre::Vector3(0, 50, 0));
ent = sceneMgr->createEntity("DefaultOgre", "ogrehead.mesh");
node->attachObject(ent);
Ogre::Vector3 offset = Ogre::Vector3(0,50,0);
Ogre::ManualObject *manObj = sceneMgr->createManualObject("DefaultManObj");
node = sceneMgr->getRootSceneNode()->createChildSceneNode("DefaultManObjNode");
node->setPosition(offset);
node->attachObject(manObj);
node->setAutoTracking(true, camNode, Ogre::Vector3::NEGATIVE_UNIT_Z, Ogre::Vector3(0, 0, 0));
manObj->setBoundingBox(aabb);
Code: Select all
bool DeviceListener::frameStarted(const Ogre::FrameEvent& evt)
{
/*
** Capture from Devices
*/
mMouse->capture();
mKeyboard->capture();
/*
** Move the mmCamera based on input
*/
mCamNode->yaw(mMouseYaw * evt.timeSinceLastFrame);
mPitchNode->pitch(mMousePitch * evt.timeSinceLastFrame);
mCamNode->translate(mPitchNode->getWorldOrientation() * mDirection * evt.timeSinceLastFrame);
mMouseYaw = mMousePitch = 0;
mCamNode->_update(true, false);
Ogre::SceneNode *node = mSceneMgr->getSceneNode("DefaultOgreNode");
Ogre::Vector3 offset = mCamera->getWorldOrientation().Inverse() * (node->getWorldPosition() - mCamera->getWorldPosition());
offset += Ogre::Vector3(0,50,0);
node = mSceneMgr->getSceneNode("DefaultManObjNode");
node->setPosition(offset);
return mContinue;
}
Code: Select all
node = sceneMgr->getRootSceneNode()->createChildSceneNode("CameraNode");
node->setPosition(0, 100, 100);
node = node->createChildSceneNode("PitchNode");
node->attachObject(camera);
node->pitch(Ogre::Degree(-30));
Ogre::AxisAlignedBox aabb;
aabb.setInfinite();
/*
** Create three copies of the same setup to test different settings
** This one will not have anything other than defualt settings
*/
node = sceneMgr->getRootSceneNode()->createChildSceneNode("DefaultOgreNode", Ogre::Vector3(0, 50, 0));
ent = sceneMgr->createEntity("DefaultOgre", "ogrehead.mesh");
node->attachObject(ent);
float diff = node->getWorldPosition().z - camera->getWorldPosition().z;
Ogre::Vector3 offset = Ogre::Vector3(0,50,diff);
Ogre::ManualObject *manObj = sceneMgr->createManualObject("DefaultManObj");
node = sceneMgr->getRootSceneNode()->createChildSceneNode("DefaultManObjNode");
node->setPosition(offset);
node->attachObject(manObj);
manObj->setBoundingBox(aabb);
manObj->begin("Cone",Ogre::RenderOperation::OT_TRIANGLE_FAN);
manObj->position(-20.0, -20.0, 0);
manObj->textureCoord(0, 0, 0);
manObj->position(-20.0, 20.0, 0);
manObj->textureCoord(0, -1, 0);
manObj->position( 20.0, 20.0, 0);
manObj->textureCoord(1, -1, 0);
manObj->position( 20.0, -20.0, 0);
manObj->textureCoord(1, 0, 0);
manObj->index(3);
manObj->index(2);
manObj->index(1);
manObj->index(0);
manObj->end();
// manObj->setUseIdentityProjection(true);
manObj->setUseIdentityView(true);