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 » Thu Mar 17, 2005 3:44 pm

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.
0 x

User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
Contact:

Post by haffax » Thu Mar 17, 2005 10:13 pm

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.
0 x
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 » Fri Mar 18, 2005 3:28 pm

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?
0 x

User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
Contact:

Post by haffax » Fri Mar 18, 2005 4:08 pm

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.
0 x
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 » Tue Mar 29, 2005 9:03 am

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.
0 x

User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
Contact:

Post by haffax » Tue Mar 29, 2005 10:16 am

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.
0 x
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 » Tue Mar 29, 2005 10:21 am

huuh.. how can I implement this for BSP map without RaySceneQuery and without deep programming, and without waiting for qsilver?..
0 x

User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
Contact:

Post by haffax » Tue Mar 29, 2005 10:30 am

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.
0 x
team-pantheon programmer
creators of Rastullahs Lockenpracht

Post Reply