예제 #1
0
            public override void Update(IConstraintDesc constraintDesc)
            {
                var hingeDesc = (HingeConstraintDesc)constraintDesc;

                ModelEntity.Transform.Rotation = Pivot == Pivot.A ? hingeDesc.AxisInA : hingeDesc.AxisInB;

                var newLowerLimit = hingeDesc.Limit.SetLimit ? -hingeDesc.Limit.LowerLimit : MathF.PI;
                var newUpperLimit = hingeDesc.Limit.SetLimit ? hingeDesc.Limit.UpperLimit : MathF.PI;

                if (newLowerLimit != lastLowerLimit)
                {
                    var limitMesh = GetLimitDisc(GraphicsDevice, newLowerLimit).ToMeshDraw();
                    lowerLimit.Model = new Model {
                        limitMaterial, new Mesh {
                            Draw = limitMesh
                        }
                    };
                    lastLowerLimit = newLowerLimit;
                }

                if (newUpperLimit != lastUpperLimit)
                {
                    var limitMesh = GetLimitDisc(GraphicsDevice, newUpperLimit).ToMeshDraw();
                    upperLimit.Model = new Model {
                        limitMaterial, new Mesh {
                            Draw = limitMesh
                        }
                    };
                    lastUpperLimit = newUpperLimit;
                }
            }
예제 #2
0
            public override void Update(IConstraintDesc constraintDesc)
            {
                var sliderDesc = (SliderConstraintDesc)constraintDesc;

                ModelEntity.Transform.Rotation = Pivot == Pivot.A ? sliderDesc.AxisInA : sliderDesc.AxisInB;

                lowerLinearLimit.Transform.Position = new Vector3(sliderDesc.Limit.LowerLinearLimit, 0, 0);
                upperLinearLimit.Transform.Position = new Vector3(sliderDesc.Limit.UpperLinearLimit, 0, 0);

                var newLowerLimit = -sliderDesc.Limit.LowerAngularLimit;
                var newUpperLimit = sliderDesc.Limit.UpperAngularLimit;

                if (newLowerLimit != lastLowerAngularLimit)
                {
                    var limitMesh = GetLimitDisc(GraphicsDevice, newLowerLimit).ToMeshDraw();
                    lowerAngulerLimit.Model = new Model {
                        limitMaterial, new Mesh {
                            Draw = limitMesh
                        }
                    };
                    lastLowerAngularLimit = newLowerLimit;
                }

                if (newUpperLimit != lastUpperAngularLimit)
                {
                    var limitMesh = GetLimitDisc(GraphicsDevice, newUpperLimit).ToMeshDraw();
                    upperAngularLimit.Model = new Model {
                        limitMaterial, new Mesh {
                            Draw = limitMesh
                        }
                    };
                    lastUpperAngularLimit = newUpperLimit;
                }
            }
예제 #3
0
            public override void Update(IConstraintDesc constraintDesc)
            {
                var coneDesc = (ConeTwistConstraintDesc)constraintDesc;

                ModelEntity.Transform.Rotation = Pivot == Pivot.A ? coneDesc.AxisInA : coneDesc.AxisInB;

                var newLimitZ = coneDesc.Limit.SetLimit ? coneDesc.Limit.SwingSpanZ : MathF.PI;
                var newLimitY = coneDesc.Limit.SetLimit ? coneDesc.Limit.SwingSpanY : MathF.PI;
                var newLimitT = coneDesc.Limit.SetLimit ? 2 * coneDesc.Limit.TwistSpan : 2 * MathF.PI;

                if (newLimitZ != lastLimitZ)
                {
                    var limitMesh = GetLimitDisc(GraphicsDevice, newLimitZ).ToMeshDraw();
                    limitZ.Model = new Model {
                        limitMaterial, new Mesh {
                            Draw = limitMesh
                        }
                    };
                    limitZ.Entity.Transform.Rotation = Quaternion.RotationY(MathF.PI + (newLimitZ / 2f));
                    lastLimitZ = newLimitZ;
                }

                if (newLimitY != lastLimitY)
                {
                    var limitMesh = GetLimitDisc(GraphicsDevice, newLimitY).ToMeshDraw();
                    limitY.Model = new Model {
                        limitMaterial, new Mesh {
                            Draw = limitMesh
                        }
                    };
                    limitY.Entity.Transform.Rotation = Quaternion.RotationY(MathF.PI + (newLimitY / 2f)) * Quaternion.RotationX(-MathUtil.PiOverTwo);
                    lastLimitY = newLimitY;
                }

                if (newLimitT != lastLimitT)
                {
                    var limitMesh = GetLimitDisc(GraphicsDevice, newLimitT).ToMeshDraw();
                    limitT.Model = new Model {
                        limitMaterial, new Mesh {
                            Draw = limitMesh
                        }
                    };
                    limitT.Entity.Transform.Rotation = Quaternion.RotationZ(MathUtil.PiOverTwo) * Quaternion.RotationX(MathUtil.PiOverTwo - newLimitT / 2f);
                    lastLimitT = newLimitT;
                }
            }
예제 #4
0
            public static ModelWrapper Create(IConstraintDesc constraintDesc, Pivot pivot, Graphics.GraphicsDevice graphicsDevice)
            {
                switch (constraintDesc)
                {
                case Point2PointConstraintDesc p:
                    return(new PointModelWrapper(p, pivot, graphicsDevice));

                case HingeConstraintDesc h:
                    return(new HingeModelWrapper(h, pivot, graphicsDevice));

                case ConeTwistConstraintDesc ct:
                    return(new ConeModelWrapper(ct, pivot, graphicsDevice));

                case GearConstraintDesc g:
                    return(new GearModelWrapper(g, pivot, graphicsDevice));

                case SliderConstraintDesc s:
                    return(new SliderModelWrapper(s, pivot, graphicsDevice));
                }

                throw new NotSupportedException();
            }
예제 #5
0
            public override void Update(IConstraintDesc constraintDesc)
            {
                var gearDesc = (GearConstraintDesc)constraintDesc;

                ModelEntity.Transform.Rotation = Pivot == Pivot.A ? gearDesc.AxisInA : gearDesc.AxisInB;
            }
예제 #6
0
 public override void Update(IConstraintDesc constraintDesc)
 {
     // model isn't changing
 }
예제 #7
0
 public abstract void Update(IConstraintDesc constraintDesc);