Ejemplo n.º 1
0
        public void AddGeometryData(MeshPartGeometryData data, MeshMaterial material, Matrix transform)
        {
            if (!parts.ContainsKey(material))
            {
                throw new InvalidOperationException("Material not created by the meshbuilder");
            }
            var p = parts[material];

            var xTransform = transform.xna();

            var sPositions = data.GetSourceVector3(MeshPartGeometryData.Semantic.Position);
            var sNormals   = data.GetSourceVector3(MeshPartGeometryData.Semantic.Normal);
            var sTexcoords = data.GetSourceVector2(MeshPartGeometryData.Semantic.Texcoord);

            var nPositions = new XnaVector3[sPositions.Length];
            var nNormals   = new XnaVector3[sNormals.Length];
            var nTexcoords = sTexcoords;

            XnaVector3.Transform(sPositions, ref xTransform, nPositions);
            XnaVector3.TransformNormal(sNormals, ref xTransform, nNormals);

            p.Positions.AddRange(nPositions);
            p.Normals.AddRange(nNormals);
            p.Texcoords.AddRange(nTexcoords);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// TODO: write tests for boundingbox calculation
        /// </summary>
        /// <param name="mesh"></param>
        /// <returns></returns>
        public static BoundingBox CalculateBoundingBox(IMesh mesh)
        {
            var ret = new XnaBoundingBox();

            foreach (var part in mesh.GetCoreData().Parts)
            {
                var positions = part.MeshPart.GetGeometryData().GetSourceVector3(MeshPartGeometryData.Semantic.Position);
                if (positions.Length == 0)
                {
                    continue;
                }

                //TODO: check this!
                XnaVector3.Transform(positions, ref part.ObjectMatrix, positions);
                ret = ret.MergeWith(XnaBoundingBox.CreateFromPoints(positions));
            }
            return(ret.dx());
        }
Ejemplo n.º 3
0
 public Vector3 TransformMatrixSubModel(Vector3 translateSub)
 {
     return(Vector3.Transform(translateSub, World));
 }
Ejemplo n.º 4
0
 public static Vector3 Transform(Vector3 vector, Quaternion transform)
 {
     return(new Vector3(
                MonoGameVector3.Transform(vector.MonoGameVector, transform)
                ));
 }
Ejemplo n.º 5
0
 public static Vector3 Transform(Vector3 vector, Matrix transform)
 {
     return(new Vector3(
                MonoGameVector3.Transform(vector.MonoGameVector, transform)
                ));
 }
Ejemplo n.º 6
0
 public static Vector3 Transform(Vector3 val, Matrix transform)
 {
     return(new Vector3(Vector.Transform(val, transform)));
 }