Exemple #1
0
        private void UpdateScaleTransform()
        {
            var scale = (Vector3)PartCollision.GetSize().ToGL() * 2f;

            ScaleTransform = Matrix4.CreateScale(scale);
            Scale          = scale;
            BoundingBox    = BBox.FromCenterSize(Vector3.Zero, scale);
        }
Exemple #2
0
 public BoneModel(PartBone element) : base(element)
 {
     UpdateBoundingBox();
     SetTransformFromElement();
     BoundingBox = BBox.FromCenterSize(Vector3.Zero, Vector3.One);
     BoneLength  = 0.4f;
     UpdateModelTransforms();
     CalculateBoneLength();
 }
Exemple #3
0
 private void UpdateBoundingBox()
 {
     if (Bone.Bounding != null && !Bone.Bounding.IsEmpty)
     {
         BoneBounding = BBox.FromCenterSize(
             (Vector3)Bone.Bounding.Center.ToGL(),
             (Vector3)Bone.Bounding.Size.ToGL());
     }
     else
     {
         BoneBounding = BBox.Empty;
     }
 }
Exemple #4
0
        private static void InitializeBoundingBoxBuffer()
        {
            BoundingBoxBufffer = new IndexedVertexBuffer <Vector3>();
            var box = BBox.FromCenterSize(Vector3.Zero, Vector3.One);

            BoundingBoxBufffer.SetVertices(box.GetCorners());
            var bboxIndices = new List <int>();

            for (int i = 0; i < 4; i++)
            {
                bboxIndices.Add((i * 2));
                bboxIndices.Add((i * 2) + 1);
                bboxIndices.Add((i * 2));
                bboxIndices.Add(((i + 1) * 2) % 8);
                bboxIndices.Add((i * 2) + 1);
                bboxIndices.Add((((i + 1) * 2) + 1) % 8);
            }

            BoundingBoxBufffer.SetIndices(bboxIndices);
        }
Exemple #5
0
        public void CalculateBoneLength()
        {
            var newLength = 0.4f;
            var target    = Bone.GetLinkedBone();

            if (target != null)
            {
                newLength = (float)(target.Transform.Position - Bone.Transform.Position).Length;
            }

            if (BoneLength != newLength)
            {
                BoneLength = newLength;
                UpdateModelTransforms();
            }

            BoundingBox = BBox.FromCenterSize(
                new Vector3((newLength / 2f) - 0.1f, 0, 0),
                new Vector3(newLength + 0.2f, 0.4f, 0.4f)
                );
            IsLengthDirty = false;
        }
Exemple #6
0
 public void TransformSize(Vector3 amount)
 {
     EditedScale    = Scale + amount;
     ScaleTransform = Matrix4.CreateScale(EditedScale);
     BoundingBox    = BBox.FromCenterSize(Vector3.Zero, EditedScale);
 }
Exemple #7
0
        //public static Buffer<StudGridCell> StudGridBuffer { get; private set; }

        #endregion

        public static void InitializeResources()
        {
            ColorShader          = ProgramFactory.Create <ColorShaderProgram>();
            WireframeShader      = ProgramFactory.Create <WireframeShaderProgram>();
            ModelShader          = ProgramFactory.Create <ModelShaderProgram>();
            WireframeShader2     = ProgramFactory.Create <WireframeShader2Program>();
            StudConnectionShader = ProgramFactory.Create <StudConnectionShaderProgram>();
            SimpleTextureShader  = ProgramFactory.Create <SimpleTextureShaderProgram>();

            BoundingBoxBufffer = new IndexedVertexBuffer <Vector3>();
            var box = BBox.FromCenterSize(Vector3.Zero, Vector3.One);

            BoundingBoxBufffer.SetVertices(box.GetCorners());
            var bboxIndices = new List <int>();

            for (int i = 0; i < 4; i++)
            {
                bboxIndices.Add((i * 2));
                bboxIndices.Add((i * 2) + 1);
                bboxIndices.Add((i * 2));
                bboxIndices.Add(((i + 1) * 2) % 8);
                bboxIndices.Add((i * 2) + 1);
                bboxIndices.Add((((i + 1) * 2) + 1) % 8);
            }

            BoundingBoxBufffer.SetIndices(bboxIndices);

            //StudGridBuffer = new Buffer<StudGridCell>();


            CollisionMaterial = new MaterialInfo
            {
                Diffuse   = new Vector4(1f, 0.05f, 0.05f, 1f),
                Specular  = new Vector3(1f),
                Shininess = 2f
            };

            ConnectionMaterial = new MaterialInfo
            {
                Diffuse   = new Vector4(0.95f, 0.95f, 0.05f, 1f),
                Specular  = new Vector3(1f),
                Shininess = 2f
            };

            MaleConnectorMaterial = new MaterialInfo
            {
                Diffuse   = new Vector4(0.05f, 0.05f, 0.95f, 1f),
                Specular  = new Vector3(1f),
                Shininess = 2f
            };

            FemaleConnectorMaterial = new MaterialInfo
            {
                Diffuse   = new Vector4(0.05f, 0.95f, 0.05f, 1f),
                Specular  = new Vector3(1f),
                Shininess = 2f
            };

            WireframeColor        = new Vector4(0, 0, 0, 1f);
            WireframeColorAlt     = new Vector4(0.85f, 0.85f, 0.85f, 1f);
            SelectionOutlineColor = new Vector4(1f);
        }