Пример #1
0
    // Not applicable for Mochi-flavored snippets
    // class MyTriggerRender : public Snippets::TriggerRender
    // {
    //     public:
    //     virtual bool isTrigger(physx::PxShape* shape) const
    //     {
    //         return ::isTriggerShape(shape);
    //     }
    // };

    static void renderCallback()
    {
        stepPhysics(true);

#if false
        {
            PxVec3 camPos = sCamera.getEye();
            PxVec3 camDir = sCamera.getDir();
            Console.WriteLine($"camPos: ({camPos.x}, {camPos.y}, {camPos.z})");
            Console.WriteLine($"camDir: ({camDir.x}, {camDir.y}, {camDir.z})");
        }
#endif

        SnippetRender.startRender(sCamera.getEye(), sCamera.getDir());
        InitLighting();

        PxScene *scene;
        PxGetPhysics()->getScenes(&scene, 1);
        uint nbActors = scene->getNbActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC);
        if (nbActors != 0)
        {
            // (Allocating on the heap here is not a good idea performance-wise, we only do it this way to keep close to the original snippet.)
            fixed(PxRigidActor **actors = new PxRigidActor *[nbActors])
            {
                scene->getActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC, actors, nbActors);

                SnippetRender.renderActors(actors, nbActors, true, new(0.0f, 0.75f, 0.0f), &isTriggerShape);
            }
        }

        SnippetRender.finishRender();
    }
    // Not applicable for Mochi-flavored snippet
    //static void idleCallback()
    //{
    //    glutPostRedisplay();
    //}

    static void renderCallback()
    {
        stepPhysics(true);

        // glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

        SnippetRender.startRender(sCamera.getEye(), sCamera.getDir());

        PxScene *scene;

        PxGetPhysics()->getScenes(&scene, 1);
        uint nbActors = scene->getNbActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC);

        if (nbActors != 0)
        {
            // (Allocating on the heap here is not a good idea performance-wise, we only do it this way to keep close to the original snippet.)
            fixed(PxRigidActor **actors = new PxRigidActor *[nbActors])
            {
                scene->getActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC, actors, nbActors);
                SnippetRender.renderActors(&actors[0], nbActors, true);
            }
        }

        SnippetRender.finishRender();
    }
Пример #3
0
    public static void renderLoop()
    {
        sCamera = new Snippets.Camera(new(50.0f, 50.0f, 50.0f), new(-0.6f, -0.2f, -0.7f));

        SnippetRender.setupDefaultWindow("PhysX Snippet Serialization");
        SnippetRender.setupDefaultRenderState();

        //glutIdleFunc(idleCallback);
        glutDisplayFunc(&renderCallback);
        glutKeyboardFunc(&keyboardCallback);
        glutMouseFunc(&mouseCallback);
        glutMotionFunc(&motionCallback);
        motionCallback(0, 0);

        glutMainLoop();
        exitCallback();
    }
Пример #4
0
    public static void renderLoop()
    {
        sCamera = new Snippets.Camera(new(10.0f * gLengthScale, 10.0f * gLengthScale, 10.0f * gLengthScale), new(-0.6f, -0.2f, -0.7f));

        SnippetRender.setupDefaultWindow("PhysX Snippet VehicleScale");
        SnippetRender.setupDefaultRenderState();

        //glutIdleFunc(idleCallback);
        glutDisplayFunc(&renderCallback);
        glutKeyboardFunc(&keyboardCallback);
        glutMouseFunc(&mouseCallback);
        glutMotionFunc(&motionCallback);
        motionCallback(0, 0);

        initPhysics();
        glutMainLoop();
        exitCallback();
    }
    // Not applicable for Mochi-flavored snippet
    //static void idleCallback()
    //{
    //    glutPostRedisplay();
    //}

    static void renderCallback()
    {
        stepPhysics();

        SnippetRender.startRender(sCamera.getEye(), sCamera.getDir());

        uint nbActors = gScene->getNbActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC);

        if (nbActors != 0)
        {
            // (Allocating on the heap here is not a good idea performance-wise, we only do it this way to keep close to the original snippet.)
            fixed(PxRigidActor **actors = new PxRigidActor *[nbActors])
            {
                gScene->getActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC, actors, nbActors);
                SnippetRender.renderActors(actors, nbActors, true);
            }
        }

        SnippetRender.finishRender();
    }
Пример #6
0
    public static void renderLoop()
    {
        Debug.Assert(sCamera is null);
        sCamera = new Snippets.Camera(new(8.757190f, 12.367847f, 23.541956f), new(-0.407947f, -0.042438f, -0.912019f));

        SnippetRender.setupDefaultWindow("PhysX Snippet Triggers");
        SnippetRender.setupDefaultRenderState();

        //glutIdleFunc(&idleCallback);
        glutDisplayFunc(&renderCallback);
        glutKeyboardFunc(&keyboardCallback);
        glutSpecialFunc(&keyboardCallback2);
        glutMouseFunc(&mouseCallback);
        glutMotionFunc(&motionCallback);
        motionCallback(0, 0);

        initPhysics(true);
        glutMainLoop();
        exitCallback();
    }
Пример #7
0
    // Not applicable for Mochi-flavored snippet
    //static void idleCallback()
    //{
    //    glutPostRedisplay();
    //}

    static void renderCallback()
    {
        stepPhysics(true);

        SnippetRender.startRender(sCamera.getEye(), sCamera.getDir());

        PxScene *scene;

        PxGetPhysics()->getScenes(&scene, 1);
        uint nbActors = scene->getNbActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC);

        if (nbActors != 0)
        {
            // (Allocating on the heap here is not a good idea performance-wise, we only do it this way to keep close to the original snippet.)
            fixed(PxRigidActor **actors = new PxRigidActor *[nbActors])
            {
                scene->getActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC, (PxActor **)actors, nbActors);
                SnippetRender.renderActors(actors, nbActors, true);
            }
        }

        uint nbArticulations = scene->getNbArticulations();

        for (uint i = 0; i < nbArticulations; i++)
        {
            PxArticulationBase *articulation;
            scene->getArticulations(&articulation, 1, i);

            uint nbLinks = articulation->getNbLinks();
            // (Allocating on the heap here is not a good idea performance-wise, we only do it this way to keep close to the original snippet.)
            fixed(PxArticulationLink **links = new PxArticulationLink *[nbLinks])
            {
                articulation->getLinks(links, nbLinks);

                SnippetRender.renderActors(links, nbLinks, true);
            }
        }

        SnippetRender.finishRender();
    }
    // Not applicable for Mochi-flavored snippet
    //static void idleCallback()
    //{
    //    glutPostRedisplay();
    //}

    static void renderCallback()
    {
        stepPhysics(true);


        SnippetRender.startRender(sCamera.getEye(), sCamera.getDir());

        PxScene *scene;

        PxGetPhysics()->getScenes(&scene, 1);
        uint nbActors = scene->getNbActors(PxActorTypeFlags.eRIGID_DYNAMIC);

        if (nbActors != 0)
        {
            Vector3 dynColor       = new(1.0f, 0f, 1f);
            Vector3 kinematicColor = new(0f, 1f, 0f);
            // (Allocating on the heap here is not a good idea performance-wise, we only do it this way to keep close to the original snippet.)
            fixed(PxRigidActor **actors = new PxRigidActor *[nbActors])
            {
                scene->getActors(PxActorTypeFlags.eRIGID_DYNAMIC, actors, nbActors);
                for (uint i = 0; i < nbActors; ++i)
                {
                    PxRigidActor *  actor = actors[i];
                    PxRigidDynamic *dyn; // = actor->is<PxRigidDynamic>(); //BIOQUIRK: No support for is<T>
                    dyn = actor->getConcreteType() == (ushort)PxConcreteType.eRIGID_DYNAMIC ? static_cast <PxRigidDynamic>(actor) : null;
                    if ((dyn->getRigidBodyFlags() & PxRigidBodyFlags.eKINEMATIC) != 0)
                    {
                        SnippetRender.renderActors(&actor, 1, true, kinematicColor);
                    }
                    else
                    {
                        SnippetRender.renderActors(&actor, 1, true, dynColor);
                    }
                }
            }
        }
        SnippetRender.finishRender();
    }