コード例 #1
0
 public void ValidityCheck(ModelComponent targetToValidate)
 {
     IsValid = targetToValidate == null ||
               Entity == null ||
               targetToValidate.Entity == null ||
               (targetToValidate.Entity.Id != Entity.Id &&
                RecurseCheckChildren(Entity.Transform.Children, targetToValidate.Entity.Transform) &&
                CheckParent(targetToValidate.Entity.Transform));
 }
コード例 #2
0
 public ModelViewHierarchyTransformOperation(ModelComponent modelComponent)
 {
     ModelComponent = modelComponent;
 }
コード例 #3
0
        public Entity AttachDebugShapeAsChild()
        {
            System.Numerics.Vector3 min, max;
            if (ColliderShape is IConvexShape ics)
            {
                ics.ComputeBounds(BepuHelpers.ToBepu(Quaternion.Identity), out min, out max);
            }
            else if (ColliderShape is BepuPhysics.Collidables.Mesh cm)
            {
                cm.ComputeBounds(BepuHelpers.ToBepu(Quaternion.Identity), out min, out max);
            }
            else
            {
                return(null);
            }

            Vector3 centerOffset = BepuHelpers.ToXenko(max + min) * 0.5f;

            Game g = ServiceRegistry.instance.GetService <IGame>() as Game;

            if (debugShapeMaterial == null)
            {
                var materialDescription = new MaterialDescriptor
                {
                    Attributes =
                    {
                        DiffuseModel = new MaterialDiffuseLambertModelFeature(),
                        Diffuse      = new MaterialDiffuseMapFeature(new ComputeColor {
                            Key      = MaterialKeys.DiffuseValue
                        })
                    }
                };

                debugShapeMaterial = Material.New(g.GraphicsDevice, materialDescription);
                debugShapeMaterial.Passes[0].Parameters.Set(MaterialKeys.DiffuseValue, Color.Red);

                var meshDraw = GeometricPrimitive.Cube.New(g.GraphicsDevice, Vector3.One).ToMeshDraw();

                cubeMesh = new Rendering.Mesh {
                    Draw = meshDraw
                };
            }

            Entity e = new Entity(Entity.Name + "-physicsBB");

            Model m = new Model();

            m.Add(debugShapeMaterial);
            m.Meshes.Add(cubeMesh);

            ModelComponent mc = e.GetOrCreate <ModelComponent>();

            mc.Model = m;

            e.Transform.Scale    = new Vector3(max.X - min.X, max.Y - min.Y, max.Z - min.Z) / Entity.Transform.WorldScale();
            e.Transform.Position = centerOffset / Entity.Transform.WorldScale();
            if (this is BepuRigidbodyComponent rb && rb.IgnorePhysicsRotation)
            {
                e.Transform.Rotation = Rotation;
            }
            e.Transform.Parent = Entity.Transform;

            return(e);
        }
コード例 #4
0
 public ModelNodeTransformLink(ModelComponent parentModelComponent, string nodeName)
 {
     this.parentModelComponent = parentModelComponent;
     this.nodeName             = nodeName;
 }