• Home
  • Products
    • Game Engine
      • Base
      • Mathematics
      • Geometry
      • Physics
      • Particles
      • Animation
      • Graphics
      • Game
      • Game UI
    • Windows Forms
      • Docking Windows
      • Text Editor Control
  • Downloads
  • Buy
    • Overview
    • Professional
    • Indie
    • Non-Commercial
  • Support
    • Overview
    • Blog
    • Forum
    • License FAQ
    • Documentation
  • About
    • About Us
      • Services
    • Contact Us
    • Press
    • Legal Terms
      • Imprint (English)
      • Imprint (German)
Select the search type
 
  • Site
  • Web
Search
DigitalRune.com
Login |Register
NEWS News RSS Feed BLOG Blog RSS Feed FORUM News RSS Feed DOCUMENTATION DigitalRune Software on YouTube DigitalRune Software on Twitter
You are here: SupportForum

If you want to contribute to the forum discussions, please Register or Login.

SearchHome
  • 1
  • 2
  • 3
  • 4
  • 5
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EngineArbitrary Triangle Mesh Character CollisionArbitrary Triangle Mesh Character Collision
Previous
 
Next
New Post
1/2/2011 2:57 AM
 
winterkewl
No Ranking

Joined: 12/8/2010
Posts: 32
Arbitrary Triangle Mesh Character Collision 
Hi Helmut,
I'm just about ready to pull the trigger on purchasing the license for this awesome Indie Physics bundle you've got here. . . however, there's one seemingly crucial bit of tech that I can't seem to figure out that I'm hoping you can help me with.

I understand that in an ideal world you wouldn't ever want to use say a terrain mesh (as modeled in maya etc) as your primary source of collisions in the world. Ideally, you'd use a heightmap of some kind. Unfortunately, I'm not able to do so. The reason is, I'm using SunBurn to do the lighting / rendering of all my objects, as such it uses a somehow different method of generating the terrain it will ultimately render.

Long Story short, what I would really like is the ability to create a collision object in Maya etc that is a rough approximation of the area I want the character to be able to walk, jump etc. Is it at all possible to use an arbitrary mesh as a collision object?

I'm currently modeling collision objects like ramps, cubes , etc in maya but what I'd really like to do is say model a plane just like a height map and use that as the ground collision object, is this possible? The ConvexPolyhedron won't work for arbitrary meshes that can have peaks and valleys etc. Other Physics engines provide methods to generate this kind've collision so I'm hoping I've just overlooked this functionality in the digitalRune Library.

Thanks again!
 
New Post
1/3/2011 8:49 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Arbitrary Triangle Mesh Character Collision 

TriangleMesh - no problem.

Rigid bodies with a TriangleMeshShape are used in the PhysicsSample in Sample10 (for the dumbbell shape) and in Sample12 (for the terrain).
Attached to this post is a new example that shows how to load a mesh from an XNA model and shows a few other tricks.
(Please add the .cs file in the attached zip manually to the PhysicsSample project.The zip contains a very simple model of a bowl which you must add to the content project. Set the scale to 0.01.)

A few more notes:
To give a RigidBody a shape defined by a mesh, you need to use the TriangleMeshShape.
The TriangleMeshShape needs an ITriangleMesh. You can either write your own ITriangleMesh implementation. Or use the standard implementation: class TriangleMesh.
Meshes are treated as one-sided - that means rigid bodies can pass through the backside of the triangles and only the frontside is "solid". - So the winding order of the triangles matters! Our libraries use counter-clockwise ordering for triangle front side.
With the TriangleMesh.FromModel() method you can load the mesh from a XNA Model.  (This method automatically flips the winding order since XNA games usually use clockwise ordering for frontsides.) You can use this method to extract the triangle mesh from a XNA Model - but usually you will want to create the collision mesh in the content pipeline and not from a Model at run-time.

I hope this info gets you started. Let us know if you need more details.

 
 TriangleMeshSample.zip
New Post
1/3/2011 3:17 PM
 
winterkewl
No Ranking

Joined: 12/8/2010
Posts: 32
Re: Arbitrary Triangle Mesh Character Collision 
Thanks Helmut,

I'll go over your example tonight when I get home from work, and let you know if I run into any problems, but this sounds like exactly what I needed!

Thanks!

 
New Post
1/7/2011 4:06 AM
 
winterkewl
No Ranking

Joined: 12/8/2010
Posts: 32
Re: Arbitrary Triangle Mesh Character Collision 
Hi Helmut!

Sorry it's taken so long to report back, I've tested your sample and it works just like you described!

Unfortunately, as you said there is a problem with the method in that since the mesh is thin , it's quite easy to get the collisions to fail and  the character will fall right through the mesh if i push on a 90degree corner for example. . . I tired doing the double sided trick but that didn't seem to help.

I'm curious, would enabling CCD for the mesh , the character controller's "capsuleShape" and the simulation rectify this situation? If so, does the full version of the Character Controller have this option?

I tried augmenting the CharacterController class that comes with the Demo but I must have done something incorrect as it doesn't seem to update that capsule and still exhibits the falling through the mesh issue.

FWIW here's what I did to add the Capsule's RigidBody to the simulation and enable CCD.

            CapsuleShape characterShape = new CapsuleShape(Width / 2, Height);
            _body = new RigidBody(characterShape)
            {
                CcdEnabled = true,
            };

            _simulation.RigidBodies.Add(_body);

            GameObject = new GameObject(
                characterShape,
                new Pose(new Vector3F(0, Height / 2, 0)));

            // Create a collision object for the game object and add it to the collision domain.
            GameObject.CollisionObject = new CollisionObject(GameObject);
            _collisionDomain.CollisionObjects.Add(GameObject.CollisionObject);

Please forgive my naivete approach, but is this on the right track to fix this issue do you think?
 
New Post
1/7/2011 9:36 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Arbitrary Triangle Mesh Character Collision 

The CharacterController of the DigitalRune.Geometry samples ("CharacterControllerSample") is a simple educational example and it displays jittering and can tunnel through thin objects.
The CharacterController of DigitalRune.Physics is a lot more stable and several times faster.

Both version were created before CCD was implemented - so they do not make use of CCD. Both are "kinematic character controllers" and not "dynamic character controllers" - which means they work on the collision detection level only and do not know about the RigidBody class. Setting RigidBody.CcdEnabled does not help in this case.

Usually, the DigitalRune.Physics CharacterController can tunnel through thin objects if it moves more than its capsule radius in a single step. In practical cases (< 10 m/s speed and a 60 fps game) I haven't found a case where it tunnels through a mesh.

Making the mesh double-sided could make the problem worse because:
With a one-sided mesh the collision detection can only find contacts with normal vectors that push the character out of the mesh. If the character tunnels through, it can be moved back.
With a two-sided mesh the collision detection can find contacts with normals that push the character through the mesh and prevent it from going back to the allowed side.

Here are a few tips:
- Use the CharacterController of DigitalRune.Physics (licensees can get the source code for free).
- Avoid very thin capsules. A capsule with a larger radius is more stable.
- Avoid unnatural high character speeds. Or try to make several smaller steps instead of one large step (call characterController.Move() 2 times with a smaller distance instead of 1 time with a large distance).

If the problem persists, maybe you can create a small sample in the DigitalRune.Physics PhysicsSample project that demonstrates problem.

 
New Post
1/7/2011 1:55 PM
 
winterkewl
No Ranking

Joined: 12/8/2010
Posts: 32
Re: Arbitrary Triangle Mesh Character Collision 
Ah, this explains a great deal about what I'm doing incorrectly!

My method of moving your characterController involves asking it to move a lot more in a given frame then it really should be. The reason being, The character can orbit around the camera in a pre-defined radius, and the camera can also rotate around the player (like ratchet and clank etc). The way I'm determining the next step forward and back is different then when the user pushes left or right on the thumbstick. When I push forward into a collision wall in the terrain mesh, the characterController does not tunnel through.

When I press left or right is where the issue occurs. For Left and Right I'm using polar coordinate method to derive the new DesiredPosition. Since this is stepping around a circle the new desired position is often times a fairly large step for the little characterController. To compound matters the DesiredPosition is also often inside the mesh or collision object because my method of determining the new DesiredPosition doesn't take into account any potential collisions at all.

To make matters worse I've also got a fairly small capsule since the character is meant to be small in the world.

I'm going to implement your suggestions and I'll post back with the results.

May I just say THANKS for all your patient help and explanations so far, I really appreciate it!
 
New Post
1/7/2011 2:23 PM
 
winterkewl
No Ranking

Joined: 12/8/2010
Posts: 32
Re: Arbitrary Triangle Mesh Character Collision 
Perfect!

Changing the CharacterController class to the one in DigitalRune.Physics.Specialized fixed the tunneling through the mesh problem right away!

I'm sorry I didn't try that sooner! The only other change I made was going from a width of 1 to a width of 1.5.

But yeah, works a charm now, I'm definitely buying this product!

Thanks for all your help, and such a great API! :)
 
 Page 1 of 1
Previous
 
Next
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EngineArbitrary Triangle Mesh Character CollisionArbitrary Triangle Mesh Character Collision


DigitalRune is a trademark of Garstenauer Information Technology OG.

Garstenauer Information Technology OG
Weingartenstrasse 35, 4452 Ternberg
Austria (EUROPE)
office@digitalrune.com

Home Products Downloads Buy Support About Us
Game Engine Particles Windows Forms Professional Blog Services
Base Animation Docking Windows Indie Forum Contact Us
Mathematics Graphics Text Editor Control Non-Commercial License FAQ Press (News)
Geometry Game Documentation Legal Terms
Physics Game UI Imprint
Impressum
Copyright © 2006-2012 Garstenauer Information Technology OG Terms Of UsePrivacy Statement