Пример #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();
    }
    // 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();
    }
Пример #4
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();
    }