Example #1
0
        /// Material::Layer が保持する TexAnim用Matrix の対象 Bone を探して index を格納しておく
        public void BindTexAnimBone()
        {
            foreach (BasicPart part in Parts)
            {
                foreach (var mesh in part.Meshes)
                {
                    if (mesh.Material >= 0)
                    {
                        BasicMaterial material = Materials[mesh.Material];
                        for (int i = 0; i < material.Layers.Length; i++)
                        {
                            BasicLayer layer = material.Layers[i];

                            // 隠しておいた名前から、Bone の index を確定させる
                            if (layer.TexAnimBoneName != "")
                            {
                                for (int bi = 0; bi < Bones.Length; bi++)
                                {
//								Console.WriteLine(Bones[bi].Name);
                                    if (layer.TexAnimBoneName == Bones[bi].Name)
                                    {
                                        layer.TexAnimBoneIdx = bi;
                                        material.UseTexAnim  = true;
                                    }
                                }
                            }
                            else
                            {
                                layer.TexAnimBoneIdx = -1;
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        /// Layer の BlindMode に設定されている値の読み込み
        void ReadLayerBlindData(BasicLayer layer, int pos, int end)
        {
            int term = pos;

            while (term < end && fileImage[term] != 0)
            {
                term++;
            }
            string name = "";

            if (term != pos)
            {
                name = encoding.GetString(fileImage, pos, term - pos);
            }
            int val = ReadInt32(term + (4 - (term % 4)));

            if (name == "TexCoord")
            {
                layer.TexCoord = val;
            }
            else if (name == "TexType")
            {
                layer.TexType = (TexType)val;
            }
            else if (name == "TangentID")
            {
                layer.TangentID = val;
            }
            else if (name == "TexBlendMode")
            {
                layer.TexBlendFunc = (TexBlendFunc)val;
            }
            else if (name == "TexWrapU")
            {
                layer.TexWrapU = 1 - val;
            }
            else if (name == "TexWrapV")
            {
                layer.TexWrapV = 1 - val;
            }
            else if (name == "magFilter")
            {
                layer.magFilter = val;
            }
            else if (name == "minFilter")
            {
                layer.minFilter = val;
            }
            else if (name == "mipFilter")
            {
                layer.mipFilter = val;
            }
            else
            {
                layer.TexAnimBoneName = name;
            }
        }
Example #3
0
        void LoadLayer(Chunk chunk, Chunk parent, BasicLayer layer)
        {
            Chunk child;

            for (int pos = chunk.Child; pos < chunk.Next; pos = child.Next)
            {
                child = ReadChunk(pos);
                int args = child.Args;
                switch (child.Type)
                {
                case ChunkType.SetTexture:
                    layer.Texture = ReadIndex(args);
                    break;

                case ChunkType.TexCrop:
                    break;

                case ChunkType.BlindData:
                    ReadLayerBlindData(layer, child.Args, child.Args + child.ArgsSize);
                    break;
                }
            }
        }
Example #4
0
        /// Material::Layer の設定を Shader に作用する
        void setLayers(
            GraphicsContext graphics,
            BasicProgram program,
            BasicMaterial material
            )
        {
            if (material.Layers == null)
            {
                return;
            }

            Texture texture = null;

            int layerCount = (material.Layers.Length <= 3) ? material.Layers.Length : 3;

            program.SetTexCount(layerCount);

            int texID = 0;

            if (NormalizeCubeMap != null)
            {
                graphics.SetTexture(texID, NormalizeCubeMap);
                texID++;
            }

//		bool flag = false;
            for (int i = 0; i < layerCount; i++)
            {
                BasicLayer layer = material.Layers[i];
//			Console.WriteLine(layer.Texture);
//			layer.Texture = 5;

                /*
                 * if(flag == false){
                 * layer.Texture = 0;
                 * flag = true;
                 * }
                 */
                texture = Textures[layer.Texture].Texture;
//            texture = Textures[ 1 ].Texture ;

                if (texture != null)
                {
                    // TexAnimation
                    if (layer.TexAnimBoneIdx >= 0)
                    {
                        Vector3 st = new Vector3();


                        st.X        = 1.0f - Bones[layer.TexAnimBoneIdx].Scaling.X;
                        st.Y        = 1.0f - Bones[layer.TexAnimBoneIdx].Scaling.Y;
                        st.Z        = 1.0f - Bones[layer.TexAnimBoneIdx].Scaling.Z;
                        texAnims[i] = Matrix4.Transformation(Bones[layer.TexAnimBoneIdx].Translation + st,
                                                             Bones[layer.TexAnimBoneIdx].Rotation,
                                                             Bones[layer.TexAnimBoneIdx].Scaling);
                    }
                    else
                    {
                        texAnims[i] = Matrix4.Identity;
                    }
                    texture.SetWrap((TextureWrapMode)layer.TexWrapU,
                                    (TextureWrapMode)layer.TexWrapV);
                    texture.SetFilter((TextureFilterMode)layer.magFilter,
                                      (TextureFilterMode)layer.minFilter,
                                      (TextureFilterMode)layer.mipFilter);
                    //                graphics.SetTexture( i + 1, texture );
                    graphics.SetTexture(texID, texture);
                    texID++;
                }
                program.SetTexMtx(texAnims);
                program.SetTexCoord(i, material.Layers[i].TexCoord);
                program.SetTangentID(material.Layers[i].TangentID);
                program.SetTexType(i, material.Layers[i].TexType);
                program.SetTexBlendFunc(i, material.Layers[i].TexBlendFunc);
            }
        }
Example #5
0
        /// Layer の BlindMode に設定されている値の読み込み
        void ReadLayerBlindData( BasicLayer layer, int pos, int end )
        {
            int term = pos ;
            while ( term < end && fileImage[ term ] != 0 ){
            term ++ ;
            }
            string name = "";
            if( term != pos ){
            name = encoding.GetString( fileImage, pos, term - pos ) ;
            }
            int val = ReadInt32( term + (4 - (term % 4)) );

            if( name == "TexCoord" ){ layer.TexCoord = val; }
            else if( name == "TexType" ){ layer.TexType = (TexType)val; }
            else if( name == "TangentID" ){
                layer.TangentID = val;
            }
            else if( name == "TexBlendMode" ){ layer.TexBlendFunc = (TexBlendFunc)val; }
            else if( name == "TexWrapU" ){ layer.TexWrapU = 1 - val; }
            else if( name == "TexWrapV" ){ layer.TexWrapV = 1 - val; }
            else if( name == "magFilter" ){ layer.magFilter = val; }
            else if( name == "minFilter" ){ layer.minFilter = val; }
            else if( name == "mipFilter" ){ layer.mipFilter = val; }
            else{ layer.TexAnimBoneName = name; }
        }
Example #6
0
 void LoadLayer( Chunk chunk, Chunk parent, BasicLayer layer )
 {
     Chunk child ;
     for ( int pos = chunk.Child ; pos < chunk.Next ; pos = child.Next ) {
     child = ReadChunk( pos ) ;
     int args = child.Args ;
     switch ( child.Type ) {
       case ChunkType.SetTexture :
         layer.Texture = ReadIndex( args ) ;
         break ;
       case ChunkType.TexCrop :
         break ;
       case ChunkType.BlindData :
         ReadLayerBlindData( layer, child.Args, child.Args + child.ArgsSize );
         break;
     }
     }
 }