public SimModelBinding(ulong bindingID)
        {
            BindingID = bindingID;

            var binding = SimCatalog.GetBinding(bindingID);
            Mesh = SimCatalog.GetOutfitMesh(binding.MeshAssetID);
            Texture = SimCatalog.GetOutfitTexture(binding.TextureAssetID);
        }
Esempio n. 2
0
 public Mesh Clone()
 {
     var result = new Mesh()
     {
         BlendData = BlendData,
         BoneBindings = BoneBindings,
         NumPrimitives = NumPrimitives,
         IndexBuffer = IndexBuffer,
         RealVertexBuffer = RealVertexBuffer,
         BlendVertexBuffer = (MeshVertex[])BlendVertexBuffer.Clone()
     };
     return result;
 }
        public static Mesh GetOutfitMesh(Skeleton Skel, ulong id)
        {
            if (OutfitMeshes.ContainsKey(id))
            {
                return OutfitMeshes[id];
            }

            var mesh = new Mesh();
            mesh.Read(ContentManager.GetResourceFromLongID(id));
            mesh.ProcessMesh(Skel);
            OutfitMeshes.Add(id, mesh);
            return mesh;
        }
Esempio n. 4
0
        public static Mesh GetOutfitMesh(ulong id)
        {
            if (OutfitMeshes.ContainsKey(id))
            {
                return OutfitMeshes[id].Clone();
            }

            var mesh = new Mesh();
            mesh.Read(new MemoryStream(ContentManager.GetResourceFromLongID(id)));
            //mesh.ProcessMesh();
            OutfitMeshes.Add(id, mesh);
            return mesh;
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a brand new mesh object that is a complete copy of this one.
        /// We need this utility because the Skel system modifies meshs. This means we
        /// have to copy a sim mesh before we use it.
        /// </summary>
        /// <returns></returns>
        public Mesh Clone()
        {
            var newMesh = new Mesh
            {
                Version = this.Version,
                BoneCount = this.BoneCount,
                BoneNames = this.BoneNames,
                FaceCount = this.FaceCount,
                FaceData = this.FaceData,
                BindingCount = this.BindingCount,
                BoneBindings = this.BoneBindings,
                RealVertexCount = this.RealVertexCount,
                BlendVertexCount = this.BlendVertexCount,
                TotalVertexCount = this.TotalVertexCount
            };

            /** Because mesh vertex is a struct, copying the array should be enough to clone it **/
            newMesh.Vertex = this.Vertex.ToArray();
            newMesh.TransformedVertices = this.TransformedVertices.ToArray();
            newMesh.VertexTexNormalPositions = this.VertexTexNormalPositions.ToArray();

            return newMesh;
        }
Esempio n. 6
0
        /// <summary>
        /// Loads a head mesh.
        /// </summary>
        /// <param name="MeshID">The ID of the mesh to load.</param>
        /// <param name="TexID">The ID of the texture to load.</param>
        public void LoadHeadMesh(Outfit Outf, int SkinColor)
        {
            Appearance Apr;

            switch (SkinColor)
            {
                case 0:
                    Apr = new Appearance(ContentManager.GetResourceFromLongID(Outf.LightAppearanceID));
                    break;
                case 1:
                    Apr = new Appearance(ContentManager.GetResourceFromLongID(Outf.MediumAppearanceID));
                    break;
                case 2:
                    Apr = new Appearance(ContentManager.GetResourceFromLongID(Outf.DarkAppearanceID));
                    break;
                default:
                    Apr = new Appearance(ContentManager.GetResourceFromLongID(Outf.LightAppearanceID));
                    break;
            }

            Binding Bnd = new Binding(ContentManager.GetResourceFromLongID(Apr.BindingIDs[0]));

            if (m_CurrentHeadMeshes.Count > 0)
            {
                if (!m_SingleRenderer)
                {
                    m_Effects.Add(new BasicEffect(m_Scene.SceneMgr.Device, null));
                    m_CurrentHeadMeshes.Add(new Mesh(ContentManager.GetResourceFromLongID(Bnd.MeshAssetID), false));
                    m_CurrentHeadMeshes[m_CurrentHeadMeshes.Count - 1].ProcessMesh();

                    m_HeadTextures.Add(Texture2D.FromFile(m_Scene.SceneMgr.Device,
                        new MemoryStream(ContentManager.GetResourceFromLongID(Bnd.TextureAssetID))));
                }
                else
                {
                    m_Effects[0] = new BasicEffect(m_Scene.SceneMgr.Device, null);
                    m_CurrentHeadMeshes[0] = new Mesh(ContentManager.GetResourceFromLongID(Bnd.MeshAssetID), false);
                    m_CurrentHeadMeshes[m_CurrentHeadMeshes.Count - 1].ProcessMesh();

                    m_HeadTextures[0] = Texture2D.FromFile(m_Scene.SceneMgr.Device,
                        new MemoryStream(ContentManager.GetResourceFromLongID(Bnd.TextureAssetID)));
                }
            }
            else
            {
                m_Effects.Add(new BasicEffect(m_Scene.SceneMgr.Device, null));
                m_CurrentHeadMeshes.Add(new Mesh(ContentManager.GetResourceFromLongID(Bnd.MeshAssetID), false));
                m_CurrentHeadMeshes[m_CurrentHeadMeshes.Count - 1].ProcessMesh();

                m_HeadTextures.Add(Texture2D.FromFile(m_Scene.SceneMgr.Device,
                    new MemoryStream(ContentManager.GetResourceFromLongID(Bnd.TextureAssetID))));
            }

            //m_RenderTarget = CreateRenderTarget(m_Screen.ScreenMgr.GraphicsDevice, 0, SurfaceFormat.Color);
            /*m_RenderTarget = new RenderTarget2D(m_Scene.SceneMgr.Device, 800, 600,
                1, SurfaceFormat.Color);*/

            //m_DSBuffer = CreateDepthStencil(m_RenderTarget);
        }