コード例 #1
0
 void UpdateFrame()
 {
     if (visMat != null)
     {
         for (int i = 0; i < visMat.textures.Count; i++)
         {
             VisualMaterialTexture t = visMat.textures[i];
             if (t.ScrollingEnabled)
             {
                 float offsetU = t.currentScrollX + (t.IsScrollX ? currentFrame * t.ScrollX : 0);
                 float offsetV = t.currentScrollY + (t.IsScrollY ? currentFrame * t.ScrollY : 0);
                 mat.SetTextureOffset("_Tex" + i, new Vector2(offsetU, offsetV));
             }
         }
     }
 }
コード例 #2
0
ファイル: MeshFile.cs プロジェクト: icup321/raymap
        private VisualMaterial ConvertMaterialSection(Section s)
        {
            VisualMaterial vm = new VisualMaterial(null);
            Material       m  = (Material)s[0]["material"];

            vm.ambientCoef  = m.color * m.ambient;
            vm.diffuseCoef  = new Color(m.diffuse, m.diffuse, m.diffuse);
            vm.specularCoef = new Color(m.specular, m.specular, m.specular);
            vm.num_textures = 1;
            if (m.isTextured)
            {
                MaterialTexture       mt        = (MaterialTexture)s[1][0]["texture"];
                byte[]                texName   = s[1][1].data;
                byte[]                alphaName = s[1][2].data;
                VisualMaterialTexture vmt       = new VisualMaterialTexture();

                /*foreach (TextureDictionary txd in txds) {
                 *      Texture2D tex = txd.Lookup(texName, TextureDictionary.Type.Texture);
                 *      if (tex != null) {
                 *              vmt.texture = new TextureInfo(null) {
                 *                      width = (ushort)tex.width,
                 *                      height = (ushort)tex.height,
                 *                      Texture = tex
                 *              };
                 *              break;
                 *      }
                 * }*/
                vm.textures.Add(vmt);
            }
            else
            {
                vm.textures.Add(new VisualMaterialTexture()
                {
                    texture = new TextureInfo(null)
                    {
                        width   = 1,
                        height  = 1,
                        Texture = Util.CreateDummyTexture()
                    }
                });
            }

            return(vm);
        }