// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- // MonoBehaviourのメソッド void Start() { app = new FWHapticApp(); app.CreateSdk(); app.GetSdk().CreateScene(); app.SetPHScene(phSceneBehaviour.phScene); app.CreateTimers(); // phSceneBehaviour.enableStep = false; // phSceneBehaviour.phScene.GetHapticEngine().Enable(true); phSceneBehaviour.phScene.GetHapticEngine().SetHapticStepMode(PHHapticEngineDesc.HapticStepMode.LOCAL_DYNAMICS); // pointer = phSceneBehaviour.phScene.CreateHapticPointer(); var shapeDesc = new CDSphereDesc(); shapeDesc.radius = 0.1f; var shape = phSceneBehaviour.phScene.GetSdk().CreateShape(CDSphereIf.GetIfInfoStatic(), shapeDesc); pointer.AddShape(shape); pointer.SetHapticRenderMode(PHHapticPointerDesc.HapticRenderMode.CONSTRAINT); pointer.SetLocalRange(20.0f); pointer.SetPosScale(100); pointer.EnableForce(true); var fwPointer = app.GetSdk().GetScene(0).CreateHapticPointer(); fwPointer.SetHumanInterface(hiSpidarGBehaviour.hiSpidar); fwPointer.SetPHHapticPointer(pointer); // pointerObj = GameObject.CreatePrimitive(PrimitiveType.Sphere); // pointerObj.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); // app.GetTimer(0).SetInterval(10); app.GetTimer(1).SetResolution(1); app.GetTimer(1).SetInterval(1); app.StartTimers(); }
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]); } }