goldman82
23-06-2007 13:41:29
hi,
iam new here. i have read many threads here...
but nothing helps me. now i made a simple app with a plane an a camera body over it. the gravity works, my camra falls down. but dont collide with my plane.
first i set up the newton:
and then i create the plane:
for moving the cambody i used setVelocity(). that is working...
whats going wrong? i tried it now for 3 days and i have no idea
Thanks
goldman82
iam new here. i have read many threads here...
but nothing helps me. now i made a simple app with a plane an a camera body over it. the gravity works, my camra falls down. but dont collide with my plane.
first i set up the newton:
mWorld = new OgreNewt::World();
mWorld->setWorldSize(AxisAlignedBox(-100000,-100000,-100000,100000,100000,100000));
mOgreNewtListener = new OgreNewt::BasicFrameListener(mWindow, sceneMgr, mWorld, 120);
mRoot->addFrameListener(mOgreNewtListener);
Ogre::Vector3 size(1.0,15.0,1.0);
Ogre::SceneNode* camnode = sceneMgr->getRootSceneNode()->createChildSceneNode();
camnode->setScale(size);
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Ellipsoid(mWorld, size);
cambody = new OgreNewt::Body(mWorld, col);
cambody->attachToNode(camnode);
delete col;
Ogre::Real mass = 1.0;
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcBoxSolid(mass, size);
cambody->setMassMatrix(mass, inertia);
//cambody->setStandardForceCallback();
cambody->setCustomForceAndTorqueCallback<Application>(&Application::camera_force_callback,this);
cambody->setAutoFreeze(0);
Ogre::SceneNode* camviewnode = camnode->createChildSceneNode(Vector3(0,5,0));
camviewnode->attachObject(mCamera);
and then i create the plane:
Plane plane( Vector3::UNIT_Y, 0 );
MeshManager::getSingleton().createPlane("ground",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);
Ogre::Entity *ent = sceneMgr->createEntity( "GroundEntity", "ground" );
meshnode->attachObject(ent);
Ogre::Vector3 siz(5,2.5,2.5);
meshnode->setScale( siz );
//OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::TreeCollision(mWorld, meshnode, true);
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Box(mWorld,siz);
OgreNewt::Body* bod = new OgreNewt::Body(mWorld, col);
delete col;
bod->attachToNode(meshnode);
bod->setPositionOrientation( Ogre::Vector3(0.0,-10.0,0.0), Ogre::Quaternion::IDENTITY );
for moving the cambody i used setVelocity(). that is working...
whats going wrong? i tried it now for 3 days and i have no idea
Thanks
goldman82