public void AddTexIdAndStoreSize(PathForImage image, int number, SortedDictionary <string, int> texAndInd)
        {
            var tempTexInfo = new TextureInformation();

            var absolutePath = image.AbsolutePath;

            if (_convertLoadingFilePath != null)
            {
                absolutePath = _convertLoadingFilePath(absolutePath);
            }

            if (!texAndInd.ContainsKey(image.RelativePath) || !tempTexInfo.Load(absolutePath))
            {
                AddInt(-1);
                return;
            }

            if (_value.UVTextureReferenceTarget.Value != Data.UVTextureReferenceTargetType.None &&
                number == (int)_value.UVTextureReferenceTarget.Value)
            {
                _texInfo.Load(absolutePath);
            }

            AddInt(texAndInd[image.RelativePath]);
        }
Example #2
0
        public static void SetSprite(RawImage image, string name)
        {
            DataSprite data = DataManager.Instance.Load <DataSprite>();

            TextureInformation information = data.GetTexture2D(name);

            if (information == null)
            {
                return;
            }

            if (textures.ContainsKey(information.name))
            {
                if (textures[information.name] != null)
                {
                    SetSprite(image, textures[information.name]);
                }
            }
            else
            {
                ResourceManager.LoadAsync <Texture2D>(information.path, (texture) =>
                {
                    if (texture != null)
                    {
                        SetSprite(image, texture);
                    }
                    Add(information.name, texture);
                });
            }
        }
Example #3
0
        public byte[] SerializeUv(TextureInformation texInfo)
        {
            GetSize(texInfo, out float width, out float height);

            var aggregator = new UvAggregator(width, height);

            aggregator.Add(UvType);

            switch (UvType.Value)
            {
            case Data.RendererCommonValues.UVType.Default:
                break;

            case Data.RendererCommonValues.UVType.Fixed:
                SerializeFixedUv(aggregator);
                break;

            case Data.RendererCommonValues.UVType.Animation:
                SerializeAnimationUv(aggregator);
                break;

            case Data.RendererCommonValues.UVType.Scroll:
                SerializeScrollUv(aggregator);
                break;

            case Data.RendererCommonValues.UVType.FCurve:
                SerializeFCurveUv(aggregator);
                break;
            }

            return(aggregator.CurrentData.ToArray().ToArray());
        }
Example #4
0
 /// <summary>
 /// Converts a TextureInformation to a SimulatedTexture
 /// </summary>
 /// <param name="information"></param>
 /// <returns></returns>
 public static SimulatedTexture ToSimulatedTexture(this TextureInformation information)
 {
     return(new SimulatedTexture
     {
         Filename = information.FilePath
     });
 }
        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformations)
        {
            VertexPositionTexture[] billboardVertices = new VertexPositionTexture[positions.Count * 6];
            int i = 0;

            foreach (var position in positions)
            {
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(0, 0));
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(1, 0));
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(1, 1));

                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(0, 0));
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(1, 1));
                billboardVertices[i++] = new VertexPositionTexture(position, new Vector2(0, 1));
            }


            VertexBuffer vertexBufferS = factory.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, billboardVertices.Count(), BufferUsage.WriteOnly);
            vertexBufferS.SetData(billboardVertices);
            int noVertices = billboardVertices.Count();
            int noTriangles = noVertices / 3;

            BatchInformations = new BatchInformation[1][];
            BatchInformation[] b = new BatchInformation[1];
            b[0] = new BatchInformation(0, 0, noTriangles, 0, 0, VertexPositionTexture.VertexDeclaration, VertexPositionTexture.VertexDeclaration.VertexStride, BatchType.NORMAL);
            b[0].VertexBuffer = vertexBufferS;
            b[0].IndexBuffer = null;
            BatchInformations[0] = b;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[1];
            TextureInformations[0][0] = new TextureInformation(isInternal, factory, diffuseTextureName, null, null, null);
            TextureInformations[0][0].LoadTexture();
        }
 void Modelo_OnTextureChange(TextureType type, TextureInformation model)
 {
     this.aniTex = model.getTexture(TextureType.DIFFUSE);
     totalwidth  = aniTex.Width;
     this.width  = aniTex.Width / numberOfFrames;
     this.height = aniTex.Height;
     size        = width / totalwidth;
 }
 public void Setup()
 {
     a           = new TextureInformation();
     a.Depth     = 32;
     a.Format    = SurfaceFormat.Bgr444;
     a.Height    = 500;
     a.MipLevels = 3;
     a.Width     = 400;
 }
        private int GetTexIdAndInfo(PathForImage image, SortedDictionary <string, int> texAndInd, ref TextureInformation texInfoRef)
        {
            var tempTexInfo = new TextureInformation();

            if (!texAndInd.ContainsKey(image.RelativePath) || !tempTexInfo.Load(image.AbsolutePath))
            {
                return(-1);
            }

            texInfoRef.Load(image.AbsolutePath);
            return(texAndInd[image.RelativePath]);
        }
        public void EqualsTest()
        {
            TextureInformation b = new TextureInformation();

            Assert.IsFalse(b == a, "#1");
            Assert.IsTrue(b != a, "#2");
            Assert.IsFalse(b.Equals(null), "#3");
            Assert.IsTrue(b.Equals(b), "#4");
            int val = 0;

            Assert.IsFalse(b.Equals(val));
        }
 protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformation)
 {
     model = factory.GetModel(this.Name, isInternal, forceFromDisk);
     ModelBuilderHelper.Extract(factory,out BatchInformations, out TextureInformation,model,_diffuseName,_bumpName,_specularName,_glowName,isInternal);            
     
     BoundingSphere sphere = new BoundingSphere();
     foreach (var item in model.Meshes)
     {
         sphere = BoundingSphere.CreateMerged(sphere, item.BoundingSphere);
     }
     modelRadius = sphere.Radius;         
 }
Example #11
0
        protected override void GetSize(TextureInformation texInfo, out float width, out float height)
        {
            // specification change(1.5)
            width  = 128.0f;
            height = 128.0f;

            if (texInfo.Width > 0 && texInfo.Height > 0)
            {
                width  = texInfo.Width;
                height = texInfo.Height;
            }
        }
        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformations)
        {
            List<VertexPositionNormalTexture> vertexList = new List<VertexPositionNormalTexture>();
#if WINDOWS_PHONE || REACH
            ////gambi shortcut
            List<int> indexList2 = new List<int>();
            GetVertexData(vertexList, indexList2, terrainObject);
            List<short> indexList = new List<short>();
            foreach (var item in indexList2)
            {
                indexList.Add( (short) item);
            }
            indexList2.Clear();
#else
            List<int> indexList = new List<int>();
            GetVertexData(vertexList, indexList, terrainObject);
#endif
            modelRadius = (terrainObject.BoundingBox.Value.Max - terrainObject.BoundingBox.Value.Max).Length() / 2;

            var newVertices = new VertexPositionNormalTexture[vertexList.Count];
            vertexList.CopyTo(newVertices);

#if WINDOWS_PHONE|| REACH
            var newIndices = new short[indexList.Count];
#else
            var newIndices = new int[indexList.Count];
#endif
            
            indexList.CopyTo(newIndices);

            VertexBuffer vertexBufferS = factory.CreateVertexBuffer(VertexPositionNormalTexture.VertexDeclaration, newVertices.Count(), BufferUsage.WriteOnly);
            vertexBufferS.SetData(newVertices);
#if WINDOWS_PHONE || REACH
            IndexBuffer indexBufferS = factory.CreateIndexBuffer(IndexElementSize.SixteenBits,newIndices.Count(),BufferUsage.WriteOnly);
#else
            IndexBuffer indexBufferS = factory.CreateIndexBuffer(IndexElementSize.ThirtyTwoBits, newIndices.Count(), BufferUsage.WriteOnly);
#endif
            indexBufferS.SetData(newIndices);
            
            BatchInformations = new BatchInformation[1][];
            BatchInformation[] b = new BatchInformation[1];
            b[0] = new BatchInformation(0, newVertices.Count(), newIndices.Count() / 3, 0, 0, VertexPositionNormalTexture.VertexDeclaration,VertexPositionNormalTexture.VertexDeclaration.VertexStride);
            b[0].VertexBuffer = vertexBufferS;
            b[0].IndexBuffer = indexBufferS;
            b[0].ModelLocalTransformation = Matrix.Identity;
            BatchInformations[0] = b;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[1];
            TextureInformations[0][0] = new TextureInformation(isInternal, factory, null, null, null, null);
            TextureInformations[0][0].LoadTexture();
        }
        public void ShowSelector(int id)
        {
            // Mover botones modificadores a un costado
            LeanTween.moveLocal(modificationTexture.gameObject, posSelectedModification.localPosition, modificationTexture.time);

            // TODO fade out del texto
            UIButtonModification[] bttnsModifications = modificationTexture.transform.GetComponentsInChildren <UIButtonModification>();

            for (int i = 0; i < bttnsModifications.Length; i++)
            {
                bttnsModifications[i].FadeText(true);
                bttnsModifications[i].GetButton().interactable = false;
            }

            Feature feat = features.FirstOrDefault((f) => f.isActive == true);

            // Obtener contenedor de los botones de texturas
            Transform listContent = selectorTexture.transform.GetChild(0);

            // eliminar hijos
            for (int i = 0; i < listContent.childCount; i++)
            {
                Destroy(listContent.GetChild(i).gameObject);
            }

            // Obtener textura e informacion para utilizarlas en el cambio de texturas del objeto
            TextureInformation ti = feat.texturesInformation.Single((tinfo) => tinfo.id == id);

            ti.isActive = true;

            foreach (Texture t in ti.textures)
            {
                // crear botones
                // agregar listener para cambiar texturas

                Button bttn = Instantiate(prefButtonSelector, listContent).GetComponent <Button>();

                bttn.onClick.AddListener(() => { m_shaderControl.setTexture(ti.id, (Texture2D)t); });

                // cambiar textura del boton
                bttn.transform.GetComponentInChildren <RawImage>().texture = t;
            }

            // Crear boton fake para poder visualizar el ultimo boton
            // este problema ocurre debido a los diferentes aspect ratios
            if (ti.textures.Length > 2)
            {
                Instantiate(prefFakeButtonSelector, listContent);
            }

            selectorTexture.setActiveWindow(true);
        }
Example #14
0
 public TextureValuesAggregator(
     Data.RendererCommonValues value,
     AdvancedRenderCommonValues advanceValue,
     TextureInformationRepository repo)
 {
     _value             = value;
     _advanceValue      = advanceValue;
     _texInfo           = repo.Texture;
     _alpha             = repo.Alpha;
     _uvDistortion      = repo.UvDistortion;
     _blend             = repo.Blend;
     _blendAlpha        = repo.BlendAlpha;
     _blendUvDistortion = repo.BlendUvDistortion;
 }
 public TextureValuesAggregator(
     Data.RendererCommonValues value,
     AdvancedRenderCommonValues advanceValue,
     TextureInformationRepository repo,
     System.Func <string, string> convertLoadingFilePath)
 {
     _value                  = value;
     _advanceValue           = advanceValue;
     _texInfo                = repo.Texture;
     _alpha                  = repo.Alpha;
     _uvDistortion           = repo.UvDistortion;
     _blend                  = repo.Blend;
     _blendAlpha             = repo.BlendAlpha;
     _blendUvDistortion      = repo.BlendUvDistortion;
     _convertLoadingFilePath = convertLoadingFilePath;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomModel"/> class.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="modelName">Name of the model.</param>
        /// <param name="meshindex">The meshindex.</param>
        /// <param name="binfo">The binfo.</param>
        /// <param name="diffuse">The diffuse.</param>
        public CustomModel(GraphicFactory factory, String modelName, int meshindex, BatchInformation[] binfo, Texture2D diffuse = null)
            : base(factory, modelName,false)
        {
            System.Diagnostics.Debug.Assert(binfo != null);
            System.Diagnostics.Debug.Assert(binfo.Count() != 0);
            BatchInformations = new BatchInformation[1][];
            BatchInformations[0] = binfo;

            BoundingSphere bs = new BoundingSphere();
            for (int i = 0; i < binfo.Count(); i++)
            {
                float radius;
                Vector3 center;
                ModelBuilderHelper.ExtractModelRadiusAndCenter(binfo[i], out radius, out center);
                bs = BoundingSphere.CreateMerged(bs, new BoundingSphere(center, radius));
            }
            modelRadius = bs.Radius;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[binfo.Count()];
            
            for (int j = 0; j < TextureInformations[0].Count(); j++)
            {
                TextureInformations[0][j] = new TextureInformation(isInternal, factory);
                TextureInformations[0][j].LoadTexture();
                if (diffuse == null)
                {
                    if (model != null)
                    {
                        BasicEffect effect = model.Meshes[meshindex].MeshParts[j].Effect as BasicEffect;
                        if (effect != null)
                        {
                            TextureInformations[0][j].SetTexture(effect.Texture, TextureType.DIFFUSE);
                        }
                    }
                }
                else
                {
                       SetTexture(diffuse, TextureType.DIFFUSE,meshindex,j);
                }            
            }
        }
        public void ConstructorTest()
        {
            a = new TextureInformation();
            Assert.AreEqual(a.Depth, 0, "#1");
            Assert.AreEqual(a.Format, (SurfaceFormat)0, "#2");
            Assert.AreEqual(a.Height, 0, "#3");
            Assert.AreEqual(a.ImageFormat, ImageFileFormat.Bmp, "#4");
            Assert.AreEqual(a.MipLevels, 0, "#5");
            Assert.AreEqual(a.ResourceType, (ResourceType)0, "#6");
            Assert.AreEqual(a.Width, 0, "#7");


            a = new TextureInformation(15, 26, 37, 115, SurfaceFormat.Rgba1010102);
            Assert.AreEqual(a.Depth, 37, "#8");
            Assert.AreEqual(a.Format, SurfaceFormat.Rgba1010102, "#9");
            Assert.AreEqual(a.Height, 26, "#10");
            Assert.AreEqual(a.ImageFormat, ImageFileFormat.Jpg, "#11");
            Assert.AreEqual(a.MipLevels, 115, "#12");
            Assert.AreEqual(a.ResourceType, ResourceType.Texture2D, "#13");
            Assert.AreEqual(a.Width, 15, "#14");
        }
        public static void Extract(GraphicFactory factory,out BatchInformation[][] batchInformationS, out TextureInformation[][] textureInformationS, Model model,String diffuseName = null,String bumpName = null,string specularName = null,String glowName = null , bool isinternal = false)
        {            
            batchInformationS = new BatchInformation[model.Meshes.Count][];
            textureInformationS = new TextureInformation[model.Meshes.Count][];
            Matrix[] boneabsolute = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(boneabsolute);

            for (int j = 0; j < model.Meshes.Count; j++)
            {
                ModelMesh mesh = model.Meshes[j];

                BatchInformation[] b = new BatchInformation[mesh.MeshParts.Count];
                TextureInformation[] t = new TextureInformation[mesh.MeshParts.Count];
                for (int i = 0; i < mesh.MeshParts.Count; i++)
                {
                    b[i] = new BatchInformation(mesh.MeshParts[i].VertexOffset, mesh.MeshParts[i].NumVertices, mesh.MeshParts[i].PrimitiveCount, mesh.MeshParts[i].StartIndex, mesh.MeshParts[i].VertexOffset, mesh.MeshParts[i].VertexBuffer.VertexDeclaration, mesh.MeshParts[i].VertexBuffer.VertexDeclaration.VertexStride);
                    b[i].IndexBuffer = mesh.MeshParts[i].IndexBuffer;
                    b[i].VertexBuffer = mesh.MeshParts[i].VertexBuffer;
                    b[i].ModelLocalTransformation = boneabsolute[mesh.ParentBone.Index];
                    t[i] = new TextureInformation(isinternal, factory, diffuseName, bumpName, specularName, glowName);
                    t[i].LoadTexture();

                    if (diffuseName == null)
                    {
                        BasicEffect BasicEffect = mesh.MeshParts[i].Effect as BasicEffect;
                        if (BasicEffect != null)
                        {
                            t[i].SetTexture(BasicEffect.Texture, TextureType.DIFFUSE);
                        }
                        else if (mesh.MeshParts[i].Effect is SkinnedEffect)
                        {
                            t[i].SetTexture((mesh.MeshParts[i].Effect as SkinnedEffect).Texture, TextureType.DIFFUSE);
                        }
                    }                    

                }
                batchInformationS[j] = b;
                textureInformationS[j] = t;
            }
        }
Example #19
0
        private void RegisterMachines(ICoreApi coreApi)
        {
            this.Monitor.Log("Registering machines...", LogLevel.Info);
            IItemApi itemApi = coreApi.Items;

            // Stone converter
            TextureInformation    textureInfo    = new TextureInformation(Game1.bigCraftableSpriteSheet, new Rectangle(16 * 3, 32 * 2, 16, 32));
            StoneConverterMachine stoneConverter = new StoneConverterMachine(this, "stoneConverter", textureInfo);

            itemApi.Register("stoneConverter", stoneConverter);

            // TODO: debug
            this.Helper.Events.Input.ButtonPressed += (sender, args) => {
                if (args.Button == SButton.NumPad3 && itemApi.TryGetInformation("stoneConverter", out IObjectInformation info) && info.Index is int index)
                {
                    SObject machine = new SObject(Vector2.Zero, index, false);
                    Game1.player.addItemToInventory(machine);
                }
            };

            this.Monitor.Log("Done");
        }
        /// <summary>
        /// Loads the model.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="BatchInformations">The batch informations.</param>
        /// <param name="TextureInformations">The texture informations.</param>
        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformations)
        {
            TreeProfile t = factory.GetAsset<TreeProfile>(profileName);
            if (!String.IsNullOrEmpty(LeaftextureName))
            {
                t.LeafTexture = factory.GetAsset<Texture2D>(LeaftextureName);
            }
            if (!String.IsNullOrEmpty(trunktextureName))
            {
                t.TrunkTexture = factory.GetAsset<Texture2D>(trunktextureName);
            }
            tree = t.GenerateSimpleTree(StaticRandom.RandomInstance);

            BatchInformations = new BatchInformation[2][];
            vertexBufferS = new VertexBuffer[2];
            indexBufferS = new IndexBuffer[2];
            indexBufferS[0] = tree.TrunkMesh.IndexBuffer;
            vertexBufferS[0] = tree.TrunkMesh.VertexBuffer;
            BatchInformation bi0 = new BatchInformation(0, tree.TrunkMesh.NumberOfVertices, tree.TrunkMesh.NumberOfTriangles, 0, 0, tree.TrunkMesh.Vdeclaration, TreeVertex.SizeInBytes);
            BatchInformations[0] = new BatchInformation[1];
            BatchInformations[0][0] = bi0;

            indexBufferS[1] = tree.LeafCloud.Ibuffer;
            vertexBufferS[1] = tree.LeafCloud.Vbuffer;
            BatchInformation bi1 = new BatchInformation(0, tree.LeafCloud.Numleaves * 4, tree.LeafCloud.Numleaves * 2, 0, 0, tree.LeafCloud.Vdeclaration, LeafVertex.SizeInBytes);
            BatchInformations[1] = new BatchInformation[1];
            BatchInformations[1][0] = bi1;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[2];
            TextureInformations[0][0] = new TextureInformation(isInternal, factory, null, null, null, null);
            TextureInformations[0][1] = new TextureInformation(isInternal, factory, null, null, null, null);
            TextureInformations[0][0].LoadTexture();
            TextureInformations[0][1].LoadTexture();
            TextureInformations[0][0].SetTexture(tree.TrunkTexture, TextureType.DIFFUSE);
            TextureInformations[0][1].SetTexture(tree.LeafTexture, TextureType.DIFFUSE);

        }
        protected override void  LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformation)

        {
            vertexBufferS = factory.CreateDynamicVertexBuffer(VertexPositionTexture.VertexDeclaration, vertices.Count(), BufferUsage.None);
            vertexBufferS.SetData(vertices);
            int noVertices  = vertices.Count();
            int noTriangles = indices.Count() / 3;

            indexBufferS = factory.CreateDynamicIndexBuffer(IndexElementSize.ThirtyTwoBits, indices.Count(), BufferUsage.None);
            indexBufferS.SetData(indices);

            BatchInformations = new BatchInformation[1][];
            BatchInformation[] b = new BatchInformation[1];
            b[0] = new BatchInformation(0, noVertices, noTriangles, 0, 0, VertexPositionTexture.VertexDeclaration, VertexPositionTexture.VertexDeclaration.VertexStride, BatchType.INDEXED);
            b[0].VertexBuffer    = vertexBufferS;
            b[0].IndexBuffer     = indexBufferS;
            BatchInformations[0] = b;

            TextureInformation       = new TextureInformation[1][];
            TextureInformation[0]    = new TextureInformation[1];
            TextureInformation[0][0] = new TextureInformation(false, factory);
            TextureInformation[0][0].SetTexture(diffuseName, TextureType.DIFFUSE);
        }
        /// <summary>
        /// Loads the model.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="BatchInformations">The batch informations.</param>
        /// <param name="TextureInformations">The texture informations.</param>
        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformations)
        {
            int vertCount = bilboards.Count() * 4;
            int indexCount = bilboards.Count() * 6;
            int noVertices = vertCount;
            int noTriangles = indexCount / 3;

            VertexBuffer vertexBufferS = factory.CreateDynamicVertexBuffer(VertexPositionTexture.VertexDeclaration, vertCount, BufferUsage.WriteOnly);
            IndexBuffer IndexBufferS = factory.CreateDynamicIndexBuffer(IndexElementSize.SixteenBits, indexCount, BufferUsage.WriteOnly);

            BatchInformations = new BatchInformation[1][];
            BatchInformation[] b = new BatchInformation[1];
            b[0] = new BatchInformation(0, vertCount, noTriangles, 0, 0, VertexPositionTexture.VertexDeclaration, VertexPositionTexture.VertexDeclaration.VertexStride, BatchType.INDEXED);
            b[0].ModelLocalTransformation = Matrix.Identity;
            b[0].VertexBuffer = vertexBufferS;
            b[0].IndexBuffer = IndexBufferS;
            BatchInformations[0] = b;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[1];
            
            TextureInformations[0][0] = new TextureInformation(isInternal, factory, diffuseTextureName, null, null, null);
            TextureInformations[0][0].LoadTexture();
        }
Example #23
0
        public static TextureInformation[] GetTextureInformationsById(string id)
        {
            List <TextureInformation> result = new List <TextureInformation>();
            SQLiteConnection          con    = GetConnection();

            con.Open();
            SQLiteDataReader reader = getAllWhere("res", "rtype = 'A654495C' and lower(name) = '" + id.ToLower() + "'", con);
            int count = 0;

            while (reader.Read())
            {
                if (count++ % 1000 == 0)
                {
                    Application.DoEvents();
                }
                TextureInformation ti = new TextureInformation();
                ti.name        = reader.GetString(0);
                ti.sha1        = Helpers.HexStringToByteArray(reader.GetString(1));
                ti.bundleIndex = reader.GetInt32(3);
                result.Add(ti);
            }
            con.Close();
            return(result.ToArray());
        }
Example #24
0
 /// <summary>
 /// Loads the batch info, called by the constructor if callLoadContent is true
 /// </summary>
 /// <param name="factory">The factory.</param>
 /// <param name="BatchInformations">The batch informations.</param>
 /// <param name="TextureInformation">The texture information.</param>
 protected abstract void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformation);
        public static byte[] GetBytes(Data.RendererCommonValues2 value, Dictionary <string, int> texture_and_index, Dictionary <string, int> distortionTexture_and_index)
        {
            List <byte[]> data = new List <byte[]>();

            var texInfo    = new TextureInformation();
            var hasTexture = true;

            // ColorTextute
            if (value.ColorTexture2.RelativePath != string.Empty &&
                texture_and_index.ContainsKey(value.ColorTexture2.RelativePath) &&
                texInfo.Load(value.ColorTexture2.AbsolutePath))
            {
                data.Add(texture_and_index[value.ColorTexture2.RelativePath].GetBytes());
                hasTexture = true;
            }
            else
            {
                data.Add((-1).GetBytes());
                hasTexture = false;
            }
            // AlphaTexture
            if (value.AlphaTexture2.RelativePath != string.Empty &&
                texture_and_index.ContainsKey(value.AlphaTexture2.RelativePath) &&
                texInfo.Load(value.AlphaTexture2.AbsolutePath))
            {
                data.Add(texture_and_index[value.AlphaTexture2.RelativePath].GetBytes());
                hasTexture = true;
            }
            else
            {
                data.Add((-1).GetBytes());
                //hasTexture = false;
            }

            // BlendMode
            data.Add(value.BlendInType);

            // Filter
            data.Add(value.Filter);

            // Wrap
            data.Add(value.Wrap);

            // UV
            if (hasTexture)
            {
                var width  = (float)texInfo.Width;
                var height = (float)texInfo.Height;

                // UV type
                data.Add(value.UV);

                // Default
                if (value.UV.Value == Data.RendererCommonValues2.UVType.Default)
                {
                }
                // UV Fixed
                else if (value.UV.Value == Data.RendererCommonValues2.UVType.Fixed)
                {
                    var value_ = value.UVFixed;
                    data.Add((value_.Start.X / width).GetBytes());
                    data.Add((value_.Start.Y / height).GetBytes());
                    data.Add((value_.Size.X / width).GetBytes());
                    data.Add((value_.Size.Y / height).GetBytes());
                }
                // UV Animation
                else if (value.UV.Value == Data.RendererCommonValues2.UVType.Animation)
                {
                    var value_ = value.UVAnimation;
                    data.Add((value_.Start.X / width).GetBytes());
                    data.Add((value_.Start.Y / height).GetBytes());
                    data.Add((value_.Size.X / width).GetBytes());
                    data.Add((value_.Size.Y / height).GetBytes());

                    if (value_.FrameLength.Infinite)
                    {
                        var inf = int.MaxValue / 100;
                        data.Add(inf.GetBytes());
                    }
                    else
                    {
                        data.Add(value_.FrameLength.Value.Value.GetBytes());
                    }

                    data.Add(value_.FrameCountX.Value.GetBytes());
                    data.Add(value_.FrameCountY.Value.GetBytes());
                    data.Add(value_.LoopType);

                    data.Add(value_.StartSheet.Max.GetBytes());
                    data.Add(value_.StartSheet.Min.GetBytes());
                }
                // UV Scroll
                else if (value.UV.Value == Data.RendererCommonValues2.UVType.Scroll)
                {
                    var value_ = value.UVScroll;
                    data.Add((value_.Start.X.Max / width).GetBytes());
                    data.Add((value_.Start.Y.Max / height).GetBytes());
                    data.Add((value_.Start.X.Min / width).GetBytes());
                    data.Add((value_.Start.Y.Min / height).GetBytes());

                    data.Add((value_.Size.X.Max / width).GetBytes());
                    data.Add((value_.Size.Y.Max / height).GetBytes());
                    data.Add((value_.Size.X.Min / width).GetBytes());
                    data.Add((value_.Size.Y.Min / height).GetBytes());

                    data.Add((value_.Speed.X.Max / width).GetBytes());
                    data.Add((value_.Speed.Y.Max / height).GetBytes());
                    data.Add((value_.Speed.X.Min / width).GetBytes());
                    data.Add((value_.Speed.Y.Min / height).GetBytes());
                }
                // FCurve
                else if (value.UV.Value == Data.RendererCommonValues2.UVType.FCurve)
                {
                    {
                        var           value_ = value.UVFCurve.Start;
                        var           bytes1 = value_.GetBytes(1.0f / width);
                        List <byte[]> _data  = new List <byte[]>();
                        data.Add(bytes1);
                    }

                    {
                        var           value_ = value.UVFCurve.Size;
                        var           bytes1 = value_.GetBytes(1.0f / height);
                        List <byte[]> _data  = new List <byte[]>();
                        data.Add(bytes1);
                    }
                }
            }
            else
            {
                // None
                data.Add(((int)Data.RendererCommonValues.UVType.Default).GetBytes());
            }

            // [TODO] Distotion

            return(data.ToArray().ToArray());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomModel"/> class.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="loader">The loader.</param>
        public CustomModel(GraphicFactory factory, ObjectInformation[] loader)
            : base(factory, loader[0].modelName, false)
        {
            System.Diagnostics.Debug.Assert(loader!= null);
            System.Diagnostics.Debug.Assert(loader.Count() != 0);
            BatchInformations = new BatchInformation[1][];
            BatchInformations[0] = new BatchInformation[loader.Count()];

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[loader.Count()];

            BoundingSphere bs = new BoundingSphere();
            for (int i = 0; i < loader.Count(); i++)
            {
                BatchInformations[0][i] = loader[i].batchInformation;
                TextureInformations[0][i] = loader[i].textureInformation;

                float radius;
                Vector3 center;
                ModelBuilderHelper.ExtractModelRadiusAndCenter(BatchInformations[0][i], out radius, out center);
                bs = BoundingSphere.CreateMerged(bs, new BoundingSphere(center, radius));
            }            
            modelRadius = bs.Radius;
        }
        /// <summary>
        /// Loads the model.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="BatchInformations">The batch informations.</param>
        /// <param name="TextureInformations">The texture informations.</param>
        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformations)
        {
            //code not called !!!
            //Here for future usage.

            model = factory.GetModel(this.Name, isInternal);
            ModelBuilderHelper.Extract(model, out BatchInformations);
            
            BoundingSphere sphere = new BoundingSphere();
            foreach (var item in model.Meshes)
            {
                BoundingSphere.CreateMerged(sphere, item.BoundingSphere);
            }
            modelRadius = sphere.Radius;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[1];
            TextureInformations[0][0] = new TextureInformation(isInternal, factory);
            TextureInformations[0][0].LoadTexture();
        }
Example #28
0
        public static byte[] GetBytes(Data.RendererCommonValues value, Dictionary <string, int> texture_and_index, Dictionary <string, int> distortionTexture_and_index)
#endif
        {
            List <byte[]> data = new List <byte[]>();

            var texInfo    = new TextureInformation();
            var hasTexture = true;

#if MATERIAL_ENABLED
            data.Add(((int)value.Material.Value).GetBytes());


            if (value.Material.Value == Data.RendererCommonValues.MaterialType.Default)
            {
                // テクスチャ番号
                if (value.Distortion.Value)
                {
                    if (value.ColorTexture.RelativePath != string.Empty &&
                        distortionTexture_and_index.ContainsKey(value.ColorTexture.RelativePath) &&
                        texInfo.Load(value.ColorTexture.AbsolutePath))
                    {
                        data.Add(distortionTexture_and_index[value.ColorTexture.RelativePath].GetBytes());
                        hasTexture = true;
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                        hasTexture = false;
                    }
                }
                else
                {
                    if (value.ColorTexture.RelativePath != string.Empty &&
                        texture_and_index.ContainsKey(value.ColorTexture.RelativePath) &&
                        texInfo.Load(value.ColorTexture.AbsolutePath))
                    {
                        data.Add(texture_and_index[value.ColorTexture.RelativePath].GetBytes());
                        hasTexture = true;
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                        hasTexture = false;
                    }
                }
            }
            else
            {
                var materialInfo = new Utl.MaterialInformation();
                materialInfo.Load(value.MaterialFile.Path.AbsolutePath);

                var textures = value.MaterialFile.GetTextures(materialInfo);
                var uniforms = value.MaterialFile.GetUniforms(materialInfo);

                if (material_and_index.ContainsKey(value.MaterialFile.Path.RelativePath))
                {
                    data.Add(material_and_index[value.MaterialFile.Path.RelativePath].GetBytes());
                }
                else
                {
                    data.Add((-1).GetBytes());
                }

                data.Add(textures.Count.GetBytes());

                foreach (var texture in textures)
                {
                    if (texture.Item2)
                    {
                        if (texture.Item1.RelativePath != string.Empty &&
                            normalTexture_and_index.ContainsKey(texture.Item1.RelativePath) &&
                            texInfo.Load(texture.Item1.AbsolutePath))
                        {
                            data.Add((1).GetBytes());
                            data.Add(normalTexture_and_index[texture.Item1.RelativePath].GetBytes());
                            hasTexture = true;
                        }
                        else
                        {
                            data.Add((1).GetBytes());
                            data.Add((-1).GetBytes());
                            hasTexture = false;
                        }
                    }
                    else
                    {
                        if (texture.Item1.RelativePath != string.Empty &&
                            texture_and_index.ContainsKey(texture.Item1.RelativePath) &&
                            texInfo.Load(texture.Item1.AbsolutePath))
                        {
                            data.Add((0).GetBytes());
                            data.Add(texture_and_index[texture.Item1.RelativePath].GetBytes());
                            hasTexture = true;
                        }
                        else
                        {
                            data.Add((0).GetBytes());
                            data.Add((-1).GetBytes());
                            hasTexture = false;
                        }
                    }
                }

                data.Add(uniforms.Count.GetBytes());

                foreach (var uniform in uniforms)
                {
                    float[] floats = new float[4];

                    if (uniform is Data.Value.Float)
                    {
                        floats[0] = (uniform as Data.Value.Float).Value;
                    }

                    if (uniform is Data.Value.Vector2D)
                    {
                        floats[0] = (uniform as Data.Value.Vector2D).X.Value;
                        floats[1] = (uniform as Data.Value.Vector2D).Y.Value;
                    }

                    if (uniform is Data.Value.Vector3D)
                    {
                        floats[0] = (uniform as Data.Value.Vector3D).X.Value;
                        floats[1] = (uniform as Data.Value.Vector3D).Y.Value;
                        floats[2] = (uniform as Data.Value.Vector3D).Z.Value;
                    }

                    if (uniform is Data.Value.Vector4D)
                    {
                        floats[0] = (uniform as Data.Value.Vector4D).X.Value;
                        floats[1] = (uniform as Data.Value.Vector4D).Y.Value;
                        floats[2] = (uniform as Data.Value.Vector4D).Z.Value;
                        floats[3] = (uniform as Data.Value.Vector4D).W.Value;
                    }

                    data.Add(floats[0].GetBytes());
                    data.Add(floats[1].GetBytes());
                    data.Add(floats[2].GetBytes());
                    data.Add(floats[3].GetBytes());
                }
            }
#else
            // テクスチャ番号
            if (value.Distortion.Value)
            {
                if (value.ColorTexture.RelativePath != string.Empty &&
                    distortionTexture_and_index.ContainsKey(value.ColorTexture.RelativePath) &&
                    texInfo.Load(value.ColorTexture.AbsolutePath))
                {
                    data.Add(distortionTexture_and_index[value.ColorTexture.RelativePath].GetBytes());
                    hasTexture = true;
                }
                else
                {
                    data.Add((-1).GetBytes());
                    hasTexture = false;
                }
            }
            else
            {
                if (value.ColorTexture.RelativePath != string.Empty &&
                    texture_and_index.ContainsKey(value.ColorTexture.RelativePath) &&
                    texInfo.Load(value.ColorTexture.AbsolutePath))
                {
                    data.Add(texture_and_index[value.ColorTexture.RelativePath].GetBytes());
                    hasTexture = true;
                }
                else
                {
                    data.Add((-1).GetBytes());
                    hasTexture = false;
                }
            }
#endif

            data.Add(value.AlphaBlend);
            data.Add(value.Filter);
            data.Add(value.Wrap);

            if (value.ZTest.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            if (value.ZWrite.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            data.Add(value.FadeInType);
            if (value.FadeInType.Value == Data.RendererCommonValues.FadeType.Use)
            {
                data.Add(value.FadeIn.Frame.GetBytes());

                var easing = Utl.MathUtl.Easing((float)value.FadeIn.StartSpeed.Value, (float)value.FadeIn.EndSpeed.Value);
                data.Add(BitConverter.GetBytes(easing[0]));
                data.Add(BitConverter.GetBytes(easing[1]));
                data.Add(BitConverter.GetBytes(easing[2]));
            }

            data.Add(value.FadeOutType);
            if (value.FadeOutType.Value == Data.RendererCommonValues.FadeType.Use)
            {
                data.Add(value.FadeOut.Frame.GetBytes());

                var easing = Utl.MathUtl.Easing((float)value.FadeOut.StartSpeed.Value, (float)value.FadeOut.EndSpeed.Value);
                data.Add(BitConverter.GetBytes(easing[0]));
                data.Add(BitConverter.GetBytes(easing[1]));
                data.Add(BitConverter.GetBytes(easing[2]));
            }

            if (hasTexture)
            {
                var width  = (float)texInfo.Width;
                var height = (float)texInfo.Height;

                data.Add(value.UV);
                if (value.UV.Value == Data.RendererCommonValues.UVType.Default)
                {
                }
                else if (value.UV.Value == Data.RendererCommonValues.UVType.Fixed)
                {
                    var value_ = value.UVFixed;
                    data.Add((value_.Start.X / width).GetBytes());
                    data.Add((value_.Start.Y / height).GetBytes());
                    data.Add((value_.Size.X / width).GetBytes());
                    data.Add((value_.Size.Y / height).GetBytes());
                }
                else if (value.UV.Value == Data.RendererCommonValues.UVType.Animation)
                {
                    var value_ = value.UVAnimation;
                    data.Add((value_.Start.X / width).GetBytes());
                    data.Add((value_.Start.Y / height).GetBytes());
                    data.Add((value_.Size.X / width).GetBytes());
                    data.Add((value_.Size.Y / height).GetBytes());

                    if (value_.FrameLength.Infinite)
                    {
                        var inf = int.MaxValue / 100;
                        data.Add(inf.GetBytes());
                    }
                    else
                    {
                        data.Add(value_.FrameLength.Value.Value.GetBytes());
                    }

                    data.Add(value_.FrameCountX.Value.GetBytes());
                    data.Add(value_.FrameCountY.Value.GetBytes());
                    data.Add(value_.LoopType);

                    data.Add(value_.StartSheet.Max.GetBytes());
                    data.Add(value_.StartSheet.Min.GetBytes());
                }
                else if (value.UV.Value == Data.RendererCommonValues.UVType.Scroll)
                {
                    var value_ = value.UVScroll;
                    data.Add((value_.Start.X.Max / width).GetBytes());
                    data.Add((value_.Start.Y.Max / height).GetBytes());
                    data.Add((value_.Start.X.Min / width).GetBytes());
                    data.Add((value_.Start.Y.Min / height).GetBytes());

                    data.Add((value_.Size.X.Max / width).GetBytes());
                    data.Add((value_.Size.Y.Max / height).GetBytes());
                    data.Add((value_.Size.X.Min / width).GetBytes());
                    data.Add((value_.Size.Y.Min / height).GetBytes());

                    data.Add((value_.Speed.X.Max / width).GetBytes());
                    data.Add((value_.Speed.Y.Max / height).GetBytes());
                    data.Add((value_.Speed.X.Min / width).GetBytes());
                    data.Add((value_.Speed.Y.Min / height).GetBytes());
                }
                else if (value.UV.Value == Data.RendererCommonValues.UVType.FCurve)
                {
                    {
                        var           value_ = value.UVFCurve.Start;
                        var           bytes1 = value_.GetBytes(1.0f / width);
                        List <byte[]> _data  = new List <byte[]>();
                        data.Add(bytes1);
                    }

                    {
                        var           value_ = value.UVFCurve.Size;
                        var           bytes1 = value_.GetBytes(1.0f / height);
                        List <byte[]> _data  = new List <byte[]>();
                        data.Add(bytes1);
                    }
                }
            }
            else
            {
                data.Add(((int)Data.RendererCommonValues.UVType.Default).GetBytes());
            }

            // Inheritance
            data.Add(value.ColorInheritType.GetValueAsInt().GetBytes());

            // 歪み
            if (value.Distortion.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            data.Add(value.DistortionIntensity.GetBytes());

            return(data.ToArray().ToArray());
        }
Example #29
0
 protected abstract void GetSize(TextureInformation texInfo, out float width, out float height);
Example #30
0
        public static byte[] GetBytes(Data.RendererCommonValues value,
                                      Data.AdvancedRenderCommonValues advanceValue,
                                      Data.AdvancedRenderCommonValues2 advanceValue2,
                                      SortedDictionary <string, int> texture_and_index,
                                      SortedDictionary <string, int> normalTexture_and_index,
                                      SortedDictionary <string, int> distortionTexture_and_index,
                                      SortedDictionary <string, int> material_and_index,
                                      ExporterVersion version)
        {
            List <byte[]> data = new List <byte[]>();

            var texInfo = new TextureInformation();

            var alphaTexInfo = new TextureInformation();

            var uvDistortionTexInfo = new TextureInformation();

            var blendTexInfo = new TextureInformation();

            var blendAlphaTexInfo = new TextureInformation();

            var blendUVDistortionTexInfo = new TextureInformation();

            data.Add(((int)value.Material.Value).GetBytes());

            if (version >= ExporterVersion.Ver16Alpha1)
            {
                if (value.Material.Value == Data.RendererCommonValues.MaterialType.Default ||
                    value.Material.Value == Data.RendererCommonValues.MaterialType.Lighting)
                {
                    data.Add(BitConverter.GetBytes(value.EmissiveScaling));
                }
            }

            Func <Data.Value.PathForImage, int, SortedDictionary <string, int>, int> getTexIDAndStoreSize = (Data.Value.PathForImage image, int number, SortedDictionary <string, int> texAndInd) =>
            {
                var tempTexInfo = new TextureInformation();

                if (texAndInd.ContainsKey(image.RelativePath) && tempTexInfo.Load(image.AbsolutePath))
                {
                    if (value.UVTextureReferenceTarget.Value != Data.UVTextureReferenceTargetType.None && number == (int)value.UVTextureReferenceTarget.Value)
                    {
                        texInfo.Load(image.AbsolutePath);
                    }

                    return(texAndInd[image.RelativePath]);
                }
                else
                {
                    return(-1);
                }
            };

            GetTexIDAndInfo getTexIDAndInfo = (Data.Value.PathForImage image, SortedDictionary <string, int> texAndInd, ref TextureInformation texInfoRef) =>
            {
                var tempTexInfo = new TextureInformation();

                if (texAndInd.ContainsKey(image.RelativePath) && tempTexInfo.Load(image.AbsolutePath))
                {
                    texInfoRef.Load(image.AbsolutePath);
                    return(texAndInd[image.RelativePath]);
                }

                return(-1);
            };

            if (value.Material.Value == Data.RendererCommonValues.MaterialType.Default)
            {
                // texture1
                data.Add(getTexIDAndStoreSize(value.ColorTexture, 1, texture_and_index).GetBytes());

                // texture2
                data.Add((-1).GetBytes());

                if (version >= ExporterVersion.Ver16Alpha1)
                {
                    // alpha texture
                    if (advanceValue.EnableAlphaTexture)
                    {
                        data.Add(getTexIDAndInfo(advanceValue.AlphaTextureParam.Texture, texture_and_index, ref alphaTexInfo).GetBytes());
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                    }

                    // uv distortion texture
                    if (advanceValue.EnableUVDistortionTexture)
                    {
                        data.Add(getTexIDAndInfo(advanceValue.UVDistortionTextureParam.Texture, texture_and_index, ref uvDistortionTexInfo).GetBytes());
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                    }

                    // blend texture
                    if (advanceValue2.EnableBlendTexture)
                    {
                        data.Add(getTexIDAndInfo(advanceValue2.BlendTextureParams.BlendTextureParam.Texture, texture_and_index, ref blendTexInfo).GetBytes());

                        // blend alpha texture
                        if (advanceValue2.BlendTextureParams.EnableBlendAlphaTexture)
                        {
                            data.Add(getTexIDAndInfo(advanceValue2.BlendTextureParams.BlendAlphaTextureParam.Texture, texture_and_index, ref blendAlphaTexInfo).GetBytes());
                        }
                        else
                        {
                            data.Add((-1).GetBytes());
                        }

                        // blend uv distortion texture
                        if (advanceValue2.BlendTextureParams.EnableBlendUVDistortionTexture)
                        {
                            data.Add(getTexIDAndInfo(advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.Texture, texture_and_index, ref blendUVDistortionTexInfo).GetBytes());
                        }
                        else
                        {
                            data.Add((-1).GetBytes());
                        }
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                        data.Add((-1).GetBytes());
                        data.Add((-1).GetBytes());
                    }
                }
            }
            else if (value.Material.Value == Data.RendererCommonValues.MaterialType.BackDistortion)
            {
                // texture1
                data.Add(getTexIDAndStoreSize(value.ColorTexture, 1, distortionTexture_and_index).GetBytes());

                // texture2
                data.Add((-1).GetBytes());

                if (version >= ExporterVersion.Ver16Alpha1)
                {
                    // alpha texture
                    if (advanceValue.EnableAlphaTexture)
                    {
                        data.Add(getTexIDAndInfo(advanceValue.AlphaTextureParam.Texture, distortionTexture_and_index, ref alphaTexInfo).GetBytes());
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                    }

                    // uv distortion texture
                    if (advanceValue.EnableUVDistortionTexture)
                    {
                        data.Add(getTexIDAndInfo(advanceValue.UVDistortionTextureParam.Texture, distortionTexture_and_index, ref uvDistortionTexInfo).GetBytes());
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                    }

                    // blend texture
                    if (advanceValue2.EnableBlendTexture)
                    {
                        data.Add(getTexIDAndInfo(advanceValue2.BlendTextureParams.BlendTextureParam.Texture, distortionTexture_and_index, ref blendTexInfo).GetBytes());

                        // blend alpha texture
                        if (advanceValue2.BlendTextureParams.EnableBlendAlphaTexture)
                        {
                            data.Add(getTexIDAndInfo(advanceValue2.BlendTextureParams.BlendAlphaTextureParam.Texture, distortionTexture_and_index, ref blendAlphaTexInfo).GetBytes());
                        }
                        else
                        {
                            data.Add((-1).GetBytes());
                        }

                        // blend uv distortion texture
                        if (advanceValue2.BlendTextureParams.EnableBlendUVDistortionTexture)
                        {
                            data.Add(getTexIDAndInfo(advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.Texture, distortionTexture_and_index, ref blendUVDistortionTexInfo).GetBytes());
                        }
                        else
                        {
                            data.Add((-1).GetBytes());
                        }
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                        data.Add((-1).GetBytes());
                        data.Add((-1).GetBytes());
                    }
                }
            }
            else if (value.Material.Value == Data.RendererCommonValues.MaterialType.Lighting)
            {
                // texture1
                data.Add(getTexIDAndStoreSize(value.ColorTexture, 1, texture_and_index).GetBytes());

                // texture2
                data.Add(getTexIDAndStoreSize(value.NormalTexture, 2, normalTexture_and_index).GetBytes());

                if (version >= ExporterVersion.Ver16Alpha1)
                {
                    // alpha texture
                    if (advanceValue.EnableAlphaTexture)
                    {
                        data.Add(getTexIDAndInfo(advanceValue.AlphaTextureParam.Texture, texture_and_index, ref alphaTexInfo).GetBytes());
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                    }

                    // uv distortion texture
                    if (advanceValue.EnableUVDistortionTexture)
                    {
                        data.Add(getTexIDAndInfo(advanceValue.UVDistortionTextureParam.Texture, texture_and_index, ref uvDistortionTexInfo).GetBytes());
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                    }

                    // blend texture
                    if (advanceValue2.EnableBlendTexture)
                    {
                        data.Add(getTexIDAndInfo(advanceValue2.BlendTextureParams.BlendTextureParam.Texture, texture_and_index, ref blendTexInfo).GetBytes());

                        // blend alpha texture
                        if (advanceValue2.BlendTextureParams.EnableBlendAlphaTexture)
                        {
                            data.Add(getTexIDAndInfo(advanceValue2.BlendTextureParams.BlendAlphaTextureParam.Texture, texture_and_index, ref blendAlphaTexInfo).GetBytes());
                        }
                        else
                        {
                            data.Add((-1).GetBytes());
                        }

                        // blend uv distortion texture
                        if (advanceValue2.BlendTextureParams.EnableBlendUVDistortionTexture)
                        {
                            data.Add(getTexIDAndInfo(advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.Texture, texture_and_index, ref blendUVDistortionTexInfo).GetBytes());
                        }
                        else
                        {
                            data.Add((-1).GetBytes());
                        }
                    }
                    else
                    {
                        data.Add((-1).GetBytes());
                        data.Add((-1).GetBytes());
                        data.Add((-1).GetBytes());
                    }
                }
            }
            else
            {
                var materialInfo = Core.ResourceCache.LoadMaterialInformation(value.MaterialFile.Path.AbsolutePath);
                if (materialInfo == null)
                {
                    materialInfo = new MaterialInformation();
                }

                var textures = value.MaterialFile.GetTextures(materialInfo).Where(_ => _.Item1 != null).ToArray();
                var uniforms = value.MaterialFile.GetUniforms(materialInfo);

                // maximum slot limitation
                if (textures.Length > Constant.UserTextureSlotCount)
                {
                    textures = textures.Take(Constant.UserTextureSlotCount).ToArray();
                }

                if (material_and_index.ContainsKey(value.MaterialFile.Path.RelativePath))
                {
                    data.Add(material_and_index[value.MaterialFile.Path.RelativePath].GetBytes());
                }
                else
                {
                    data.Add((-1).GetBytes());
                }

                data.Add(textures.Length.GetBytes());

                foreach (var texture in textures)
                {
                    var texture_ = texture.Item1.Value as Data.Value.PathForImage;
                    if (texture.Item2.Type == TextureType.Value)
                    {
                        data.Add((1).GetBytes());
                        data.Add(getTexIDAndStoreSize(texture_, texture.Item2.Priority, normalTexture_and_index).GetBytes());
                    }
                    else
                    {
                        data.Add((0).GetBytes());
                        data.Add(getTexIDAndStoreSize(texture_, texture.Item2.Priority, texture_and_index).GetBytes());
                    }
                }

                data.Add(uniforms.Count.GetBytes());

                foreach (var uniform in uniforms)
                {
                    float[] floats = new float[4];

                    if (uniform.Item1 == null)
                    {
                        floats = uniform.Item2.DefaultValues.ToArray();
                    }
                    else if (uniform.Item1.Value is Data.Value.Float)
                    {
                        floats[0] = (uniform.Item1.Value as Data.Value.Float).Value;
                    }
                    else if (uniform.Item1.Value is Data.Value.Vector2D)
                    {
                        floats[0] = (uniform.Item1.Value as Data.Value.Vector2D).X.Value;
                        floats[1] = (uniform.Item1.Value as Data.Value.Vector2D).Y.Value;
                    }
                    else if (uniform.Item1.Value is Data.Value.Vector3D)
                    {
                        floats[0] = (uniform.Item1.Value as Data.Value.Vector3D).X.Value;
                        floats[1] = (uniform.Item1.Value as Data.Value.Vector3D).Y.Value;
                        floats[2] = (uniform.Item1.Value as Data.Value.Vector3D).Z.Value;
                    }
                    else if (uniform.Item1.Value is Data.Value.Vector4D)
                    {
                        floats[0] = (uniform.Item1.Value as Data.Value.Vector4D).X.Value;
                        floats[1] = (uniform.Item1.Value as Data.Value.Vector4D).Y.Value;
                        floats[2] = (uniform.Item1.Value as Data.Value.Vector4D).Z.Value;
                        floats[3] = (uniform.Item1.Value as Data.Value.Vector4D).W.Value;
                    }

                    data.Add(floats[0].GetBytes());
                    data.Add(floats[1].GetBytes());
                    data.Add(floats[2].GetBytes());
                    data.Add(floats[3].GetBytes());
                }
            }

            data.Add(value.AlphaBlend);
            data.Add(value.Filter);
            data.Add(value.Wrap);

            data.Add(value.Filter2);
            data.Add(value.Wrap2);

            if (version >= ExporterVersion.Ver16Alpha1)
            {
                data.Add(advanceValue.AlphaTextureParam.Filter);
                data.Add(advanceValue.AlphaTextureParam.Wrap);

                data.Add(advanceValue.UVDistortionTextureParam.Filter);
                data.Add(advanceValue.UVDistortionTextureParam.Wrap);

                data.Add(advanceValue2.BlendTextureParams.BlendTextureParam.Filter);
                data.Add(advanceValue2.BlendTextureParams.BlendTextureParam.Wrap);

                data.Add(advanceValue2.BlendTextureParams.BlendAlphaTextureParam.Filter);
                data.Add(advanceValue2.BlendTextureParams.BlendAlphaTextureParam.Wrap);

                data.Add(advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.Filter);
                data.Add(advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.Wrap);
            }

            if (value.ZTest.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            if (value.ZWrite.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            data.Add(value.FadeInType);
            if (value.FadeInType.Value == Data.RendererCommonValues.FadeType.Use)
            {
                data.Add(value.FadeIn.Frame.GetBytes());

                var easing = Utl.MathUtl.Easing((float)value.FadeIn.StartSpeed.Value, (float)value.FadeIn.EndSpeed.Value);
                data.Add(BitConverter.GetBytes(easing[0]));
                data.Add(BitConverter.GetBytes(easing[1]));
                data.Add(BitConverter.GetBytes(easing[2]));
            }

            data.Add(value.FadeOutType);
            if (value.FadeOutType.Value == Data.RendererCommonValues.FadeType.Use)
            {
                data.Add(value.FadeOut.Frame.GetBytes());

                var easing = Utl.MathUtl.Easing((float)value.FadeOut.StartSpeed.Value, (float)value.FadeOut.EndSpeed.Value);
                data.Add(BitConverter.GetBytes(easing[0]));
                data.Add(BitConverter.GetBytes(easing[1]));
                data.Add(BitConverter.GetBytes(easing[2]));
            }

            // sprcification change(1.5)
            float width  = 128.0f;
            float height = 128.0f;

            if (texInfo.Width > 0 && texInfo.Height > 0)
            {
                width  = (float)texInfo.Width;
                height = (float)texInfo.Height;
            }

            data.Add(value.UV);
            if (value.UV.Value == Data.RendererCommonValues.UVType.Default)
            {
            }
            else if (value.UV.Value == Data.RendererCommonValues.UVType.Fixed)
            {
                var value_ = value.UVFixed;
                data.Add((value_.Start.X / width).GetBytes());
                data.Add((value_.Start.Y / height).GetBytes());
                data.Add((value_.Size.X / width).GetBytes());
                data.Add((value_.Size.Y / height).GetBytes());
            }
            else if (value.UV.Value == Data.RendererCommonValues.UVType.Animation)
            {
                var value_ = value.UVAnimation;

                data.Add((value_.AnimationParams.Start.X / width).GetBytes());
                data.Add((value_.AnimationParams.Start.Y / height).GetBytes());
                data.Add((value_.AnimationParams.Size.X / width).GetBytes());
                data.Add((value_.AnimationParams.Size.Y / height).GetBytes());

                if (value_.AnimationParams.FrameLength.Infinite)
                {
                    var inf = int.MaxValue / 100;
                    data.Add(inf.GetBytes());
                }
                else
                {
                    data.Add(value_.AnimationParams.FrameLength.Value.Value.GetBytes());
                }

                data.Add(value_.AnimationParams.FrameCountX.Value.GetBytes());
                data.Add(value_.AnimationParams.FrameCountY.Value.GetBytes());
                data.Add(value_.AnimationParams.LoopType);

                data.Add(value_.AnimationParams.StartSheet.Max.GetBytes());
                data.Add(value_.AnimationParams.StartSheet.Min.GetBytes());

                data.Add(value_.FlipbookInterpolationType);
            }
            else if (value.UV.Value == Data.RendererCommonValues.UVType.Scroll)
            {
                var value_ = value.UVScroll;
                data.Add((value_.Start.X.Max / width).GetBytes());
                data.Add((value_.Start.Y.Max / height).GetBytes());
                data.Add((value_.Start.X.Min / width).GetBytes());
                data.Add((value_.Start.Y.Min / height).GetBytes());

                data.Add((value_.Size.X.Max / width).GetBytes());
                data.Add((value_.Size.Y.Max / height).GetBytes());
                data.Add((value_.Size.X.Min / width).GetBytes());
                data.Add((value_.Size.Y.Min / height).GetBytes());

                data.Add((value_.Speed.X.Max / width).GetBytes());
                data.Add((value_.Speed.Y.Max / height).GetBytes());
                data.Add((value_.Speed.X.Min / width).GetBytes());
                data.Add((value_.Speed.Y.Min / height).GetBytes());
            }
            else if (value.UV.Value == Data.RendererCommonValues.UVType.FCurve)
            {
                {
                    var           value_ = value.UVFCurve.Start;
                    var           bytes1 = value_.GetBytes(1.0f / width, 1.0f / height);
                    List <byte[]> _data  = new List <byte[]>();
                    data.Add(bytes1);
                }

                {
                    var           value_ = value.UVFCurve.Size;
                    var           bytes1 = value_.GetBytes(1.0f / width, 1.0f / height);
                    List <byte[]> _data  = new List <byte[]>();
                    data.Add(bytes1);
                }
            }


            if (version >= ExporterVersion.Ver16Alpha1)
            {
                // alpha texture
                data.Add(GetUVBytes
                         (
                             alphaTexInfo,
                             advanceValue.AlphaTextureParam.UV,
                             advanceValue.AlphaTextureParam.UVFixed,
                             advanceValue.AlphaTextureParam.UVAnimation,
                             advanceValue.AlphaTextureParam.UVScroll,
                             advanceValue.AlphaTextureParam.UVFCurve
                         ));

                // uv distortion texture
                data.Add(GetUVBytes
                         (
                             uvDistortionTexInfo,
                             advanceValue.UVDistortionTextureParam.UV,
                             advanceValue.UVDistortionTextureParam.UVFixed,
                             advanceValue.UVDistortionTextureParam.UVAnimation,
                             advanceValue.UVDistortionTextureParam.UVScroll,
                             advanceValue.UVDistortionTextureParam.UVFCurve
                         ));

                // uv distortion intensity
                data.Add((advanceValue.UVDistortionTextureParam.UVDistortionIntensity).GetBytes());

                // blend texture
                data.Add(GetUVBytes
                         (
                             blendTexInfo,
                             advanceValue2.BlendTextureParams.BlendTextureParam.UV,
                             advanceValue2.BlendTextureParams.BlendTextureParam.UVFixed,
                             advanceValue2.BlendTextureParams.BlendTextureParam.UVAnimation,
                             advanceValue2.BlendTextureParams.BlendTextureParam.UVScroll,
                             advanceValue2.BlendTextureParams.BlendTextureParam.UVFCurve
                         ));

                // blend texture blend type
                if (advanceValue2.EnableBlendTexture && advanceValue2.BlendTextureParams.BlendTextureParam.Texture.RelativePath != string.Empty)
                {
                    data.Add(advanceValue2.BlendTextureParams.BlendTextureParam.BlendType);
                }
                else
                {
                    data.Add((-1).GetBytes());
                }

                // blend alpha texture
                data.Add(GetUVBytes
                         (
                             blendAlphaTexInfo,
                             advanceValue2.BlendTextureParams.BlendAlphaTextureParam.UV,
                             advanceValue2.BlendTextureParams.BlendAlphaTextureParam.UVFixed,
                             advanceValue2.BlendTextureParams.BlendAlphaTextureParam.UVAnimation,
                             advanceValue2.BlendTextureParams.BlendAlphaTextureParam.UVScroll,
                             advanceValue2.BlendTextureParams.BlendAlphaTextureParam.UVFCurve
                         ));

                // blend uv distoriton texture
                data.Add(GetUVBytes
                         (
                             blendUVDistortionTexInfo,
                             advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.UV,
                             advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.UVFixed,
                             advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.UVAnimation,
                             advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.UVScroll,
                             advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.UVFCurve
                         ));

                // blend uv distoriton intensity
                data.Add((advanceValue2.BlendTextureParams.BlendUVDistortionTextureParam.UVDistortionIntensity).GetBytes());
            }


            // Inheritance
            data.Add(value.ColorInheritType.GetValueAsInt().GetBytes());

            // Distortion
            data.Add(value.DistortionIntensity.GetBytes());

            // Custom data1 from 1.5
            data.Add(value.CustomData1.CustomData);
            if (value.CustomData1.CustomData.Value == Data.CustomDataType.Fixed2D)
            {
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed.X.Value));
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed.Y.Value));
            }
            else if (value.CustomData1.CustomData.Value == Data.CustomDataType.Random2D)
            {
                var value_ = value.CustomData1.Random;
                var bytes1 = value_.GetBytes(1.0f);
                data.Add(bytes1);
            }
            else if (value.CustomData1.CustomData.Value == Data.CustomDataType.Easing2D)
            {
                var easing = Utl.MathUtl.Easing((float)value.CustomData1.Easing.StartSpeed.Value, (float)value.CustomData1.Easing.EndSpeed.Value);

                List <byte[]> _data = new List <byte[]>();
                _data.Add(value.CustomData1.Easing.Start.GetBytes(1.0f));
                _data.Add(value.CustomData1.Easing.End.GetBytes(1.0f));
                _data.Add(BitConverter.GetBytes(easing[0]));
                _data.Add(BitConverter.GetBytes(easing[1]));
                _data.Add(BitConverter.GetBytes(easing[2]));
                var __data = _data.ToArray().ToArray();
                data.Add(__data);
            }
            else if (value.CustomData1.CustomData.Value == Data.CustomDataType.FCurve2D)
            {
                var value_ = value.CustomData1.FCurve;
                var bytes1 = value_.GetBytes();
                data.Add(bytes1);
            }
            else if (value.CustomData1.CustomData.Value == Data.CustomDataType.Fixed4D)
            {
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.X.Value));
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.Y.Value));
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.Z.Value));
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.W.Value));
            }
            else if (value.CustomData1.CustomData.Value == Data.CustomDataType.FCurveColor)
            {
                var bytes = value.CustomData1.FCurveColor.GetBytes();
                data.Add(bytes);
            }

            // Custom data2 from 1.5
            data.Add(value.CustomData2.CustomData);
            if (value.CustomData2.CustomData.Value == Data.CustomDataType.Fixed2D)
            {
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed.X.Value));
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed.Y.Value));
            }
            else if (value.CustomData2.CustomData.Value == Data.CustomDataType.Random2D)
            {
                var value_ = value.CustomData2.Random;
                var bytes1 = value_.GetBytes(1.0f);
                data.Add(bytes1);
            }
            else if (value.CustomData2.CustomData.Value == Data.CustomDataType.Easing2D)
            {
                var easing = Utl.MathUtl.Easing((float)value.CustomData2.Easing.StartSpeed.Value, (float)value.CustomData2.Easing.EndSpeed.Value);

                List <byte[]> _data = new List <byte[]>();
                _data.Add(value.CustomData2.Easing.Start.GetBytes(1.0f));
                _data.Add(value.CustomData2.Easing.End.GetBytes(1.0f));
                _data.Add(BitConverter.GetBytes(easing[0]));
                _data.Add(BitConverter.GetBytes(easing[1]));
                _data.Add(BitConverter.GetBytes(easing[2]));
                var __data = _data.ToArray().ToArray();
                data.Add(__data);
            }
            else if (value.CustomData2.CustomData.Value == Data.CustomDataType.FCurve2D)
            {
                var value_ = value.CustomData2.FCurve;
                var bytes1 = value_.GetBytes();
                data.Add(bytes1);
            }
            else if (value.CustomData2.CustomData.Value == Data.CustomDataType.Fixed4D)
            {
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.X.Value));
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.Y.Value));
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.Z.Value));
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.W.Value));
            }
            else if (value.CustomData2.CustomData.Value == Data.CustomDataType.FCurveColor)
            {
                var bytes = value.CustomData2.FCurveColor.GetBytes();
                data.Add(bytes);
            }

            if (version >= ExporterVersion.Ver16Alpha1)
            {
                data.Add(AlphaCutoffValues.GetBytes(advanceValue.AlphaCutoffParam, version));
            }

            if (version >= ExporterVersion.Ver16Alpha3)
            {
                if (advanceValue.EnableFalloff)
                {
                    data.Add((1).GetBytes());

                    data.Add(advanceValue.FalloffParam.ColorBlendType);
                    data.Add(advanceValue.FalloffParam.BeginColor);
                    data.Add(advanceValue.FalloffParam.EndColor);
                    data.Add(BitConverter.GetBytes(advanceValue.FalloffParam.Pow.Value));
                }
                else
                {
                    data.Add((0).GetBytes());
                }
            }

            if (version >= ExporterVersion.Ver16Alpha4)
            {
                data.Add(advanceValue.SoftParticleDistance.GetBytes());
            }

            if (version >= ExporterVersion.Ver16Alpha5)
            {
                data.Add(advanceValue.SoftParticleDistanceNear.GetBytes());
                data.Add(advanceValue.SoftParticleDistanceNearOffset.GetBytes());
            }

            return(data.ToArray().ToArray());
        }
        public static byte[] GetBytes(Data.RendererCommonValues value, Dictionary <string, int> texture_and_index, Dictionary <string, int> distortionTexture_and_index)
        {
            List <byte[]> data = new List <byte[]>();

            var texInfo    = new TextureInformation();
            var hasTexture = true;

            // テクスチャ番号
            if (value.Distortion.Value)
            {
                if (value.ColorTexture.RelativePath != string.Empty &&
                    distortionTexture_and_index.ContainsKey(value.ColorTexture.RelativePath) &&
                    texInfo.Load(value.ColorTexture.AbsolutePath))
                {
                    data.Add(distortionTexture_and_index[value.ColorTexture.RelativePath].GetBytes());
                    hasTexture = true;
                }
                else
                {
                    data.Add((-1).GetBytes());
                    hasTexture = false;
                }
            }
            else
            {
                if (value.ColorTexture.RelativePath != string.Empty &&
                    texture_and_index.ContainsKey(value.ColorTexture.RelativePath) &&
                    texInfo.Load(value.ColorTexture.AbsolutePath))
                {
                    data.Add(texture_and_index[value.ColorTexture.RelativePath].GetBytes());
                    hasTexture = true;
                }
                else
                {
                    data.Add((-1).GetBytes());
                    hasTexture = false;
                }
            }


            data.Add(value.AlphaBlend);
            data.Add(value.Filter);
            data.Add(value.Wrap);

            if (value.ZTest.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            if (value.ZWrite.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            data.Add(value.FadeInType);
            if (value.FadeInType.Value == Data.RendererCommonValues.FadeType.Use)
            {
                data.Add(value.FadeIn.Frame.GetBytes());

                var easing = Utl.MathUtl.Easing((float)value.FadeIn.StartSpeed.Value, (float)value.FadeIn.EndSpeed.Value);
                data.Add(BitConverter.GetBytes(easing[0]));
                data.Add(BitConverter.GetBytes(easing[1]));
                data.Add(BitConverter.GetBytes(easing[2]));
            }

            data.Add(value.FadeOutType);
            if (value.FadeOutType.Value == Data.RendererCommonValues.FadeType.Use)
            {
                data.Add(value.FadeOut.Frame.GetBytes());

                var easing = Utl.MathUtl.Easing((float)value.FadeOut.StartSpeed.Value, (float)value.FadeOut.EndSpeed.Value);
                data.Add(BitConverter.GetBytes(easing[0]));
                data.Add(BitConverter.GetBytes(easing[1]));
                data.Add(BitConverter.GetBytes(easing[2]));
            }

            if (hasTexture)
            {
                var width  = (float)texInfo.Width;
                var height = (float)texInfo.Height;

                data.Add(value.UV);
                if (value.UV.Value == Data.RendererCommonValues.UVType.Default)
                {
                }
                else if (value.UV.Value == Data.RendererCommonValues.UVType.Fixed)
                {
                    var value_ = value.UVFixed;
                    data.Add((value_.Start.X / width).GetBytes());
                    data.Add((value_.Start.Y / height).GetBytes());
                    data.Add((value_.Size.X / width).GetBytes());
                    data.Add((value_.Size.Y / height).GetBytes());
                }
                else if (value.UV.Value == Data.RendererCommonValues.UVType.Animation)
                {
                    var value_ = value.UVAnimation;
                    data.Add((value_.Start.X / width).GetBytes());
                    data.Add((value_.Start.Y / height).GetBytes());
                    data.Add((value_.Size.X / width).GetBytes());
                    data.Add((value_.Size.Y / height).GetBytes());

                    if (value_.FrameLength.Infinite)
                    {
                        var inf = int.MaxValue / 100;
                        data.Add(inf.GetBytes());
                    }
                    else
                    {
                        data.Add(value_.FrameLength.Value.Value.GetBytes());
                    }

                    data.Add(value_.FrameCountX.Value.GetBytes());
                    data.Add(value_.FrameCountY.Value.GetBytes());
                    data.Add(value_.LoopType);

                    data.Add(value_.StartSheet.Max.GetBytes());
                    data.Add(value_.StartSheet.Min.GetBytes());
                }
                else if (value.UV.Value == Data.RendererCommonValues.UVType.Scroll)
                {
                    var value_ = value.UVScroll;
                    data.Add((value_.Start.X.Max / width).GetBytes());
                    data.Add((value_.Start.Y.Max / height).GetBytes());
                    data.Add((value_.Start.X.Min / width).GetBytes());
                    data.Add((value_.Start.Y.Min / height).GetBytes());

                    data.Add((value_.Size.X.Max / width).GetBytes());
                    data.Add((value_.Size.Y.Max / height).GetBytes());
                    data.Add((value_.Size.X.Min / width).GetBytes());
                    data.Add((value_.Size.Y.Min / height).GetBytes());

                    data.Add((value_.Speed.X.Max / width).GetBytes());
                    data.Add((value_.Speed.Y.Max / height).GetBytes());
                    data.Add((value_.Speed.X.Min / width).GetBytes());
                    data.Add((value_.Speed.Y.Min / height).GetBytes());
                }
            }
            else
            {
                data.Add(((int)Data.RendererCommonValues.UVType.Default).GetBytes());
            }

            // Inheritance
            data.Add(value.ColorInheritType.GetValueAsInt().GetBytes());

            // 歪み
            if (value.Distortion.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            data.Add(value.DistortionIntensity.GetBytes());

            return(data.ToArray().ToArray());
        }
        /// <summary>
        /// Loads the model.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="BatchInformations">The batch informations.</param>
        /// <param name="TextureInformations">The texture informations.</param>
        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformations)
        {
            VertexPositionTexture[] billboardVertices = new VertexPositionTexture[4];
            int i = 0;
            
            billboardVertices[i++] = new VertexPositionTexture(Vector3.Zero, new Vector2(0, 0));
            billboardVertices[i++] = new VertexPositionTexture(Vector3.Zero, new Vector2(1, 0));
            billboardVertices[i++] = new VertexPositionTexture(Vector3.Zero, new Vector2(0, 1));
            billboardVertices[i++] = new VertexPositionTexture(Vector3.Zero, new Vector2(1, 1));

            VertexElement v0 = new VertexElement(0,VertexElementFormat.Vector3,VertexElementUsage.TextureCoordinate,1);
            VertexElement v1 = new VertexElement(sizeof(float) * 3,VertexElementFormat.Vector2,VertexElementUsage.TextureCoordinate,2);

             vd = new VertexDeclaration(v0, v1);

             VertexBuffer InstancedvertexBufferS;
             if (dynamicBufferSize != -1)
             {
                 InstancedvertexBufferS = factory.CreateDynamicVertexBuffer(vd, dynamicBufferSize, BufferUsage.WriteOnly);
             }
             else
             {
                 InstancedvertexBufferS = factory.CreateDynamicVertexBuffer(vd, instances.Count(), BufferUsage.WriteOnly);
             }            
        
            InstancedvertexBufferS.SetData(instances);

            VertexBuffer vertexBufferS = factory.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, billboardVertices.Count(), BufferUsage.WriteOnly);
            vertexBufferS.SetData(billboardVertices);

            short[] indices = new short[] { 0,2,1,1,2,3};

            IndexBuffer indexBufferS = factory.CreateIndexBuffer(IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
            indexBufferS.SetData<short>(indices);
            
            BatchInformations = new BatchInformation[1][];
            BatchInformation[] b = new BatchInformation[1];
            b[0] = new BatchInformation(0, 4, 2, 0, 0, VertexPositionTexture.VertexDeclaration, VertexPositionTexture.VertexDeclaration.VertexStride,instances.Count());
            b[0].VertexBuffer = vertexBufferS;
            b[0].IndexBuffer = indexBufferS;
            b[0].InstancedVertexBuffer = InstancedvertexBufferS;
            BatchInformations[0] = b;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[1];
            TextureInformations[0][0] = new TextureInformation(isInternal, factory, diffuseTextureName, null, null, null);
            TextureInformations[0][0].LoadTexture();
        }
 public StoneConverterMachine(IMod owner, string rawName, TextureInformation textureInfo) : base(owner, rawName, 500, textureInfo)
 {
 }
Example #34
0
        public static byte[] GetBytes(Data.RendererCommonValues value, Dictionary <string, int> texture_and_index, Dictionary <string, int> normalTexture_and_index, Dictionary <string, int> distortionTexture_and_index, Dictionary <string, int> material_and_index)

        {
            List <byte[]> data = new List <byte[]>();

            var texInfo = new TextureInformation();

            data.Add(((int)value.Material.Value).GetBytes());

            Func <Data.Value.PathForImage, int, Dictionary <string, int>, int> getTexIDAndStoreSize = (Data.Value.PathForImage image, int number, Dictionary <string, int> texAndInd) =>
            {
                var tempTexInfo = new TextureInformation();

                if (texAndInd.ContainsKey(image.RelativePath) && tempTexInfo.Load(image.AbsolutePath))
                {
                    if (value.UVTextureReferenceTarget.Value != Data.UVTextureReferenceTargetType.None && number == (int)value.UVTextureReferenceTarget.Value)
                    {
                        texInfo.Load(image.AbsolutePath);
                    }

                    return(texAndInd[image.RelativePath]);
                }
                else
                {
                    return(-1);
                }
            };

            if (value.Material.Value == Data.RendererCommonValues.MaterialType.Default)
            {
                // texture1
                data.Add(getTexIDAndStoreSize(value.ColorTexture, 1, texture_and_index).GetBytes());

                // texture2
                data.Add((-1).GetBytes());
            }
            else if (value.Material.Value == Data.RendererCommonValues.MaterialType.BackDistortion)
            {
                // texture1
                data.Add(getTexIDAndStoreSize(value.ColorTexture, 1, distortionTexture_and_index).GetBytes());

                // texture2
                data.Add((-1).GetBytes());
            }
            else if (value.Material.Value == Data.RendererCommonValues.MaterialType.Lighting)
            {
                // texture1
                data.Add(getTexIDAndStoreSize(value.ColorTexture, 1, texture_and_index).GetBytes());

                // texture2
                data.Add(getTexIDAndStoreSize(value.NormalTexture, 2, normalTexture_and_index).GetBytes());
            }
            else
            {
                var materialInfo = new Utl.MaterialInformation();
                materialInfo.Load(value.MaterialFile.Path.AbsolutePath);

                var textures = value.MaterialFile.GetTextures(materialInfo).Where(_ => _.Item1 != null).ToArray();
                var uniforms = value.MaterialFile.GetUniforms(materialInfo);

                // maximum slot limitation
                if (textures.Length > Constant.UserTextureSlotCount)
                {
                    textures = textures.Take(Constant.UserTextureSlotCount).ToArray();
                }

                if (material_and_index.ContainsKey(value.MaterialFile.Path.RelativePath))
                {
                    data.Add(material_and_index[value.MaterialFile.Path.RelativePath].GetBytes());
                }
                else
                {
                    data.Add((-1).GetBytes());
                }

                data.Add(textures.Length.GetBytes());

                foreach (var texture in textures)
                {
                    var texture_ = texture.Item1.Value as Data.Value.PathForImage;
                    if (texture.Item2.Type == TextureType.Value)
                    {
                        data.Add((1).GetBytes());
                        data.Add(getTexIDAndStoreSize(texture_, texture.Item2.Priority, normalTexture_and_index).GetBytes());
                    }
                    else
                    {
                        data.Add((0).GetBytes());
                        data.Add(getTexIDAndStoreSize(texture_, texture.Item2.Priority, texture_and_index).GetBytes());
                    }
                }

                data.Add(uniforms.Count.GetBytes());

                foreach (var uniform in uniforms)
                {
                    float[] floats = new float[4];

                    if (uniform.Item1 == null)
                    {
                        floats = uniform.Item2.DefaultValues.ToArray();
                    }
                    else if (uniform.Item1.Value is Data.Value.Float)
                    {
                        floats[0] = (uniform.Item1.Value as Data.Value.Float).Value;
                    }
                    else if (uniform.Item1.Value is Data.Value.Vector4D)
                    {
                        floats[0] = (uniform.Item1.Value as Data.Value.Vector4D).X.Value;
                        floats[1] = (uniform.Item1.Value as Data.Value.Vector4D).Y.Value;
                        floats[2] = (uniform.Item1.Value as Data.Value.Vector4D).Z.Value;
                        floats[3] = (uniform.Item1.Value as Data.Value.Vector4D).W.Value;
                    }

                    data.Add(floats[0].GetBytes());
                    data.Add(floats[1].GetBytes());
                    data.Add(floats[2].GetBytes());
                    data.Add(floats[3].GetBytes());
                }
            }

            data.Add(value.AlphaBlend);
            data.Add(value.Filter);
            data.Add(value.Wrap);

            data.Add(value.Filter2);
            data.Add(value.Wrap2);

            if (value.ZTest.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            if (value.ZWrite.GetValue())
            {
                data.Add((1).GetBytes());
            }
            else
            {
                data.Add((0).GetBytes());
            }

            data.Add(value.FadeInType);
            if (value.FadeInType.Value == Data.RendererCommonValues.FadeType.Use)
            {
                data.Add(value.FadeIn.Frame.GetBytes());

                var easing = Utl.MathUtl.Easing((float)value.FadeIn.StartSpeed.Value, (float)value.FadeIn.EndSpeed.Value);
                data.Add(BitConverter.GetBytes(easing[0]));
                data.Add(BitConverter.GetBytes(easing[1]));
                data.Add(BitConverter.GetBytes(easing[2]));
            }

            data.Add(value.FadeOutType);
            if (value.FadeOutType.Value == Data.RendererCommonValues.FadeType.Use)
            {
                data.Add(value.FadeOut.Frame.GetBytes());

                var easing = Utl.MathUtl.Easing((float)value.FadeOut.StartSpeed.Value, (float)value.FadeOut.EndSpeed.Value);
                data.Add(BitConverter.GetBytes(easing[0]));
                data.Add(BitConverter.GetBytes(easing[1]));
                data.Add(BitConverter.GetBytes(easing[2]));
            }

            // sprcification change(1.5)
            float width  = 128.0f;
            float height = 128.0f;

            if (texInfo.Width > 0 && texInfo.Height > 0)
            {
                width  = (float)texInfo.Width;
                height = (float)texInfo.Height;
            }

            data.Add(value.UV);
            if (value.UV.Value == Data.RendererCommonValues.UVType.Default)
            {
            }
            else if (value.UV.Value == Data.RendererCommonValues.UVType.Fixed)
            {
                var value_ = value.UVFixed;
                data.Add((value_.Start.X / width).GetBytes());
                data.Add((value_.Start.Y / height).GetBytes());
                data.Add((value_.Size.X / width).GetBytes());
                data.Add((value_.Size.Y / height).GetBytes());
            }
            else if (value.UV.Value == Data.RendererCommonValues.UVType.Animation)
            {
                var value_ = value.UVAnimation;
                data.Add((value_.Start.X / width).GetBytes());
                data.Add((value_.Start.Y / height).GetBytes());
                data.Add((value_.Size.X / width).GetBytes());
                data.Add((value_.Size.Y / height).GetBytes());

                if (value_.FrameLength.Infinite)
                {
                    var inf = int.MaxValue / 100;
                    data.Add(inf.GetBytes());
                }
                else
                {
                    data.Add(value_.FrameLength.Value.Value.GetBytes());
                }

                data.Add(value_.FrameCountX.Value.GetBytes());
                data.Add(value_.FrameCountY.Value.GetBytes());
                data.Add(value_.LoopType);

                data.Add(value_.StartSheet.Max.GetBytes());
                data.Add(value_.StartSheet.Min.GetBytes());
            }
            else if (value.UV.Value == Data.RendererCommonValues.UVType.Scroll)
            {
                var value_ = value.UVScroll;
                data.Add((value_.Start.X.Max / width).GetBytes());
                data.Add((value_.Start.Y.Max / height).GetBytes());
                data.Add((value_.Start.X.Min / width).GetBytes());
                data.Add((value_.Start.Y.Min / height).GetBytes());

                data.Add((value_.Size.X.Max / width).GetBytes());
                data.Add((value_.Size.Y.Max / height).GetBytes());
                data.Add((value_.Size.X.Min / width).GetBytes());
                data.Add((value_.Size.Y.Min / height).GetBytes());

                data.Add((value_.Speed.X.Max / width).GetBytes());
                data.Add((value_.Speed.Y.Max / height).GetBytes());
                data.Add((value_.Speed.X.Min / width).GetBytes());
                data.Add((value_.Speed.Y.Min / height).GetBytes());
            }
            else if (value.UV.Value == Data.RendererCommonValues.UVType.FCurve)
            {
                {
                    var           value_ = value.UVFCurve.Start;
                    var           bytes1 = value_.GetBytes(1.0f / width);
                    List <byte[]> _data  = new List <byte[]>();
                    data.Add(bytes1);
                }

                {
                    var           value_ = value.UVFCurve.Size;
                    var           bytes1 = value_.GetBytes(1.0f / height);
                    List <byte[]> _data  = new List <byte[]>();
                    data.Add(bytes1);
                }
            }


            // Inheritance
            data.Add(value.ColorInheritType.GetValueAsInt().GetBytes());

            // Distortion
            data.Add(value.DistortionIntensity.GetBytes());

            // Custom data1 from 1.5
            data.Add(value.CustomData1.CustomData);
            if (value.CustomData1.CustomData.Value == Data.CustomDataType.Fixed2D)
            {
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed.X.Value));
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed.Y.Value));
            }
            else if (value.CustomData1.CustomData.Value == Data.CustomDataType.Easing2D)
            {
                var easing = Utl.MathUtl.Easing((float)value.CustomData1.Easing.StartSpeed.Value, (float)value.CustomData1.Easing.EndSpeed.Value);

                List <byte[]> _data = new List <byte[]>();
                _data.Add(value.CustomData1.Easing.Start.GetBytes(1.0f));
                _data.Add(value.CustomData1.Easing.End.GetBytes(1.0f));
                _data.Add(BitConverter.GetBytes(easing[0]));
                _data.Add(BitConverter.GetBytes(easing[1]));
                _data.Add(BitConverter.GetBytes(easing[2]));
                var __data = _data.ToArray().ToArray();
                data.Add(__data);
            }
            else if (value.CustomData1.CustomData.Value == Data.CustomDataType.FCurve2D)
            {
                var value_ = value.CustomData1.FCurve;
                var bytes1 = value_.GetBytes(1.0f);
                data.Add(bytes1);
            }
            else if (value.CustomData1.CustomData.Value == Data.CustomDataType.Fixed4D)
            {
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.X.Value));
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.Y.Value));
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.Z.Value));
                data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.W.Value));
            }
            else if (value.CustomData1.CustomData.Value == Data.CustomDataType.FCurveColor)
            {
                var bytes = value.CustomData1.FCurveColor.GetBytes();
                data.Add(bytes);
            }

            // Custom data2 from 1.5
            data.Add(value.CustomData2.CustomData);
            if (value.CustomData2.CustomData.Value == Data.CustomDataType.Fixed2D)
            {
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed.X.Value));
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed.Y.Value));
            }
            else if (value.CustomData2.CustomData.Value == Data.CustomDataType.Easing2D)
            {
                var easing = Utl.MathUtl.Easing((float)value.CustomData2.Easing.StartSpeed.Value, (float)value.CustomData2.Easing.EndSpeed.Value);

                List <byte[]> _data = new List <byte[]>();
                _data.Add(value.CustomData2.Easing.Start.GetBytes(1.0f));
                _data.Add(value.CustomData2.Easing.End.GetBytes(1.0f));
                _data.Add(BitConverter.GetBytes(easing[0]));
                _data.Add(BitConverter.GetBytes(easing[1]));
                _data.Add(BitConverter.GetBytes(easing[2]));
                var __data = _data.ToArray().ToArray();
                data.Add(__data);
            }
            else if (value.CustomData2.CustomData.Value == Data.CustomDataType.FCurve2D)
            {
                var value_ = value.CustomData2.FCurve;
                var bytes1 = value_.GetBytes(1.0f);
                data.Add(bytes1);
            }
            else if (value.CustomData2.CustomData.Value == Data.CustomDataType.Fixed4D)
            {
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.X.Value));
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.Y.Value));
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.Z.Value));
                data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.W.Value));
            }
            else if (value.CustomData2.CustomData.Value == Data.CustomDataType.FCurveColor)
            {
                var bytes = value.CustomData2.FCurveColor.GetBytes();
                data.Add(bytes);
            }

            return(data.ToArray().ToArray());
        }
Example #35
0
 public static TextureInformation[] GetTextureInformationsById(string id)
 {
     List<TextureInformation> result = new List<TextureInformation>();
     SQLiteConnection con = GetConnection();
     con.Open();
     SQLiteDataReader reader = getAllWhere("res", "rtype = 'A654495C' and lower(name) = '" + id.ToLower() + "'", con);
     int count = 0;
     while (reader.Read())
     {
         if (count++ % 1000 == 0)
             Application.DoEvents();
         TextureInformation ti = new TextureInformation();
         ti.name = reader.GetString(0);
         ti.sha1 = Helpers.HexStringToByteArray(reader.GetString(1));
         ti.bundleIndex = reader.GetInt32(3);
         result.Add(ti);
     }
     con.Close();
     return result.ToArray();
 }
Example #36
0
        private static byte[] GetUvBytes(TextureInformation texInfoL, IUvCommandValues param)
        {
            var serializer = new AdvancedUvSerializer(param);

            return(serializer.SerializeUv(texInfoL));
        }
Example #37
0
        public static byte[] GetUVBytes(TextureInformation _TexInfo,
                                        Data.Value.Enum <Data.RendererCommonValues.UVType> _UVType,
                                        Data.RendererCommonValues.UVFixedParamater _Fixed,
                                        Data.RendererCommonValues.UVAnimationParamater _Animation,
                                        Data.RendererCommonValues.UVScrollParamater _Scroll,
                                        Data.RendererCommonValues.UVFCurveParamater _FCurve)
        {
            List <byte[]> data = new List <byte[]>();

            // sprcification change(1.5)
            float width  = 128.0f;
            float height = 128.0f;

            if (_TexInfo.Width > width && _TexInfo.Height > height)
            {
                width  = (float)_TexInfo.Width;
                height = (float)_TexInfo.Height;
            }

            data.Add(_UVType);
            if (_UVType == Data.RendererCommonValues.UVType.Default)
            {
            }
            else if (_UVType == Data.RendererCommonValues.UVType.Fixed)
            {
                var value_ = _Fixed;
                data.Add((value_.Start.X / width).GetBytes());
                data.Add((value_.Start.Y / height).GetBytes());
                data.Add((value_.Size.X / width).GetBytes());
                data.Add((value_.Size.Y / height).GetBytes());
            }
            else if (_UVType == Data.RendererCommonValues.UVType.Animation)
            {
                var value_ = _Animation;
                data.Add((value_.Start.X / width).GetBytes());
                data.Add((value_.Start.Y / height).GetBytes());
                data.Add((value_.Size.X / width).GetBytes());
                data.Add((value_.Size.Y / height).GetBytes());

                if (value_.FrameLength.Infinite)
                {
                    var inf = int.MaxValue / 100;
                    data.Add(inf.GetBytes());
                }
                else
                {
                    data.Add(value_.FrameLength.Value.Value.GetBytes());
                }

                data.Add(value_.FrameCountX.Value.GetBytes());
                data.Add(value_.FrameCountY.Value.GetBytes());
                data.Add(value_.LoopType);

                data.Add(value_.StartSheet.Max.GetBytes());
                data.Add(value_.StartSheet.Min.GetBytes());
            }
            else if (_UVType == Data.RendererCommonValues.UVType.Scroll)
            {
                var value_ = _Scroll;
                data.Add((value_.Start.X.Max / width).GetBytes());
                data.Add((value_.Start.Y.Max / height).GetBytes());
                data.Add((value_.Start.X.Min / width).GetBytes());
                data.Add((value_.Start.Y.Min / height).GetBytes());

                data.Add((value_.Size.X.Max / width).GetBytes());
                data.Add((value_.Size.Y.Max / height).GetBytes());
                data.Add((value_.Size.X.Min / width).GetBytes());
                data.Add((value_.Size.Y.Min / height).GetBytes());

                data.Add((value_.Speed.X.Max / width).GetBytes());
                data.Add((value_.Speed.Y.Max / height).GetBytes());
                data.Add((value_.Speed.X.Min / width).GetBytes());
                data.Add((value_.Speed.Y.Min / height).GetBytes());
            }
            else if (_UVType == Data.RendererCommonValues.UVType.FCurve)
            {
                {
                    var           value_ = _FCurve.Start;
                    var           bytes1 = value_.GetBytes(1.0f / width);
                    List <byte[]> _data  = new List <byte[]>();
                    data.Add(bytes1);
                }

                {
                    var           value_ = _FCurve.Size;
                    var           bytes1 = value_.GetBytes(1.0f / height);
                    List <byte[]> _data  = new List <byte[]>();
                    data.Add(bytes1);
                }
            }

            return(data.ToArray().ToArray());
        }
        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformations)
        {
            Vector3 myPosition = new Vector3(basePosition.X - (myWidth / 2), basePosition.Y, basePosition.Z - (myHeight / 2));
            
            Vector3[] pos = new Vector3[myWidth * myHeight];
            // Vertices
            VertexMultitextured[] myVertices = new VertexMultitextured[myWidth * myHeight];

            for (int x = 0; x < myWidth; x++)
                for (int y = 0; y < myHeight; y++)
                {
                    myVertices[x + y * myWidth].Position = new Vector3(y, 0, x);
                    pos[x + y * myWidth] = new Vector3(y, 0, x); 
                    myVertices[x + y * myWidth].Normal = new Vector3(0, -1, 0);
                    myVertices[x + y * myWidth].TextureCoordinate.X = (float)x / 30.0f;
                    myVertices[x + y * myWidth].TextureCoordinate.Y = (float)y / 30.0f;                    
                }

            modelRadius = BoundingSphere.CreateFromPoints(pos).Radius;            

            // Calc Tangent and Bi Normals.
            for (int x = 0; x < myWidth; x++)
                for (int y = 0; y < myHeight; y++)
                {
                    // Tangent Data.
                    if (x != 0 && x < myWidth - 1)
                        myVertices[x + y * myWidth].Tangent = myVertices[x - 1 + y * myWidth].Position - myVertices[x + 1 + y * myWidth].Position;
                    else
                        if (x == 0)
                            myVertices[x + y * myWidth].Tangent = myVertices[x + y * myWidth].Position - myVertices[x + 1 + y * myWidth].Position;
                        else
                            myVertices[x + y * myWidth].Tangent = myVertices[x - 1 + y * myWidth].Position - myVertices[x + y * myWidth].Position;

                    // Bi Normal Data.
                    if (y != 0 && y < myHeight - 1)
                        myVertices[x + y * myWidth].BiNormal = myVertices[x + (y - 1) * myWidth].Position - myVertices[x + (y + 1) * myWidth].Position;
                    else
                        if (y == 0)
                            myVertices[x + y * myWidth].BiNormal = myVertices[x + y * myWidth].Position - myVertices[x + (y + 1) * myWidth].Position;
                        else
                            myVertices[x + y * myWidth].BiNormal = myVertices[x + (y - 1) * myWidth].Position - myVertices[x + y * myWidth].Position;
            }


            VertexDeclaration vd = new VertexDeclaration(VertexMultitextured.SizeInBytes,VertexMultitextured.VertexElements);
            VertexBuffer vb = factory.CreateVertexBuffer(vd, myWidth * myHeight, BufferUsage.WriteOnly);
            vb.SetData(myVertices);

            short[] terrainIndices = new short[(myWidth - 1) * (myHeight - 1) * 6];
            for (short x = 0; x < myWidth - 1; x++)
            {
                for (short y = 0; y < myHeight - 1; y++)
                {
                    terrainIndices[(x + y * (myWidth - 1)) * 6] = (short)((x + 1) + (y + 1) * myWidth);
                    terrainIndices[(x + y * (myWidth - 1)) * 6 + 1] = (short)((x + 1) + y * myWidth);
                    terrainIndices[(x + y * (myWidth - 1)) * 6 + 2] = (short)(x + y * myWidth);

                    terrainIndices[(x + y * (myWidth - 1)) * 6 + 3] = (short)((x + 1) + (y + 1) * myWidth);
                    terrainIndices[(x + y * (myWidth - 1)) * 6 + 4] = (short)(x + y * myWidth);
                    terrainIndices[(x + y * (myWidth - 1)) * 6 + 5] = (short)(x + (y + 1) * myWidth);
                }
            }

            IndexBuffer ib = factory.CreateIndexBuffer(IndexElementSize.SixteenBits, (myWidth - 1) * (myHeight - 1) * 6, BufferUsage.WriteOnly);
            ib.SetData(terrainIndices);

            BatchInformations = new BatchInformation[1][];
            BatchInformation[] b = new BatchInformation[1];
            b[0] = new BatchInformation(0,myVertices.Count(),terrainIndices.Count() /3,0,0,vd,VertexMultitextured.SizeInBytes);
            b[0].VertexBuffer = vb;
            b[0].IndexBuffer = ib;
            BatchInformations[0] = b;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[1];
            TextureInformations[0][0] = new TextureInformation(isInternal, factory, null, null, null, null);
            TextureInformations[0][0].LoadTexture();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomModel"/> class.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="modelName">Name of the model.</param>
        /// <param name="BatchInformation">The batch information.</param>
        /// <param name="TextureInformation">The texture information.</param>
        /// <param name="meshindex">The meshindex.</param>
        /// <param name="meshpartIndex">Index of the meshpart.</param>
        public CustomModel(GraphicFactory factory, String modelName, BatchInformation BatchInformation, TextureInformation TextureInformation, int meshindex = 0, int meshpartIndex = 0)        
            : base(factory, modelName, false)
       {

           System.Diagnostics.Debug.Assert(BatchInformation != null);
           System.Diagnostics.Debug.Assert(TextureInformation != null);

           BatchInformations = new BatchInformation[1][];
           BatchInformations[0] = new BatchInformation[1];
           BatchInformations[0][0] = BatchInformation;
                      
           BoundingSphere bs = new BoundingSphere();           
           {
               float radius;
               Vector3 center;
               ModelBuilderHelper.ExtractModelRadiusAndCenter(BatchInformation, out radius, out center);                
               bs = BoundingSphere.CreateMerged(bs,new BoundingSphere(center,radius));
           }
           modelRadius = bs.Radius;

           TextureInformations = new TextureInformation[1][];
           TextureInformations[0] = new TextureInformation[1];
           TextureInformations[0][0] = TextureInformation;

           if (TextureInformation.getTexture(TextureType.DIFFUSE) == null)
           {
               if (model != null)
               {
                   BasicEffect effect = model.Meshes[meshindex].MeshParts[meshpartIndex].Effect as BasicEffect;
                   if (effect != null)
                   {
                       TextureInformations[0][0].SetTexture(effect.Texture, TextureType.DIFFUSE);
                   }
               }
           }           
       }
 void Modelo_OnTextureChange(TextureType type, TextureInformation model)
 {
     this.aniTex = model.getTexture(TextureType.DIFFUSE);
     totalwidth = aniTex.Width;
     this.width = aniTex.Width / numberOfFrames;
     this.height = aniTex.Height;
     size = width / totalwidth;
 }
        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformation)
        {                        
            BatchInformations = new BatchInformation[1][];
            BatchInformations[0] = new BatchInformation[1];
            BatchInformations[0][0] = BatchInformation;

            TextureInformation = new TextureInformation[1][];
            TextureInformation[0] = new TextureInformation[1];
            TextureInformation[0][0] = new TextureInformation(false,factory,_diffuseName);
            TextureInformation[0][0].LoadTexture();
        }
        private void AddTexIdAndInfo(bool isEnabled, PathForImage path, SortedDictionary <string, int> texAndInd, ref TextureInformation textureInfo)
        {
            var value = isEnabled
                                ? GetTexIdAndInfo(path, texAndInd, ref textureInfo)
                                : -1;

            AddInt(value);
        }
 public static void Extract(GraphicFactory factory, out BatchInformation[][] batchInformationS, out TextureInformation[][] textureInformationS, string modelName, String diffuseName = null, String bumpName = null, string specularName = null, String glowName = null, bool isinternal = false)
 {
     Model model = factory.GetModel(modelName, isinternal);
     Extract(factory, out batchInformationS, out textureInformationS, model, diffuseName, bumpName, specularName, glowName, isinternal);
 }