Ejemplo n.º 1
0
        public MeshPrimitive(MeshCreatorModifier control, TgcMesh mesh)
            : base(control)
        {
            //this.Name = mesh.Name + "_" + EditorPrimitive.PRIMITIVE_COUNT++;
            Name                = mesh.Name;
            this.mesh           = mesh;
            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
                ModifyCaps.ChangeTexture  = true;
                ModifyCaps.ChangeOffsetUV = true;
                ModifyCaps.ChangeTilingUV = true;
                ModifyCaps.TextureNumbers = mesh.DiffuseMaps.Length;
                originalUVCoords          = mesh.getTextureCoordinates();
            }
            else
            {
                //No tiene textura, deshabilitar todo
                ModifyCaps.ChangeTexture  = false;
                ModifyCaps.ChangeOffsetUV = false;
                ModifyCaps.ChangeTilingUV = false;
                ModifyCaps.TextureNumbers = 0;
            }

            UserProperties = this.mesh.UserProperties;
            uvOffset       = new TGCVector2(0, 0);
            uvTile         = new TGCVector2(1, 1);

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

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