Cylinder and Cone Positioning oddity.

darkheron

09-02-2014 17:55:01

Hello,

I am currently using Ogre 1.9 (ghadamon stable) and the latest ogre procedural (unstable) library on linux. Whenever I generate a Cone as such:
Procedural::ConeGenerator().setRadius(5).setHeight(5).realizeMesh("Cone");

or a Cylinder as such :
Procedural::CylinderGenerator().setRadius(5).setHeight(5).realizeMesh("Cylinder");

It seems that the actual origins of the generated meshes is generated along the bottom side of the Y axis, as opposed to being in the center of the mass (bounding box) as I thought it would be. As a result my operations do not end up manipulating as I expect... ie a call such as: setPosition(10,0,0) on the attached SceneNode, does indeed shift the node and the attached mesh object, but the center of the mesh is not translated to this location, rather the *bottom side* of the mesh is moved here. Sort of like in Blender, if you aligned the origin into the center of the planes that make up the bottom side of these two object types. Sphere, Box, Capsule, and Plane do not exhibit this behaviour, and if I replace the procedurally generated Cone/Cylinder versions with ones exported from Blender (into the exact same code), I get the expected behaviour... ie the objects are translated with the center of mass at the requested position.

It is entirely possible that this is by design, or that I have done something wrong. I would appreciate any advice.

TIA, and let me know if more explanation/clarity is required.

mikachu

10-02-2014 13:33:07

Yes, it's a convention from OgreProcedural to generate a cylinder from the origin to (0,length,0).

If you want a cylinder or a cone centered around the center of mass, you can translate it by (0,-length/2,0), using the CylinderGenerator's setPosition (the sceneNode's setPosition doesn't modify the mesh itself, it just translates the entity's origin).

darkheron

10-02-2014 17:43:27

Thank you that worked nicely,

For my education, may I ask why you treat these two primitives differently? Does it aid in the construction of compound primitives or something?

Thanks again.