z789017890
13-01-2011 12:06:10
cant you send me some about how to create a physix car?
my gmail:zero16832@gmail.com
thanks for your help
z789017890
13-01-2011 12:06:10
mironix
13-01-2011 17:16:13
betajaen
13-01-2011 17:25:24
z789017890
14-01-2011 00:23:22
It's four WheelDescriptions and a Chassis BoxDescription or ConvexDescription. You can build it manually or use the Machine series of classes.
There is plenty of code floating around on the forums, and there is at least two tutorials on NxOgreTutorials github page involving wheels and cars.
mironix
14-01-2011 01:16:00
z789017890
14-01-2011 02:20:57
there is no consistent documentation. there are samples on the githubfor 1.6 look here: https://github.com/betajaen/nxogretutorials
according to this: https://github.com/betajaen/nxogretutor ... index.html betajean is working on it
betajaen
14-01-2011 08:26:28
z789017890
14-01-2011 11:55:38
https://github.com/betajaen/nxogretutorials/blob/buggyswires/build/NxOgre701/701.cpp
Is source code to create a Unicycle. (Lines 61-93) for setup, (Lines 137-147) to move it
https://github.com/betajaen/nxogretutor ... 02/702.cpp
Is source code to create a Bicycle. (Lines 61-97) for setup, (Lines 159-169) to move it
Creating a car, is just adding two more wheels.
That should get you started at least. If you need specific help on a particular line of code -- ask.
z789017890
15-01-2011 01:59:27
betajaen
15-01-2011 09:12:44
z789017890
15-01-2011 12:54:55
Just use Detritus and Critter.
You don't need to compile that code I posted to understand it. Just READ the source code out aloud, until you understand what it does.
mFrontWheel = static_cast<Wheel*>( mUnicycle->getShapeById(FrontWheel) );
mBackWheel = static_cast<Wheel*>( mUnicycle->getShapeById(BackWheel) );
mFrontWheel = static_cast<Wheel*>( mUnicycle->getShape(FrontWheel) );
mBackWheel = static_cast<Wheel*>( mUnicycle->getShape(BackWheel) );
betajaen
15-01-2011 14:07:37
z789017890
16-01-2011 11:15:42
Alright then. Upgrade to BuggySwires and the BuggySwires version of Critter
But there are other ways at getting those shapes. Your just doing it incorrectly; getShape gets the shape by order of inserting into the ShapeDescriptions vector, and getShapeById by a personal Id.
mephisto
16-01-2011 12:23:37
betajaen
16-01-2011 13:12:55
z789017890
16-01-2011 15:10:06
What are the errors now? You mean that Screenshot?
@mephisto
It's best not use the Machine classes when your beginner. You need to walk first then run.
z789017890
16-01-2011 15:12:16
What are the errors now? You mean that Screenshot?
@mephisto
It's best not use the Machine classes when your beginner. You need to walk first then run.
z789017890
16-01-2011 15:14:17
What are the errors now? You mean that Screenshot?
@mephisto
It's best not use the Machine classes when your beginner. You need to walk first then run.
betajaen
16-01-2011 15:25:16
class _OgreSampleClassExport NxOgre701 : public SdkSample
{
public:
NxOgre::World* mWorld;
NxOgre::Scene* mScene;
Critter::RenderSystem* mRenderSystem;
Body* mUnicycle;
Wheel* mWheel;
// So we can identify with shape is which later.
enum ShapeIds
{
Chassis = 1,
MiddleWheel = 2
};
void setupPhysics()
{
createWorldSceneEtc();
Critter::BodyDescription bodyDescription;
bodyDescription.mMass = 40.0f;
// The body is going to have only one wheel (A unicycle) to prevent it falling over, we'll cheat physics and
// freeze the rotations of this body only.
bodyDescription.mDynamicRigidbodyFlags += DynamicRigidbodyFlags::FreezeRotationX;
bodyDescription.mDynamicRigidbodyFlags += DynamicRigidbodyFlags::FreezeRotationZ;
// A body with a wheel can't sleep. So we'll make the sleep counter to ~3 years!
bodyDescription.mWakeUpCounter = 1E8;
NxOgre::ShapeDescriptions shapes;
// A wheel can't just be attached to a Actor/Body by itself, it needs a chassis for collisions.
BoxDescription box_desc;
box_desc.mSize.set(1,1,1);
box_desc.mId = Chassis;
// Wheels are like normal shapes, they are attached to the Actor/Body just like a Box or a Sphere
WheelDescription wheel_desc;
wheel_desc.mRadius = 0.5f;
wheel_desc.mLocalPose = Vec3(0,-0.5,0); // This wheel is just going to be underneath the box.
wheel_desc.mId = MiddleWheel;
shapes.push_back(&box_desc);
shapes.push_back(&wheel_desc);
mUnicycle = mRenderSystem->createBody(shapes, Vec3(0,3,0), "cube.1m.mesh", bodyDescription);
// Go through the shapes and find our wheel, via the Id that was just set earlier.
// Remember we don't delete the shapes, the Actor/Body will for us. We're just borrowing them.
mWheel = static_cast<Wheel*>( mUnicycle->getShapeById(MiddleWheel) );
// Wheels's aren't normally rendered, but later tutorials will cover this with the Machine class
// For now, turn on the VisualDebugger so you can see it.
NxOgre::VisualDebuggerDescription vd_desc;
vd_desc.showDebug();
mRenderSystem->createVisualDebugger(vd_desc);
}
void createWorldSceneEtc()
{
// The usual suspects.
mWorld = NxOgre::World::createWorld();
NxOgre::ResourceSystem::getSingleton()->openProtocol(new Critter::OgreResourceProtocol());
mWorld->getRemoteDebugger()->connect();
NxOgre::SceneDescription scene_description;
scene_description.mGravity = Constants::MEAN_EARTH_GRAVITY;
scene_description.mUseHardware = false;
mScene = mWorld->createScene(scene_description);
mScene->createSceneGeometry(NxOgre::PlaneGeometryDescription());
mRenderSystem = new Critter::RenderSystem(mScene, mSceneMgr);
mScene->getMaterial(0)->setAll(0.1, 0.5,0.5);
}
Body* makeBox(const Matrix44& globalPose, const Vec3& initialVelocity = Vec3::ZERO, GroupIdentifier group = 0)
{
Critter::BodyDescription bodyDescription;
bodyDescription.mMass = 40.0f;
bodyDescription.mLinearVelocity = initialVelocity;
BoxDescription box_desc;
box_desc.mSize.set(1,1,1);
box_desc.mGroup = group;
Body* box = mRenderSystem->createBody(box_desc, globalPose, "cube.1m.mesh", bodyDescription);
return box;
}
bool keyPressed(const OIS::KeyEvent& evt)
{
// Listen to the IJKL keys to rotate and turn the wheel.
if (evt.key == OIS::KC_I)
mWheel->setMotorTorque(100); // Forward
else if (evt.key == OIS::KC_K)
mWheel->setMotorTorque(-100); // Reverse
else
mWheel->setMotorTorque(0); // Apply no torque if forward/reverse isn't down.
if (evt.key == OIS::KC_J)
mWheel->setSteeringAngle(mWheel->getSteeringAngle() + NxOgre::Radian(0.1)); // Turn left
else if (evt.key == OIS::KC_L)
mWheel->setSteeringAngle(mWheel->getSteeringAngle() - NxOgre::Radian(0.1)); // Turn right.
return SdkSample::keyPressed(evt);
}
void stopPhysics()
{
NxOgre::World::destroyWorld();
}
void setupContent()
{
ColourValue background = ColourValue(16.f/255.f, 16.f/255.f, 16.f/255.f);
mViewport->setBackgroundColour(background);
mSceneMgr->setFog(Ogre::FOG_EXP, background, 0.001, 800, 1000);
// set shadow properties
mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE);
mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5));
mSceneMgr->setShadowTextureSize(1024);
mSceneMgr->setShadowTextureCount(1);
// create a floor mesh resource
Ogre::MeshManager::getSingleton().createPlane("floor", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Plane(Vector3::UNIT_Y, 0), 1000, 1000, 1,1 , true, 1, 1, 1, Vector3::UNIT_Z);
// create a floor entity, give it a material, and place it at the origin
Entity* floor = mSceneMgr->createEntity("Floor", "floor");
floor->setMaterialName("ground-from-nxogre.org");
floor->setCastShadows(false);
mSceneMgr->getRootSceneNode()->attachObject(floor);
// use a small amount of ambient lighting
mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3));
// add a bright light above the scene
Light* light = mSceneMgr->createLight();
light->setType(Light::LT_POINT);
light->setPosition(-10, 40, 20);
light->setSpecularColour(ColourValue::White);
mCamera->setPosition(10,10,10);
mCamera->lookAt(0,0.5,0);
mCamera->setNearClipDistance(0.02f);
mCamera->setFarClipDistance(1000.0f);
mCameraMan->setTopSpeed(7.5);
setupPhysics();
}
void cleanupContent()
{
stopPhysics();
}
bool frameRenderingQueued(const FrameEvent& evt)
{
// Advance NxOgre.
mWorld->advance(evt.timeSinceLastFrame);
// Don't let the camera go underground.
if (mCamera->getPosition().y < 0.5f)
{
Ogre::Vector3 pos = mCamera->getPosition();
pos.y = 0.5f;
mCamera->setPosition(pos);
}
return SdkSample::frameRenderingQueued(evt);
}
NxOgre701()
{
mInfo["Title"] = "NxOgre 701";
mInfo["Description"] = "NxOgre 701 - Wheel Shapes";
mInfo["Thumbnail"] = "thumb_skybox.png";
mInfo["Category"] = "Physics";
mInfo["Help"] = "Filtering collisions.";
}
};
mephisto
16-01-2011 20:19:33
betajaen
16-01-2011 20:31:34
mephisto
16-01-2011 20:37:34
mephisto
16-01-2011 21:14:24
betajaen
16-01-2011 21:49:14
mephisto
16-01-2011 23:00:48
betajaen
16-01-2011 23:11:57
mephisto
16-01-2011 23:39:19
mephisto
17-01-2011 06:58:22
betajaen
17-01-2011 09:35:35
mephisto
17-01-2011 15:35:41