camera on the ground

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
anjay
Gnoblar
Posts: 9
Joined: Thu Mar 17, 2005 3:29 pm
Location: Vilnius, Lithuania

camera on the ground

Post by anjay »

how to make camera in DemoBspCollision to move only on the ground no matter whats direction (orientation?) it is? should I use here RaySceneQuery to check distance from camera to ground? (I tried this, my code crashed).

thanks, for your answer.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 7
Contact:

Post by haffax »

When it crashed, you did something wrong. A RaySceneQuery is one solution, look at the terrain demo source for how to do it, for it uses a RaySceneQuery for this exact cause.
team-pantheon programmer
creators of Rastullahs Lockenpracht
anjay
Gnoblar
Posts: 9
Joined: Thu Mar 17, 2005 3:29 pm
Location: Vilnius, Lithuania

Post by anjay »

thanks I will. what could be another solution for this? I think gravity of the world will not affect collide camera, or I am wrong?
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 7
Contact:

Post by haffax »

You could manually manage gravity for the camera. This is what we do in our project. I don't know the reference layer, we use OgreOde, but it should be possible.
team-pantheon programmer
creators of Rastullahs Lockenpracht
anjay
Gnoblar
Posts: 9
Joined: Thu Mar 17, 2005 3:29 pm
Location: Vilnius, Lithuania

Post by anjay »

I still have the same dificulty with moving my camera in BSP world. when changed direction, it moves along it's vector, not on the ground. I am doing with RaySceneQuery to check if my camera is over the ground, but no more than 10 units. in my program I use code from TerrainDemo example, but it works not properly with BSP world. the code I use:
  • in createScene() method:

    Code: Select all

       raySceneQuery = mSceneMgr->createRayQuery(
                Ray(mCamera->getPosition(),
                Vector3::NEGATIVE_UNIT_Z));
    
  • in frameEnded() method of Refference Application Frame Listener class

    Code: Select all

       static Ray updateRay;
       updateRay.setOrigin(mCamera->getPosition());
       updateRay.setDirection(Vector3::NEGATIVE_UNIT_Z);
       raySceneQuery->setRay(updateRay);
       RaySceneQueryResult& qryResult = raySceneQuery->execute();
       RaySceneQueryResult::iterator i = qryResult.begin();
       if (i != qryResult.end() && i->worldFragment) {
             zfHeroNode->setVisible(false);
             SceneQuery::WorldFragment* wf = i->worldFragment;
             mCamera->setPosition(mCamera->getPosition().x,
                 mCamera->getPosition().z,
                 i->worldFragment->singleIntersection.y + 10);
       }
    
it seems if statement never becomes true.. what could be the reason of not working peace of code?
thank you.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 7
Contact:

Post by haffax »

Th reason is very simple, I fear. RaySceneQueries aren't supported for BSP world fragments. They just aren't tested for. qsilver is now enhancing the BspSceneManager afaik, so this might be implemented in the near future.
team-pantheon programmer
creators of Rastullahs Lockenpracht
anjay
Gnoblar
Posts: 9
Joined: Thu Mar 17, 2005 3:29 pm
Location: Vilnius, Lithuania

Post by anjay »

huuh.. how can I implement this for BSP map without RaySceneQuery and without deep programming, and without waiting for qsilver?..
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 7
Contact:

Post by haffax »

You could for instance use ODE ray geoms for it and let ODE handle the collision with the ground. See the ReferenceAppLayer on how to use BSP together with ODE, it's not pretty but works.
team-pantheon programmer
creators of Rastullahs Lockenpracht
Post Reply