How to make irregualar shape object interact with other models?

May 16, 2010 at 7:27 AM
Edited May 16, 2010 at 7:31 AM

I want to make a physics simulation that a torus fall through a cylinder under gravity, but GoblinXNA.Physics.ShapeType only support some predefined shape (e.g. Box and Cylinder) and Compound, ConvexHull and TriangleMesh. If I use the simple shapes such as Box and Cylinder, the torus will not fall through because the physics engine doesn't recognize the hold in the torus. The same situation occurred when using ConvexHull. I cannot use Compound because I don't know how to set up the ShapeData. And when I try TriangleMesh, the torus just don't move!!

Another problem: If I design my own model using 3dsmax and export to fbx file, how can I set up the simulation so the dynamics is correct (corresponding to the model shape)?

I'm a beginner at GoblinXNA and don't know how to solve this problem, please show me how to do this if you have any ideas, thanks!!

Coordinator
May 16, 2010 at 11:43 AM

Unfortunately, the Newton doesn't have Torus primitive, and you need to create it with Compound type to do what you want to do. Torus is rather a complicated shape, so you probably need a list of cylinder shapes to represent it. TriangleMesh in Newton cannot be moved. 

For any models with complicated shape, if you want to have correct dynamic behavior, you need to model them using Compound shapes, and you probably need to write your own content pipeline to assign correct shapes based on the model. Other solution is to implement IPhysics class with another physics engine of your choice, and plug it in to use with Goblin XNA. Commercially available physics engine such as Havok may do this for you.

Currently, i'm busy with a paper deadline, so I won't have a time to provide a tutorial, but I'm planning to write a tutorial for Compound types later on.

Ohan

May 17, 2010 at 6:32 AM

Thanks for your immediate reply! I'm quite interested in it and looking forward to the tutorial.

There's still a problem: I designed a model in 3ds Max 8 SP2 and applied a material to it,  then I exported the model to a .fbx file (choosing "Embed textures in export file") and loaded in my program using Content Manager. If I don't set the IModel's Material, then the model will just appear dark black. I also tried the property UseInternalMaterials and failed. How can I correctly render the model in my game?

Thank you!

Coordinator
May 17, 2010 at 2:09 PM
It is possible that the texture material is for some reason, set to very dark color. Set UseInternalMaterials to true, and also set its GeometryNode.Material.Diffuse to Vector4(1, 1, 1, 1). Ohan
May 17, 2010 at 2:46 PM

I tried several materials and find that only some material will be rendered correctly in GoblinXNA, for the materials that can be rendered correctly, set  its GeometryNode.Material.Diffuse to Vector4(1, 1, 1, 1) will disable the original material and the object appear pure white. For the materials that cannot be renderly correctly, the object will appear just black if I don't set UseInternalMaterials to true, and appears pure white if I set UseInternalMaterials to true.

Maybe GoblinXNA only support a limited set of materials?

Coordinator
May 17, 2010 at 9:28 PM
Hmm... that is very weird. I've been loading many models with textures, but haven't had problem in v3.4 yet. Instead of .fbx, why don't you try .x models? What I usually do is create (or download using it's 3D warehouse) a textured model in GoogleSketchup and export the model to .x format using the plugin downloadable here (http://www.3drad.com/Google-SketchUp-To-DirectX-XNA-Exporter-Plug-in.htm) . You can do this with the free version of GoogleSketchup, and it's very handy. Ohan
May 18, 2010 at 11:50 AM

Thanks for your suggestion! I tried .x model and more materials can be rendered correctly, however, still some (maybe advanced, such as Ink's Paint) cannot be displayed correctly.

GoogleStetchup is a really cool tool and yeah, I think I will use it in some of my future works.

Thanks again!

Coordinator
May 18, 2010 at 2:52 PM
We currently only support basic rendering using SimpleEffectShader, so if you need more advanced rendering to support, for example bump mapping, then you can easily extend the framework by extending Material.cs and implementing an IShader interface and use those for your model. We actually have internal project that has advanced material and shader support, but it's still in experimental phase, so it's not included in the release version. Ohan