public void setPosition(SLAct act, float x, float y, float z) { lock (this.scene) { act.setPosition(x, y, z); } }
public void movePosition(SLAct act, float x, float y, float z) { lock (this.scene) { act.move(x, y, z); } }
/// <summary> /// カプセルを作成してワールドに追加する /// </summary> /// <param name="pos"></param> /// <param name="height"></param> /// <param name="radius"></param> /// <param name="density"></param> /// <returns></returns> public SLAct addCapsule(float x, float y, float z, float height, float radius, float density, bool fix) { SLAct act = SLAct.createCapsule(x, y, z, height, radius, density, fix); addRigidBody(act); return(act); }
public SLAct addSphere(float x, float y, float z, float radius, float density, bool fix) { SLAct act = SLAct.createSphere(x, y, z, radius, density, fix); addRigidBody(act); return(act); }
public static SLAct createBox(float x, float y, float z, float density, bool fix) { Vector3 pos = new Vector3(x, y, z); ActorDescription actorDesc = new ActorDescription(); BodyDescription bodyDesc = new BodyDescription(); actorDesc.SetToDefault(); bodyDesc.SetToDefault(); BoxShapeDescription capsuleDesc = new BoxShapeDescription() { LocalPose = Matrix.Translation(new Vector3(0, 0, 0)), //Name = mName // LocalRotation = Matrix.CreateRotationZ(45) }; actorDesc.Shapes.Add(capsuleDesc); if (density > 0) { actorDesc.BodyDescription = bodyDesc; actorDesc.Density = density; } actorDesc.GlobalPose = Matrix.Translation(pos); SLAct act = new SLAct(actorDesc); act.no_gravity = fix; return(act); }
public SLJoint addJoint( SLAct actorA, SLAct actorB, float anchor_x, float anchor_y, float anchor_z, float axis_x, float axis_y, float axis_z) { SLJoint joint = new SLJoint(actorA, actorA, anchor_x, anchor_y, anchor_z, axis_x, axis_y, axis_z); setJoint(joint); return(joint); }
public void addRigidBody(SLAct act) { lock (this.scene) { Actor actor; if (act.mass > 0) { act.actorDesc.Density = 0; act.actorDesc.BodyDescription.Mass = act.mass; } else { act.actorDesc.Density = 0; act.actorDesc.BodyDescription.Mass = 0.001f; } #if false act.actorDesc.BodyDescription.LinearDamping = act.m_damping; act.actorDesc.BodyDescription.AngularDamping = act.m_damping; act.actorDesc.BodyDescription.MassSpaceInertia = act.m_inertia; #endif actor = scene.CreateActor(act.actorDesc); //actor.MassSpaceInertiaTensor = if (act.no_gravity) { // 重力を無効にする場合 actor.RaiseBodyFlag(BodyFlag.DisableGravity); // 回転を無効にする場合 actor.RaiseBodyFlag(BodyFlag.FrozenRotation); // 移動を無効にする場合 actor.RaiseBodyFlag(BodyFlag.FrozenPosition); } if (act.kinematic_mode) { // 重力を無効にする場合 actor.RaiseBodyFlag(BodyFlag.DisableGravity); // 回転を無効にする場合 actor.RaiseBodyFlag(BodyFlag.FrozenRotation); // 移動を無効にする場合 actor.RaiseBodyFlag(BodyFlag.FrozenPosition); actor.RaiseBodyFlag(BodyFlag.Kinematic); } act.setActor(actor); act_list.Add(act); } }
/// <summary> /// 物理シミュレーションを更新する /// </summary> public int stepSimulation(float TotalSeconds) { lock (this.scene) { // モデルの動きを物理に反映する for (int i = 0; i < act_list.Count; i++) { SLAct act = act_list[i]; act.updateToPhisics(TotalSeconds); } // Update Physics this.scene.Simulate(TotalSeconds); //_scene.Simulate( 1.0f / 60.0f ); this.scene.FlushStream(); this.scene.FetchResults(SimulationStatus.RigidBodyFinished, true); // 物理結果をモデルに反映する for (int i = 0; i < act_list.Count; i++) { SLAct act = act_list[i]; act.updateToModel(TotalSeconds); } #if false int i = 0; foreach (Actor actor in this.scene.Actors) { // 各アクターの位置・回転情報 Matrix m = actor.GlobalPose; // これで位置がとれるので、ここからMotionStateを呼び出せばいい Vector3 v = GetPosition(m); //Console.WriteLine("pos " + i + ":" + v.X + "," + v.Y + "," + v.Z); i++; } #endif } return(0); }
public SLJoint( SLAct actorA, SLAct actorB, float anchor_x, float anchor_y, float anchor_z, float axis_x, float axis_y, float axis_z) { Vector3 anchor = new Vector3(anchor_x, anchor_y, anchor_z); Vector3 axis = new Vector3(axis_x, axis_y, axis_z); act_anc = anchor; d6JointDesc = new StillDesign.PhysX.D6JointDescription(); d6JointDesc.SetToDefault(); d6JointDesc.Actor1 = actorA != null ? actorA.actor : null; d6JointDesc.Actor2 = actorB != null ? actorB.actor : null; d6JointDesc.DriveLinearVelocity = new Vector3(0, 0, 0); // グローバル座標でのアンカーの場所 d6JointDesc.SetGlobalAnchor(anchor); // グローバル座標での回転軸 d6JointDesc.SetGlobalAxis(axis); // 回転方向の制約 d6JointDesc.TwistMotion = StillDesign.PhysX.D6JointMotion.Locked; d6JointDesc.Swing1Motion = StillDesign.PhysX.D6JointMotion.Locked; d6JointDesc.Swing2Motion = StillDesign.PhysX.D6JointMotion.Locked; // 移動方向の制約 d6JointDesc.XMotion = StillDesign.PhysX.D6JointMotion.Locked; d6JointDesc.YMotion = StillDesign.PhysX.D6JointMotion.Locked; d6JointDesc.ZMotion = StillDesign.PhysX.D6JointMotion.Locked; d6JointDesc.ProjectionMode = StillDesign.PhysX.JointProjectionMode.None; act1 = actorA; act2 = actorB; }
public CapsuleShape(float width, float height, float x, float y, float z) { act = SLAct.createCapsule(x, y, z, height, width, 10, false); }
public CapsuleShape(float width, float height) { act = SLAct.createCapsule(0, 0, 0, height, width, 10, false); Margin = width; }
public BoxShape(btVector3 vector) { act = SLAct.createBox(vector.X, vector.Y, vector.Z, 10, false); Margin = vector.X; }
public SphereShape(float width, float x, float y, float z) { act = SLAct.createSphere(x, y, z, width, 10, false); }
public SphereShape(float width) { act = SLAct.createSphere(0, 0, 0, width, 10, false); Margin = width; }