need some help

z789017890

13-01-2011 12:06:10

i want to create a physix car whit the NXOGRE.But I don't know how to do that~~
cant you send me some about how to create a physix car?

my gmail:zero16832@gmail.com

thanks for your help

mironix

13-01-2011 17:16:13

i would say 5 capsules, one for each weel and one for the body, that would be youre actor(Body) according to version of nxogre. i dont know yet how to work with custom surfaces, but on the normal surface u can define friction so it should be eazy to apply it (or not) to a custom geometry.

betajaen

13-01-2011 17:25:24

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.

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.


where is the NxOgreTutorials about the wheels and cars?

send me the address please

thanks

mironix

14-01-2011 01:16:00

there is no consistent documentation. there are samples on the github :) for 1.6 look here: https://github.com/betajaen/nxogretutorials

according to this: https://github.com/betajaen/nxogretutor ... index.html betajean is working on it :)

z789017890

14-01-2011 02:20:57

there is no consistent documentation. there are samples on the github :) for 1.6 look here: https://github.com/betajaen/nxogretutorials

according to this: https://github.com/betajaen/nxogretutor ... index.html betajean is working on it :)



i know this but is not the wheel or car Tutorials?~~

betajaen

14-01-2011 08:26:28

https://github.com/betajaen/nxogretutor ... 01/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

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.


Compile the BuggySwires src have error

what is the error is?

z789017890

15-01-2011 01:59:27

help me please~~

betajaen

15-01-2011 09:12:44

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.

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.



yes , i know that .

but some function don't have.

like this:

mFrontWheel = static_cast<Wheel*>( mUnicycle->getShapeById(FrontWheel) );
mBackWheel = static_cast<Wheel*>( mUnicycle->getShapeById(BackWheel) );


I try that:

mFrontWheel = static_cast<Wheel*>( mUnicycle->getShape(FrontWheel) );
mBackWheel = static_cast<Wheel*>( mUnicycle->getShape(BackWheel) );


but is have some error

betajaen

15-01-2011 14:07:37

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.

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.



yes , I Upgrade to BuggySwires and the BuggySwires version of Critter.

but have the other error.

the NEW Critter like don't have some function?

mephisto

16-01-2011 12:23:37

how about the machine class ? can someone just give the methodology how initialize the wheels and chassis ...

betajaen

16-01-2011 13:12:55

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: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. ;)


the error is this

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. ;)


i use this to Compile the 702 and the 701

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. ;)


i create a new project use the code with 702 and Compile it.

betajaen

16-01-2011 15:25:16

Replace NxOgre701 with this instead.

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.";
}

};



That aside, Any real programmer should be able to diagnose those problems and try and get to a solution. You can't just use and learn NxOgre by copying random sample code.

mephisto

16-01-2011 20:19:33

That is a "noob" question but I am really confused :
To create something for example a rigidbody;
we create an actor passing by mScene; (physic entity)
considering tha the shape is the link between the graphic and physic...
then we create a body using mRenderSystem; (graphic entity)

and the same logic for fluids etc...

but it seems that I am wrong ... :(
For example this code :
NxOgre::RigidBody* rigid_body;
NxOgre::RigidBodyDescription rigid_body_dsc;
Critter::Body* body;
Critter::BodyDescription body_dsc;
NxOgre::ShapeDescription shape_dsc;
NxOgre::Mesh* skeleton = NxOgre::MeshGenerator::makeBox(NxOgre::Vec3(3,3,3), NxOgre::Enums::MeshType_Skeleton);

rigid_body_dsc.mDensity = 0.2;
shape_dsc.mDensity = 0.2;
shape_dsc.mSkeleton = skeleton;
body_dsc.mMass = 10;

NxOgre::Vec3 pos(40,40,40);
//rigid body is an actor
rigid_body = mScene->createActor(shape_dsc, pos, rigid_body_dsc);
body = mRenderSystem->createBody(shape_dsc, pos, "box.mesh", body_dsc);

Please can someone just explain in a few words...

betajaen

16-01-2011 20:31:34

Body is a Actor + SceneNode (it even inherits from Actor). What exactly are you having problems with it?

mephisto

16-01-2011 20:37:34

This code doesnt work;
the problem seems to be in the descriptions
when i do something like this
if(shape_dsc.valid() && rigid_dsc.valide())
it always returns false;

mephisto

16-01-2011 21:14:24

In many examples only RenderSystem is used to create a body for example like this :

Body* box = mRenderSystem->createBody(BoxDescription(1,1,1), globalPose, "cube.1m.mesh", bodyDescription);

So I suppose boxDescription is a prefabricated version of a shape and doesnt need to pass by mScene...

betajaen

16-01-2011 21:49:14

Mass and Density can't be set at the same time, it's one or the other. Personally, I recommend you just set the mass, than the density.

ShapeDescription (and all Descriptions) is what you want it to be like, the Shape hasn't been created yet. Actor get's to do that for you.

mephisto

16-01-2011 23:00:48

1.I was awere about the choice of density or mass but as there was about 3 densities or mass to set :
RigidBodyDsc , ShapeDsc and CritterBodyDsc. .. How do they interact ? Or i need to set this only for ShapeDsc.

2.But about the createActor (may be I didnt understand) . I must do something like this :

// the question turns around the shape creation, this code crashes...

NxOgre::ShapeDescription shape_dsc;
NxOgre::RigidBodyDescription rigid_body_dsc;
shape_dsc.mMass = 10.0f;
// so the createActor fnct creates the shape for me, based on the shape_dsc...?;
NxOgre::Actor* actor = mScene->createActor(shape_dsc, pos, rigid_body_dsc); // <--- crash
NxOgre::Shape* shape = actor->getShape(0); // 0 is the default shape_dsc.mId

betajaen

16-01-2011 23:11:57

1. The PhysX document explains it far better than I could. Best thing to do is stick with RigidBodyDescription::mMass. But as far I can remember specific Mass or Density values for shapes, are useful if you have multiple shapes per RigidBody which are heavier than the other parts.

2. It's crashing because your using a ShapeDescription directly. Use BoxDescription, CapsuleDescription, SphereDescription, etc. instead.

mephisto

16-01-2011 23:39:19

1.OK
2.OK
Thank You!

mephisto

17-01-2011 06:58:22

It seems that when I do : body = mRenderSystem->createBody(boxdsc, pos, "cube.1m.mesh", body_dsc);
that I can not scale the mesh. Boxdsc.size scales the shape, can I scale the mesh?

Also just to be sure :
the difference between :
this :
rigid_body = mScene->createActor(bd, pos, rigid_body_dsc);
body = mRenderSystem->createBody(bd, pos, "cube.1m.mesh", body_dsc);

and this :
body = mRenderSystem->createBody(bd, pos, "cube.1m.mesh", body_dsc);

is that in the first I am specifying the rigidbody by the rigidbodydescription
In the second a default rigidbody is created. as I can do this in the second: body->getShape()->getRigidBody();
(and this applies for fluids etc...)

betajaen

17-01-2011 09:35:35

1. You can use mBody->getNode()->setScale() to scale your Body's SceneNode.

2. Bodies are Actors which are RigidBodies. When you create a Body, your also creating an Actor and RigidBody as well, all part of the same class. Any code that requires a RigidBody will happily accept any derivatives of it; Actors, KinematicActors, SceneGeometries, Volumes, Bodies and KinematicBodies.

mephisto

17-01-2011 15:35:41

may be I am agassant but still have question. A Critter::Body is an entire physic+graphic entity and for example when I set :
critter_body.mMass or mLinearVelocity this concerns the rigid body .
But I tried 2 cases :

body_dsc.mMass = 100.0f;
body_dsc.mLinearVelocity.set(0,-20,0);
body = mRenderSystem->createBody(bd, pos, "cube.1m.mesh", body_dsc);

and

rigid_body_dsc.mMass = 100.0f;
rigid_body_dsc.mLinearVelocity.set(0,-20,0);
//nothing for body_dsc
rigid_body = mScene->createActor(bd, pos, rigid_body_dsc);
body = mRenderSystem->createBody(bd, pos, "cube.1m.mesh", body_dsc);

The cube's behavior wasnt the same;(in the first the cube falls very simply but in the second the fall is very realistic)