Exemple #1
0
    static void renderGeometry(ref PxGeometry geom)
    {
        switch (geom.getType())
        {
        case PxGeometryType.eBOX:
        {
            ref PxBoxGeometry boxGeom = ref Unsafe.As <PxGeometry, PxBoxGeometry>(ref geom);
            float             hx      = boxGeom.halfExtents.x;
            float             hy      = boxGeom.halfExtents.y;
            float             hz      = boxGeom.halfExtents.z;

            // +x
            GL.Begin(PrimitiveType.Quads);
            GL.Normal3(1f, 0f, 0f);
            GL.Vertex3(+hx, +hy, +hz);
            GL.Vertex3(+hx, -hy, +hz);
            GL.Vertex3(+hx, -hy, -hz);
            GL.Vertex3(+hx, +hy, -hz);
            GL.End();

            // -x
            GL.Begin(PrimitiveType.Quads);
            GL.Normal3(-1f, 0f, 0f);
            GL.Vertex3(-hx, +hy, +hz);
            GL.Vertex3(-hx, +hy, -hz);
            GL.Vertex3(-hx, -hy, -hz);
            GL.Vertex3(-hx, -hy, +hz);
            GL.End();

            // +y
            GL.Begin(PrimitiveType.Quads);
            GL.Normal3(0f, 1f, 0f);
            GL.Vertex3(+hx, +hy, +hz);
            GL.Vertex3(-hx, +hy, +hz);
            GL.Vertex3(-hx, +hy, -hz);
            GL.Vertex3(+hx, +hy, -hz);
            GL.End();

            // -y
            GL.Begin(PrimitiveType.Quads);
            GL.Normal3(0f, -1f, 0f);
            GL.Vertex3(+hx, -hy, +hz);
            GL.Vertex3(+hx, -hy, -hz);
            GL.Vertex3(-hx, -hy, -hz);
            GL.Vertex3(-hx, -hy, +hz);
            GL.End();

            // +z
            GL.Begin(PrimitiveType.Quads);
            GL.Normal3(0f, 0f, 1f);
            GL.Vertex3(+hx, +hy, +hz);
            GL.Vertex3(-hx, +hy, +hz);
            GL.Vertex3(-hx, -hy, +hz);
            GL.Vertex3(+hx, -hy, +hz);
            GL.End();

            // -z
            GL.Begin(PrimitiveType.Quads);
            GL.Normal3(0f, 0f, -1f);
            GL.Vertex3(+hx, +hy, -hz);
            GL.Vertex3(+hx, -hy, -hz);
            GL.Vertex3(-hx, -hy, -hz);
            GL.Vertex3(-hx, +hy, -hz);
            GL.End();
        }
        break;