notgiven688 / jitterphysics

A cross-platform, realtime physics engine for all .NET apps.
MIT License
386 stars 87 forks source link

Can't draw Compound Body #31

Closed matbord closed 3 years ago

matbord commented 5 years ago

Hi, I'm following the wiki and when I create and add the body to the world I can't find the method to draw it. I wrote this method (that already contains the call to draw Box)

     protected override void OnBeginRender(double elapsedTime)
    {
     foreach (RigidBody body in world.RigidBodies)//for every rigid body in the world
        {
            if (body.Shape is BoxShape)
            {
                BoxShape shape = body.Shape as BoxShape;

                dsDrawBox(body.Position, body.Orientation, shape.Size);
            }
           else if(body.Shape is CompoundShape)
            {
                CompoundShape shape = body.Shape as CompoundShape;
               //What is the method to call here? In the library there isn't dsDrawCompoundShape(...)
            }
        }
     world.Step(1.0f / 100.0f, true);
    }

Thakyou for the help.

notgiven688 commented 3 years ago

You have to implement your own drawing code for CompoundShapes. This includes looping over all the shapes the compound shape is made of and draw them one by one at the correct position and orientation.