Page 1 of 1

camera on the ground

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

Posted: Thu Mar 17, 2005 10:13 pm
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.

Posted: Fri Mar 18, 2005 3:28 pm
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?

Posted: Fri Mar 18, 2005 4:08 pm
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.

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

Posted: Tue Mar 29, 2005 10:16 am
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.

Posted: Tue Mar 29, 2005 10:21 am
by anjay
huuh.. how can I implement this for BSP map without RaySceneQuery and without deep programming, and without waiting for qsilver?..

Posted: Tue Mar 29, 2005 10:30 am
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.