public ModelParticle(ShaderParticle shader) : base(null, shader)
        {
            var vertexes = CubeModelBuilder.CreateCubeVertexes(true);
            var normals  = CubeModelBuilder.CreateCubeNormals();
            var uvs      = CubeModelBuilder.CreateCubeUvs();

            RawModel = ModelManager.LoadModel3ToVao(vertexes, normals, uvs);
        }
        public static void LoadModel(string path, Shader <ModelCustom> shader) //TODO
        {
            string file = $"{SharpCraft.Instance.GameFolderDir}\\SharpCraft_Data\\assets\\models\\{path}.json";

            if (!File.Exists(file))
            {
                return;
            }

            List <string> nonDuplicateTextures = new List <string>();

            JsonBlockModel model = FixBlockJson(file);

            foreach (var pair in model.textures) //iterating over the textureMap in the Json model
            {
                if (!nonDuplicateTextures.Contains(pair.Value))
                {
                    nonDuplicateTextures.Add(pair.Value); //add the current texture name to a list of all textureMap if isn't already there
                }
            }

            var textureMapElements = new Dictionary <string, TextureMapElement>();   //each texture name has it's UV values TODO - maybe make a TextureMap class where this could be used

            var id = Stitch(nonDuplicateTextures.ToArray(), 16, textureMapElements); //TODO - make the texture size variable

            float[] vertexes = new float[72 * model.cubes.Length];
            float[] normals  = new float[72 * model.cubes.Length];
            float[] uvs      = new float[48 * model.cubes.Length];

            for (var index = 0; index < model.cubes.Length; index++)
            {
                var cube = model.cubes[index];

                CubeModelBuilder.AppendCubeModel(cube, model.textures, textureMapElements, ref vertexes,
                                                 ref normals, ref uvs, index);
            }

            var customModel = new ModelCustom(id, ModelManager.LoadModel3ToVao(vertexes, normals, uvs), shader);

            _customModels.Add(path, customModel);

            //return customModel;
        }
예제 #3
0
 public ModelChunk(float[] vertexes, float[] normals, float[] uvs, Shader <ModelBlock> shader) : base(null, shader)
 {
     IsGenerated = vertexes.Length > 0;
     RawModel    = ModelManager.LoadModel3ToVao(vertexes, normals, uvs);
 }
 public ModelCubeOutline() : base(ModelManager.LoadModel3ToVao(CubeModelBuilder.CreateCubeVertexes()), new ShaderColor())
 {
 }