コード例 #1
0
ファイル: HelpfulStuff.cs プロジェクト: olydis/FineCraft
        public static AwesomeMesh getCube(float bBoxSize, Vector2 basis)
        {
            var cube = new VertexAwesome[36];

            cube[0] = new VertexAwesome(255, new Vector3(-bBoxSize, -bBoxSize, -bBoxSize), Vector3.Zero, basis);
            cube[4] = cube[1] = new VertexAwesome(255, new Vector3(-bBoxSize, bBoxSize, -bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit);
            cube[3] = cube[2] = new VertexAwesome(255, new Vector3(-bBoxSize, -bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureYUnit);
            cube[5] = new VertexAwesome(255, new Vector3(-bBoxSize, bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit + GraphicsHelper.TextureYUnit);
            cube[6] = new VertexAwesome(255, new Vector3(bBoxSize, -bBoxSize, -bBoxSize), Vector3.Zero, basis);
            cube[10] = cube[7] = new VertexAwesome(255, new Vector3(bBoxSize, -bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit);
            cube[9] = cube[8] = new VertexAwesome(255, new Vector3(bBoxSize, bBoxSize, -bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureYUnit);
            cube[11] = new VertexAwesome(255, new Vector3(bBoxSize, bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit + GraphicsHelper.TextureYUnit);

            cube[12] = new VertexAwesome(255, new Vector3(-bBoxSize, -bBoxSize, -bBoxSize), Vector3.Zero, basis);
            cube[16] = cube[13] = new VertexAwesome(255, new Vector3(-bBoxSize, -bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit);
            cube[15] = cube[14] = new VertexAwesome(255, new Vector3(bBoxSize, -bBoxSize, -bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureYUnit);
            cube[17] = new VertexAwesome(255, new Vector3(bBoxSize, -bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit + GraphicsHelper.TextureYUnit);
            cube[18] = new VertexAwesome(255, new Vector3(-bBoxSize, bBoxSize, -bBoxSize), Vector3.Zero, basis);
            cube[22] = cube[19] = new VertexAwesome(255, new Vector3(bBoxSize, bBoxSize, -bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit);
            cube[21] = cube[20] = new VertexAwesome(255, new Vector3(-bBoxSize, bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureYUnit);
            cube[23] = new VertexAwesome(255, new Vector3(bBoxSize, bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit + GraphicsHelper.TextureYUnit);

            cube[24] = new VertexAwesome(255, new Vector3(-bBoxSize, -bBoxSize, -bBoxSize), Vector3.Zero, basis);
            cube[28] = cube[25] = new VertexAwesome(255, new Vector3(bBoxSize, -bBoxSize, -bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit);
            cube[27] = cube[26] = new VertexAwesome(255, new Vector3(-bBoxSize, bBoxSize, -bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureYUnit);
            cube[29] = new VertexAwesome(255, new Vector3(bBoxSize, bBoxSize, -bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit + GraphicsHelper.TextureYUnit);
            cube[30] = new VertexAwesome(255, new Vector3(-bBoxSize, -bBoxSize, bBoxSize), Vector3.Zero, basis);
            cube[34] = cube[31] = new VertexAwesome(255, new Vector3(-bBoxSize, bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit);
            cube[33] = cube[32] = new VertexAwesome(255, new Vector3(bBoxSize, -bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureYUnit);
            cube[35] = new VertexAwesome(255, new Vector3(bBoxSize, bBoxSize, bBoxSize), Vector3.Zero, basis + GraphicsHelper.TextureXUnit + GraphicsHelper.TextureYUnit);

            return new AwesomeMesh(cube);
        }
コード例 #2
0
ファイル: BlockTypes.cs プロジェクト: olydis/FineCraft
 static VertexAwesome[] GetWild(int num, float scale)
 {
     float rotOffset = count / 10f + 0.3f;
     int segment = 8 * num;
     VertexAwesome[] mesh = new VertexAwesome[3 * segment];
     for (int i = 0; i < num; i++)
     {
         mesh[8 * i + 4] = mesh[8 * i + 0] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f * scale, -0.5f * scale), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), new Vector2(0, 1));
         mesh[8 * i + 6] = mesh[8 * i + 1] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f * scale, 0.5f * scale), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), new Vector2(0, 0));
         mesh[8 * i + 5] = mesh[8 * i + 2] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f * scale, -0.5f * scale), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi)), new Vector2(1, 1));
         mesh[8 * i + 7] = mesh[8 * i + 3] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f * scale, 0.5f * scale), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi)), new Vector2(1, 0));
     }
     for (int i = 0; i < num; i++)
     {
         mesh[segment + 8 * i + 4] = mesh[segment + 8 * i + 0] = new VertexAwesome(255, Vector3.Transform(new Vector3(0.5f * scale, -0.5f * scale,0), Matrix.CreateRotationY(MathHelper.TwoPi * i / num + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), new Vector2(0, 1));
         mesh[segment + 8 * i + 6] = mesh[segment + 8 * i + 1] = new VertexAwesome(255, Vector3.Transform(new Vector3(0.5f * scale, 0.5f * scale, 0), Matrix.CreateRotationY(MathHelper.TwoPi * i / num + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), new Vector2(0, 0));
         mesh[segment + 8 * i + 5] = mesh[segment + 8 * i + 2] = new VertexAwesome(255, Vector3.Transform(new Vector3(0.5f * scale, -0.5f * scale, 0), Matrix.CreateRotationY(MathHelper.TwoPi * i / num + MathHelper.Pi + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi)), new Vector2(1, 1));
         mesh[segment + 8 * i + 7] = mesh[segment + 8 * i + 3] = new VertexAwesome(255, Vector3.Transform(new Vector3(0.5f * scale, 0.5f * scale,0), Matrix.CreateRotationY(MathHelper.TwoPi * i / num + MathHelper.Pi + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi)), new Vector2(1, 0));
     }
     for (int i = 0; i < num; i++)
     {
         mesh[2 * segment + 8 * i + 4] = mesh[2 * segment + 8 * i + 0] = new VertexAwesome(255, Vector3.Transform(new Vector3(-0.5f * scale, 0, 0.5f * scale), Matrix.CreateRotationX(MathHelper.TwoPi * i / num + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), new Vector2(0, 1));
         mesh[2 * segment + 8 * i + 6] = mesh[2 * segment + 8 * i + 1] = new VertexAwesome(255, Vector3.Transform(new Vector3(0.5f * scale, 0, 0.5f * scale), Matrix.CreateRotationX(MathHelper.TwoPi * i / num + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), new Vector2(0, 0));
         mesh[2 * segment + 8 * i + 5] = mesh[2 * segment + 8 * i + 2] = new VertexAwesome(255, Vector3.Transform(new Vector3(-0.5f * scale, 0, 0.5f * scale), Matrix.CreateRotationX(MathHelper.TwoPi * i / num + MathHelper.Pi + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi)), new Vector2(1, 1));
         mesh[2 * segment + 8 * i + 7] = mesh[2 * segment + 8 * i + 3] = new VertexAwesome(255, Vector3.Transform(new Vector3(0.5f * scale, 0, 0.5f * scale), Matrix.CreateRotationX(MathHelper.TwoPi * i / num + MathHelper.Pi + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi)), new Vector2(1, 0));
     }
     return mesh;
 }
コード例 #3
0
ファイル: VertexAwesomeTest.cs プロジェクト: olydis/FineCraft
 public void VertexAwesomeConstructorTest()
 {
     byte color = 0; // TODO: Passenden Wert initialisieren
     Vector3 position = new Vector3(); // TODO: Passenden Wert initialisieren
     Vector3 normal = new Vector3(); // TODO: Passenden Wert initialisieren
     Vector2 textureCoordinate = new Vector2(); // TODO: Passenden Wert initialisieren
     VertexAwesome target = new VertexAwesome(color, position, normal, textureCoordinate);
     Assert.Inconclusive("TODO: Code zum Überprüfen des Ziels implementieren");
 }
コード例 #4
0
ファイル: BlockTypes.cs プロジェクト: olydis/FineCraft
 static VertexAwesome[] GetFold(int num, float sideScale, float lowerZ, float upperZ, Vector2 relTex)
 {
     float rotOffset = count / 10f + 0.3f;
     VertexAwesome[] mesh = new VertexAwesome[8 * num];
     for (int i = 0; i < num; i++)
     {
         mesh[8 * i + 7] = mesh[8 * i + 0] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f * sideScale, lowerZ), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), relTex + new Vector2(0, 1));
         mesh[8 * i + 5] = mesh[8 * i + 1] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f * sideScale, upperZ), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), relTex + new Vector2(0, 0));
         mesh[8 * i + 6] = mesh[8 * i + 2] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f * sideScale, lowerZ), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi)), relTex + new Vector2(1, 1));
         mesh[8 * i + 4] = mesh[8 * i + 3] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f * sideScale, upperZ), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi + rotOffset)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num + MathHelper.Pi)), relTex + new Vector2(1, 0));
     }
     return mesh;
 }
コード例 #5
0
ファイル: BlockTypes.cs プロジェクト: olydis/FineCraft
 static VertexAwesome[] GetCyl(int num)
 {
     var mesh = new VertexAwesome[12 * num];
     for (int i = 0; i < num; i++)
     {
         mesh[12 * i + 7] = mesh[12 * i + 0] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f, -0.5f), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), new Vector2((float)i / num, 0));
         mesh[12 * i + 11] = mesh[12 * i + 1] = mesh[12 * i + 4] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f, 0.5f), Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * i / num)), new Vector2((float)i / num, 1));
         mesh[12 * i + 8] = mesh[12 * i + 3] = mesh[12 * i + 2] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f, -0.5f), Matrix.CreateRotationZ(MathHelper.TwoPi * (i + 1) / num)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * (i + 1) / num)), new Vector2((float)(i + 1) / num, 0));
         mesh[12 * i + 10] = mesh[12 * i + 5] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f, 0.5f), Matrix.CreateRotationZ(MathHelper.TwoPi * (i + 1) / num)), Vector3.Transform(Vector3.UnitY, Matrix.CreateRotationZ(MathHelper.TwoPi * (i + 1) / num)), new Vector2((float)(i + 1) / num, 1));
         mesh[12 * i + 6] = new VertexAwesome(255, new Vector3(0, 0, -0.5f), -Vector3.UnitZ, new Vector2(0.5f, 0.5f));
         mesh[12 * i + 9] = new VertexAwesome(255, new Vector3(0, 0, 0.5f), Vector3.UnitZ, new Vector2(0.5f, 0.5f));
     }
     return mesh;
 }
コード例 #6
0
ファイル: BlockTypes.cs プロジェクト: olydis/FineCraft
 static VertexAwesome[] GetCyl(int num)
 {
     var mesh = new VertexAwesome[4 * num];
     for (int i = 0; i < num; i++)
     {
         Matrix rotZ1 = Matrix.CreateRotationZ(MathHelper.TwoPi * i / num);
         Matrix rotZ2 = Matrix.CreateRotationZ(MathHelper.TwoPi * (i + 1) / num);
        
         mesh[4 * i + 0] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f, -0.5f), rotZ1), Vector3.Transform(Vector3.UnitY, rotZ1), new Vector2((float)i / num, 0));
         mesh[4 * i + 1] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f, 0.5f), rotZ1), Vector3.Transform(Vector3.UnitY, rotZ1), new Vector2((float)i / num, 1));
         mesh[4 * i + 2] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f, -0.5f), rotZ2), Vector3.Transform(Vector3.UnitY, rotZ2), new Vector2((float)(i + 1) / num, 0));
         mesh[4 * i + 3] = new VertexAwesome(255, Vector3.Transform(new Vector3(0, 0.5f, 0.5f), rotZ2), Vector3.Transform(Vector3.UnitY, rotZ2), new Vector2((float)(i + 1) / num, 1));
         
         //mesh[12 * i + 6] = new VertexAwesome(255, new Vector3(0, 0, -0.5f), -Vector3.UnitZ, new Vector2(0.5f, 0.5f));
         //mesh[12 * i + 9] = new VertexAwesome(255, new Vector3(0, 0, 0.5f), Vector3.UnitZ, new Vector2(0.5f, 0.5f));
     }
     return mesh;
 }
コード例 #7
0
ファイル: BlockTypes.cs プロジェクト: olydis/FineCraft
 static void addCustom(Color c, BlockingType blocking, uint texture, VertexAwesome[] mesh, string name, string description)
 {
     add(new BlockType
     {
         Schematic = c,
         Name = name,
         Description = description,
         IsCube = false,
         IsEmpty = false,
         IsSolid = false,
         Removable = true,
         Blocking = blocking,
         Texture = texture,
         Mesh = mesh
     });
 }
コード例 #8
0
ファイル: BlockTypes.cs プロジェクト: olydis/FineCraft
 static void addCube(Color c, CubeType type, bool removable, BlockingType blocking, uint texture, string name, string description, VertexAwesome[] mesh)
 {
     add(new BlockType
     {
         Schematic = c,
         Name = name,
         Description = description,
         IsCube = true,
         IsEmpty = type == CubeType.Empty,
         IsSolid = type == CubeType.Solid,
         Removable = removable,
         Blocking = blocking,
         Texture = texture,
         //Mesh = mesh
     });
 }
コード例 #9
0
ファイル: AwesomeMesh.cs プロジェクト: olydis/FineCraft
 public AwesomeMesh(VertexAwesome[] vertices)
 {
     primitiveCount = vertices.Length / 3;
     vBuffer = new VertexBuffer(Static.Device, vertices.Length * VertexAwesome.SizeInBytes, BufferUsage.WriteOnly);
     vBuffer.SetData(vertices);
 }
コード例 #10
0
ファイル: AwesomeMesh.cs プロジェクト: olydis/FineCraft
 public AwesomeMesh(VertexAwesome[] vertices)
 {
     primitiveCount = vertices.Length / 3;
     vBuffer = new VertexBuffer(Static.Device, typeof(VertexAwesome), vertices.Length, BufferUsage.WriteOnly);
     vBuffer.SetData(vertices);
 }
コード例 #11
0
ファイル: BlockTypes.cs プロジェクト: olydis/FineCraft
 static void addCustom(Color c, BlockingType blocking, uint texture, VertexAwesome[] mesh, string name, string description)
 {
     addCustom(c, blocking, texture, mesh, name, description, Color.Black);
 }
コード例 #12
0
ファイル: BlockTypes.cs プロジェクト: olydis/FineCraft
 static void addCube(Color c, CubeType type, bool removable, BlockingType blocking, uint texture, string name, string description, VertexAwesome[] mesh)
 {
     addCube(c, type, removable, blocking, texture, name, description, mesh, Color.Black);
 }