How can I make a manualobject have some physics attribute?

challenge

17-08-2008 15:40:43

I create a manualobject and attach it to a ScenceNode, how can I make it have some physics attribute? I've seen some Demos but I haven't find a similar one. Could someone help me?

rewb0rn

18-08-2008 18:40:21

What do you mean? It should be possible to create a transform geometry that fits your manual object, then you can create a body like you are used to it. search simplescenes for entityinformer.

challenge

20-08-2008 02:15:46

I've seen in the EntityInformer I found that it can creat boxes, balls, triangle meshs, but I don't know how to use the ei to make my manualobject have some physics.

Can anyone help me ? Thanks a lot.

My manualobject is a cone

rewb0rn

20-08-2008 06:15:39

well your manual objects should also contain a mesh so you should be able to create a trimeshgeometry for it.

challenge

20-08-2008 06:32:39

Should I creat a mesh myself, can I do this just by coding? Would you tell me how?

rewb0rn

20-08-2008 06:47:16

well i dont have in mind how to access the mesh of the manual object but there already has to be one else it could not be rendered. Probably something like getMesh()

challenge

10-09-2008 04:31:11

I've tried as you said, while it still doesn't work :( , would you please tell me why?

Here is my code. And my manualobject is a Aiguille.

ManualObject * circle = mSceneMgr->createManualObject(cName);

float const radius = 10,
thickness = 10, // Of course this must be less than the radius value.
accuracy = 0.5;


circle->begin("BaseWhiteNoLighting", RenderOperation::OT_TRIANGLE_LIST);
unsigned point_index = 0;
for(float theta = 0; theta <= 2 * Math::PI; theta += Math::PI / (radius * accuracy)) {

circle->position(radius * cos(theta),
10,
radius * sin(theta));
circle->position(radius * cos(theta - Math::PI / (radius * accuracy)),
10,
radius * sin(theta - Math::PI / (radius * accuracy)));
circle->position((radius - thickness) * cos(theta - Math::PI / (radius * accuracy)),
10,
(radius - thickness) * sin(theta - Math::PI / (radius * accuracy)));
// circle->position((radius - thickness) * cos(theta),
// 10,
// (radius - thickness) * sin(theta));
// Join the 4 vertices created above to form a quad.
circle->triangle(point_index, point_index + 1, point_index + 2);

point_index += 3;

}
circle->end();
circle->begin("Examples/RustySteel", RenderOperation::OT_TRIANGLE_LIST);
point_index = 0;
for(float theta = 0; theta <= 2 * Math::PI; theta += Math::PI / (radius * accuracy)) {

circle->position(radius * cos(theta),
10,
radius * sin(theta));
circle->textureCoord(0,0);
circle->position(radius * cos(theta - Math::PI / (radius * accuracy)),
10,
radius * sin(theta - Math::PI / (radius * accuracy)));
circle->textureCoord(0,1);
circle->position(0,0,0);
circle->textureCoord(1,1);
// Join the 4 vertices created above to form a quad.
circle->triangle(point_index,point_index+1,point_index+2);
point_index += 3;

}
circle->end();


circle->setQueryFlags(-2147483648);
circle->convertToMesh("Aiguille");
Entity* drillEntity = mSceneMgr->createEntity("Entity2", "Aiguille");

SceneNode* pNode=mSceneMgr->getRootSceneNode()->createChildSceneNode();
pNode->attachObject(drillEntity);
pNode->translate(dPos.x, dPos.y,dPos.z);
// Attach the entity to the root of the scene
// mSceneMgr->getRootSceneNode()->attachObject(patchEntity);

OgreOde::EntityInformer ei(drillEntity,Matrix4::getScale( pNode->getScale()));
OgreOde::Geometry *geom = ei.createStaticTriangleMesh(mWorld, mWorld->getDefaultSpace());
drillEntity->setUserObject (geom);
_geoms.push_back(geom);