Example #1
0
        public MeshPrimitive(MeshCreatorControl control, TgcMesh mesh)
            : base(control)
        {
            //this.Name = mesh.Name + "_" + EditorPrimitive.PRIMITIVE_COUNT++;
            this.Name = mesh.Name;
            this.mesh = mesh;
            this.editablePolyEnabled = false;

            //Ver si tiene texturas
            if(mesh.RenderType == TgcMesh.MeshRenderType.DIFFUSE_MAP || mesh.RenderType == TgcMesh.MeshRenderType.DIFFUSE_MAP_AND_LIGHTMAP)
            {
                //Tiene, habilitar la edicion
                this.ModifyCaps.ChangeTexture = true;
                this.ModifyCaps.ChangeOffsetUV = true;
                this.ModifyCaps.ChangeTilingUV = true;
                this.ModifyCaps.TextureNumbers = mesh.DiffuseMaps.Length;
                this.originalUVCoords = mesh.getTextureCoordinates();
            }
            else
            {
                //No tiene textura, deshabilitar todo
                this.ModifyCaps.ChangeTexture = false;
                this.ModifyCaps.ChangeOffsetUV = false;
                this.ModifyCaps.ChangeTilingUV = false;
                this.ModifyCaps.TextureNumbers = 0;
            }
            
            this.UserProperties = this.mesh.UserProperties;
            this.uvOffset = new Vector2(0, 0);
            this.uvTile = new Vector2(1, 1);

            //Layer
            if (this.mesh.Layer != null && this.mesh.Layer.Length > 0)
            {
                this.Layer = this.mesh.Layer;
            }
            else
            {
                this.Layer = control.CurrentLayer;
            }

            //Ubicar mesh en el origen de coordenadas respecto del centro de su AABB
            setMeshToOrigin();
        }