Exemple #1
0
        static void test_tostring()
        {
            test_name("ToString");

            Vec3d v3d = new Vec3d(0.1, 0.2, 0.3);

            //string s = v3d.ToString();
/**/ put("ToString", "(0.1, 0.2, 0.3)", v3d.ToString());
/**/ System.Console.WriteLine("ToString: implicit ToString call           : " + v3d);

            PHSceneDesc descScene = new PHSceneDesc();
            PHSolidDesc descSolid = new PHSolidDesc();
            PHSdkIf     phSdk     = PHSdkIf.CreateSdk();
            PHSceneIf   phScene   = phSdk.CreateScene(descScene);
            PHSolidIf   phSolid   = phScene.CreateSolid(descSolid);

            phSolid.SetPose(new Posed(1, 0, 0, 0, 0, 2, 0));
            put_title("ToString: phSolid");
            put_indent(2, phSolid.ToString());

            FWWinBaseDesc descWinBase = new FWWinBaseDesc();
            FWSdkIf       fwSdk       = FWSdkIf.CreateSdk();

            put_title("ToString: fwSdk.ToString");
            put_indent(2, fwSdk.ToString());
        }
Exemple #2
0
    // -- Sprオブジェクトの構築を行う
    public override ObjectIf Build()
    {
        SEH_Exception.init();

        PHSceneIf phScene;

        if (enableDebugWindow)
        {
            fwApp = new FWApp();
            fwApp.InitInNewThread();

            // FWAppの初期化が終わるまで待つ
            while (fwApp.GetSdk() == null || fwApp.GetSdk().GetPHSdk() == null)
            {
                System.Threading.Thread.Sleep(10);
            }

            phSdk   = fwApp.GetSdk().GetPHSdk();
            phScene = fwApp.GetSdk().GetScene(0).GetPHScene();
            phScene.Clear();
            phScene.SetDesc((PHSceneDesc)desc);

            FWSceneIf fwSceneIf = fwApp.GetSdk().GetScene(0);
            fwSceneIf.EnableRenderContact(true);
            fwSceneIf.EnableRenderForce(false, true);
            //fwSceneIf.SetForceScale(0.01f, 0.01f);
        }
        else
        {
            phSdk   = PHSdkIf.CreateSdk();
            phScene = phSdk.CreateScene((PHSceneDesc)desc);
        }

        return(phScene);
    }
        static void test_simulation()
        {
            test_name("physical simulation");

            PHSceneDesc descScene = new PHSceneDesc();
            PHSolidDesc descSolid = new PHSolidDesc();
            CDBoxDesc   descBox   = new CDBoxDesc();
            PHSdkIf     phSdk     = PHSdkIf.CreateSdk();
            PHSceneIf   phScene   = phSdk.CreateScene(descScene);
            PHSolidIf   phSolid   = phScene.CreateSolid(descSolid);

            phSolid.AddShape(phSdk.CreateShape(CDBoxIf.GetIfInfoStatic(), descBox));
            phSolid.SetPose(new Posed(1, 0, 0, 0, 0, 2, 0));

            PHSolidIf phFloor = phScene.CreateSolid(descSolid);

            phFloor.SetDynamical(false);
            descBox.boxsize = new Vec3f(10, 10, 10);
            phFloor.AddShape(phSdk.CreateShape(CDBoxIf.GetIfInfoStatic(), descBox));
            phFloor.SetPose(new Posed(1, 0, 0, 0, 0, -5, 0));

            PHBallJointDesc descJoint = new PHBallJointDesc();
            PHBallJointIf   j         = phScene.CreateJoint(phFloor, phSolid, PHBallJointIf.GetIfInfoStatic(), descJoint).Cast();

            System.Console.WriteLine(j.GetName());

            PHIKBallActuatorDescStruct s = new PHIKBallActuatorDesc();

            put("bias", "something", s.bias);

            /**/
            for (int i = 0; i < 200; i++)
            {
                phScene.Step();
                //System.Console.WriteLine(i.ToString() + " : " + phSolid.GetPose());
                System.Console.WriteLine(String.Format("{0, 3}", i) + " : " + phSolid.GetPose());
            }
            /**/
        }
Exemple #4
0
    // -- Sprオブジェクトの構築を行う
    public override ObjectIf Build()
    {
        SEH_Exception.init();

        FWAppBehaviour appB = GetComponent <FWAppBehaviour>();

        PHSceneIf phScene;

        if (appB != null)
        {
            FWApp app = FWAppBehaviour.app;
            phSdk   = app.GetSdk().GetPHSdk();
            phScene = app.GetSdk().GetScene(0).GetPHScene();
            phScene.Clear();
            phScene.SetDesc((PHSceneDesc)desc);
        }
        else
        {
            phSdk   = PHSdkIf.CreateSdk();
            phScene = phSdk.CreateScene((PHSceneDesc)desc);
        }

        return(phScene);
    }
Exemple #5
0
        static void test_func_return()
        {
            test_name("function return");
            int memoryLeakTest = 0;

            PHSceneDesc descScene = new PHSceneDesc();
            PHSolidDesc descSolid = new PHSolidDesc();

            if (memoryLeakTest == 1)
            {
                return;
            }

            PHSdkIf phSdk = PHSdkIf.CreateSdk();        // ここでメモリリークする

            if (memoryLeakTest == 2)
            {
                return;
            }
            PHSceneIf phScene = phSdk.CreateScene(descScene);

            descSolid.mass    = 2.0;
            descSolid.inertia = new Matrix3d(2.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 2.0);
            PHSolidIf phSolid = phScene.CreateSolid(descSolid);

            descSolid.mass = 1e20f;

            descSolid.inertia = new Matrix3d(1e20f, 0.0, 0.0, 0.0, 1e20f, 0.0, 0.0, 0.0, 1e20f);
            PHSolidIf solid1 = phScene.CreateSolid(descSolid);

            PHHapticPointerDesc descHaptic = new PHHapticPointerDesc();
            PHHapticPointerIf   phHaptic   = phScene.CreateHapticPointer();

            //HISdkDesc descHi = new HISdkDesc();
            //HISdkIf hiSdk = HISdkIf.CreateSdk();

            put("ret int   ", "3    ", phScene.NSolids());
            for (int i = 0; i < 20; i++)
            {
                phScene.Step();
            }
            put("ret Uint  ", "20   ", phScene.GetCount());
            phHaptic.SetLocalRange(2.345f);
            put("ret float ", "2.345", phHaptic.GetLocalRange());
            put("ret double", "0.005", phScene.GetTimeStep());
            phScene.SetMaxVelocity(1.23);
            put("ret double", "0.123", phScene.GetMaxVelocity());
            phScene.EnableContactDetection(false);
            put("ret bool  ", "False", phScene.IsContactDetectionEnabled());
            phScene.EnableContactDetection(true);
            put("ret bool  ", "True ", phScene.IsContactDetectionEnabled());
            put("ret size_t", "152? ", phScene.GetDescSize());
            put("ret Vec3d ", "(0.0, -9.8, 0.0)", phScene.GetGravity());
            phScene.SetGravity(new Vec3d(0.1, -9.9, 0.2));
            put("ret Vec3d ", "(0.1, -9.9, 0.2)", phScene.GetGravity());

            // function returns array by using pointer
            CDConvexMeshDesc descMesh = new CDConvexMeshDesc();

            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y < 10; y++)
                {
                    for (int z = 0; z < 10; z++)
                    {
                        Vec3f v3f = new Vec3f(x, y, z);
                        descMesh.vertices.push_back(new Vec3f(x, y, z));
                    }
                }
            }
            //PHSdkIf phSdk = PHSdkIf.CreateSdk();
            CDConvexMeshIf mesh = phSdk.CreateShape(CDConvexMeshIf.GetIfInfoStatic(), descMesh) as CDConvexMeshIf;

            mesh.GetVertices();
            arraywrapper_Vec3f vertices = mesh.GetVertices();

            Vec3f[] v3fr = new Vec3f[8];
            v3fr[0] = new Vec3f(0, 0, 0); v3fr[1] = new Vec3f(0, 0, 9);
            v3fr[2] = new Vec3f(0, 9, 0); v3fr[3] = new Vec3f(0, 9, 9);
            v3fr[4] = new Vec3f(9, 0, 0); v3fr[5] = new Vec3f(9, 0, 9);
            v3fr[6] = new Vec3f(9, 9, 0); v3fr[7] = new Vec3f(9, 9, 9);
            for (int i = 0; i < 8; i++)
            {
                put("ret_array", edit_vector(v3fr[i]), vertices[i]);
            }
        }