How do I add textures to my Actors/ShapeDesc PhysX.net

163 views Asked by At

How do I add textures to my Actors/ShapeDesc in PhysX.net?

I'm using XNA and PhysX.NET.

I have scenes and everything set up and everything is working, but my Game Engine won't look good in Wireframe mode, you know what I mean.

Thank you again!

// Add some boxes to the scene
for (int x = 0; x < 20; x++)
{
    for (int y = 0; y < 20; y++)
    {
        BoxShapeDescription boxShapeDesc = new BoxShapeDescription(2, 8, 3);

        ActorDescription actorDesc = new ActorDescription()
        {
            Name = String.Format("Box {0}", x),
            BodyDescription = new BodyDescription(10.0f),
            GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(y*2, 20 + 8 * x, 0),
            Shapes = { boxShapeDesc }

        };

        Actor actor = this.Scene.CreateActor(actorDesc);
    }
}

Draw() method:

// TODO: Add your drawing code here
DebugRenderable data = this.Scene.GetDebugRenderable();
foreach (EffectPass ep in visEff.CurrentTechnique.Passes)
{
    ep.Apply(); //Veeery simple now!
    if (data.LineCount > 0)
    {
        DebugLine[] lines = data.GetDebugLines();

        VertexPositionColor[] vertices = new VertexPositionColor[data.LineCount * 2];
        for (int x = 0; x < data.LineCount; x++)
        {
            DebugLine line = lines[x];

            vertices[x * 2 + 0] = new VertexPositionColor(new Vector3(line.Point0.X, line.Point0.Y, line.Point0.Z), Int32ToColor(line.Color));
            vertices[x * 2 + 1] = new VertexPositionColor(new Vector3(line.Point1.X, line.Point1.Y, line.Point1.Z), Int32ToColor(line.Color));
        }

        GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, lines.Length);
    }

    if (data.TriangleCount > 0)
    {
        DebugTriangle[] triangles = data.GetDebugTriangles();

        VertexPositionColor[] vertices = new VertexPositionColor[data.TriangleCount * 3];
        for (int x = 0; x < data.TriangleCount; x++)
        {
            DebugTriangle triangle = triangles[x];                 

            vertices[x * 3 + 0] = new VertexPositionColor(new Vector3(triangle.Point0.X, triangle.Point0.Y, triangle.Point0.Z), Int32ToColor(triangle.Color));
            vertices[x * 3 + 1] = new VertexPositionColor(new Vector3(triangle.Point1.X, triangle.Point1.Y, triangle.Point1.Z), Int32ToColor(triangle.Color));
            vertices[x * 3 + 2] = new VertexPositionColor(new Vector3(triangle.Point2.X, triangle.Point2.Y, triangle.Point2.Z), Int32ToColor(triangle.Color));
        }

        GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, vertices, 0, triangles.Length);
    }
}

And.. Int32ToColor():

public static Color Int32ToColor( int color )
{
    byte a = (byte)( ( color & 0xFF000000 ) >> 32 );
    byte r = (byte)( ( color & 0x00FF0000 ) >> 16 );
    byte g = (byte)( ( color & 0x0000FF00 ) >> 8 );
    byte b = (byte)( ( color & 0x000000FF ) >> 0 );

    return new Color( r, g, b, a );
}
0

There are 0 answers