예제 #1
0
        /// <summary>
        /// Performs a cache lookup,
        /// adds a new static mesh if not found
        /// </summary>
        /// <param name="id">The model id to fetch the static mesh for</param>
        public static StaticMesh GetMesh(uint id)
        {
            StaticMesh mesh = null;

            Meshes.TryGetValue(id, out mesh);
            if (mesh == null)
            {
                mesh = new StaticMesh(id);
                Add(id, mesh);
            }
            return(mesh);
        }
예제 #2
0
        public void BuildBox(StaticMesh model)
        {
            Min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            Max = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            foreach (var gfxObj in model.GfxObjs)
            {
                foreach (var vertex in gfxObj.VertexArray.Vertices.Values)
                {
                    if (vertex.X < Min.X)
                    {
                        Min.X = vertex.X;
                    }
                    if (vertex.Y < Min.Y)
                    {
                        Min.Y = vertex.Y;
                    }
                    if (vertex.Z < Min.Z)
                    {
                        Min.Z = vertex.Z;
                    }

                    if (vertex.X > Max.X)
                    {
                        Max.X = vertex.X;
                    }
                    if (vertex.Y > Max.Y)
                    {
                        Max.Y = vertex.Y;
                    }
                    if (vertex.Z > Max.Z)
                    {
                        Max.Z = vertex.Z;
                    }
                }
            }

            GetSize();
        }
예제 #3
0
 /// <summary>
 /// Adds a static mesh to the cache
 /// </summary>
 public static void Add(uint id, StaticMesh mesh)
 {
     Meshes.Add(id, mesh);
 }
예제 #4
0
 public BoundingBox(StaticMesh model)
 {
     Model = model;
     BuildBox(model);
 }
예제 #5
0
 /// <summary>
 /// Returns a pointer to the static mesh
 /// </summary>
 public void GetMesh(uint modelId)
 {
     StaticMesh = StaticMeshCache.GetMesh(modelId);
 }