public void Load(Skeleton skeleton, BCRES bcres)
        {
            Renderable = new STSkeleton();

            BcresParent = bcres;

            Skeleton = skeleton;
            Text     = "Skeleton";
            Checked  = true;

            foreach (var bone in skeleton.Bones.Values)
            {
                var boneWrapper = new CRESBoneWrapper();
                boneWrapper.skeletonParent = Renderable;
                boneWrapper.Load(bone, bcres);
                Renderable.bones.Add(boneWrapper);
            }

            Nodes.Clear();
            foreach (var bone in Renderable.bones)
            {
                if (bone.Parent == null)
                {
                    Nodes.Add(bone);
                }
            }

            Renderable.update();
            Renderable.reset();
        }
        public void Load(BCRES bcres, Material material)
        {
            Material    = material;
            BcresParent = bcres;

            Text = material.Name;

            if (material.TexCoordSources.Count > 0)
            {
                TexCoord1Buffer = new TexCoord1()
                {
                    Translate = Utils.ToVec2(material.TexCoordSources[0].Translate),
                    Rotate    = material.TexCoordSources[0].Rotate,
                    Scale     = Utils.ToVec2(material.TexCoordSources[0].Scale),
                };
            }

            int textureUnit = 1;

            if (material.TextureMapInfo1 != null)
            {
                Nodes.Add(CreateGenericMatTexture(textureUnit, bcres, material.TextureMapInfo1));
            }
            if (material.TextureMapInfo2 != null)
            {
                Nodes.Add(CreateGenericMatTexture(textureUnit, bcres, material.TextureMapInfo2));
            }
            if (material.TextureMapInfo3 != null)
            {
                Nodes.Add(CreateGenericMatTexture(textureUnit, bcres, material.TextureMapInfo3));
            }
        }
Exemplo n.º 3
0
        private BcresTextureMapWrapper CreateGenericMatTexture(int textureUnit, BCRES bcres, TextureMapInfo TextureMapInfo)
        {
            STGenericMatTexture tex1 = new STGenericMatTexture();
            var TexRef  = TextureMapInfo.TextureRef;
            var Sampler = TextureMapInfo.Sampler;

            tex1.textureUnit = textureUnit++;
            tex1.Name        = TexRef.Reference.Name;
            tex1.Type        = STGenericMatTexture.TextureType.Diffuse;
            TextureMaps.Add(tex1);

            switch (TextureMapInfo.WrapU)
            {
            case PICATextureWrap.Repeat: tex1.WrapModeS = STTextureWrapMode.Repeat; break;

            case PICATextureWrap.Mirror: tex1.WrapModeS = STTextureWrapMode.Mirror; break;

            case PICATextureWrap.ClampToEdge: tex1.WrapModeS = STTextureWrapMode.Clamp; break;

            case PICATextureWrap.ClampToBorder: tex1.WrapModeS = STTextureWrapMode.Clamp; break;
            }
            switch (TextureMapInfo.WrapV)
            {
            case PICATextureWrap.Repeat: tex1.WrapModeT = STTextureWrapMode.Repeat; break;

            case PICATextureWrap.Mirror: tex1.WrapModeT = STTextureWrapMode.Mirror; break;

            case PICATextureWrap.ClampToEdge: tex1.WrapModeT = STTextureWrapMode.Clamp; break;

            case PICATextureWrap.ClampToBorder: tex1.WrapModeT = STTextureWrapMode.Clamp; break;
            }

            switch (TextureMapInfo.MagFilter)
            {
            case PICATextureFilter.Linear: tex1.MagFilter = STTextureMagFilter.Linear; break;

            case PICATextureFilter.Nearest: tex1.MagFilter = STTextureMagFilter.Nearest; break;
            }

            switch (TextureMapInfo.MinFilter)
            {
            case PICATextureFilter.Linear: tex1.MagFilter = STTextureMagFilter.Linear; break;

            case PICATextureFilter.Nearest: tex1.MagFilter = STTextureMagFilter.Nearest; break;
            }

            switch (TextureMapInfo.MipFilter)
            {
            case PICATextureFilter.Linear: tex1.MagFilter = STTextureMagFilter.Linear; break;

            case PICATextureFilter.Nearest: tex1.MagFilter = STTextureMagFilter.Nearest; break;
            }


            var wrapperTexMap = new BcresTextureMapWrapper(bcres, TextureMapInfo, tex1);

            return(wrapperTexMap);
        }
Exemplo n.º 4
0
        public void LoadModel(Model model, BCRES bcres)
        {
            BcresParent = bcres;

            Model = model;
            Text  = model.Name;

            var MaterialFolder = new TreeNode("Materials");
            var MeshFolder     = new TreeNode("Meshes");

            Skeleton      = new CRESSkeletonWrapper();
            Skeleton.Text = "Skeleton";
            Checked       = true;

            Nodes.Add(MeshFolder);
            Nodes.Add(MaterialFolder);
            Nodes.Add(Skeleton);

            if (model.HasSkeleton)
            {
                Skeleton.Load(model.Skeleton, bcres);
            }

            int Index = 0;

            foreach (var material in model.Materials.Values)
            {
                var matWrapper = new MTOBWrapper();
                matWrapper.Load(bcres, material);
                if (matWrapper.Text == string.Empty)
                {
                    matWrapper.Text = $"Material {Index++}";
                }
                MaterialFolder.Nodes.Add(matWrapper);
                Materials.Add(matWrapper);
            }

            Index = 0;
            foreach (var mesh in model.Meshes)
            {
                var meshWrapper = new SOBJWrapper(this, mesh)
                {
                    BcresParent = bcres
                };
                MeshFolder.Nodes.Add(meshWrapper);
                if (meshWrapper.Text == string.Empty)
                {
                    meshWrapper.Text = $"Mesh {Index++}";
                }
                Shapes.Add(meshWrapper);
            }
        }
Exemplo n.º 5
0
        public BcresTextureMapWrapper(BCRES bcres, TextureMapInfo texInfo, STGenericMatTexture texture)
        {
            CanRename  = false;
            CanReplace = false;

            BcresParent = bcres;

            Text = texture.Name;
            GenericMatTexture = texture;
            TextureMapInfo    = texInfo;

            ImageKey         = "TextureMaterialMap";
            SelectedImageKey = "TextureMaterialMap";
        }
Exemplo n.º 6
0
        public void Load(Bone bone, BCRES bcres)
        {
            BcresParent = bcres;
            Checked     = true;

            Bone = bone;
            Text = bone.Name;

            parentIndex  = bone.ParentIndex;
            RotationType = BoneRotationType.Euler;
            position     = new float[3];
            scale        = new float[3];
            rotation     = new float[4];
            scale[0]     = bone.Scale.X;
            scale[1]     = bone.Scale.Y;
            scale[2]     = bone.Scale.Z;
            rotation[0]  = bone.Rotation.X;
            rotation[1]  = bone.Rotation.Y;
            rotation[2]  = bone.Rotation.Z;
            rotation[3]  = 1;
            position[0]  = bone.Position.X;
            position[1]  = bone.Position.Y;
            position[2]  = bone.Position.Z;
        }
 public MTOBWrapper(BCRES bcres, Material material) : base()
 {
     Load(bcres, material);
 }
Exemplo n.º 8
0
 public TXOBWrapper(Texture texture, BCRES bcres) : base()
 {
     BcresParent = bcres;
     LoadTexture(texture);
 }
Exemplo n.º 9
0
 public CMDLWrapper(Model model, BCRES bcres) : base()
 {
     BcresParent = bcres;
     LoadModel(model, bcres);
 }
 public CRESSkeletonWrapper(Skeleton skeleton, BCRES bcres) : base()
 {
     BcresParent = bcres;
     Load(skeleton, bcres);
 }
Exemplo n.º 11
0
 public CRESBoneWrapper(Bone bone, BCRES bcres) : base()
 {
     BcresParent = bcres;
     Load(bone, bcres);
 }