Exemplo n.º 1
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++;
            }

            for( int i = 0; i < layerCount; i++ ){
            BasicLayer layer = material.Layers[ i ];
            texture = Textures[ layer.Texture ].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 );
            }
        }
Exemplo n.º 2
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);
            }
        }