public TexturedModel Add(TexturedVertex[] tvs, uint[] tis) { TexturedModel texturedModel = new TexturedModel(tvs, tis, ShaderLayout_Position, ShaderLayout_Texture); this.Disposables.Add(texturedModel); return(texturedModel); }
public void Add(TexturedModel texturedModel, int textureId, Vector3 position) { SceneObject texturedObject = new SceneObject(texturedModel, position); //_texture = InitTextures(@"C:\Users\pstepnowski\Source\Repos\fdafadf\basics\Basics.Physics.Test.UI\Textures\wooden.bmp"); GL.BindTexture(TextureTarget.Texture2D, textureId); this.Renderables.Add(texturedObject); }
public void LoadTrack(TexturedObjectGroup texturedGroup, Texture texture) { WindowsFormsApp1.TestModel testModel = WindowsFormsApp1.Form1.CreateTestModel2(); List <TexturedVertex> trackVertices = new List <TexturedVertex>(); var minX = testModel.Vertices.Min(v => v.X); var maxX = testModel.Vertices.Max(v => v.X); var minZ = testModel.Vertices.Min(v => v.Z); var maxZ = testModel.Vertices.Max(v => v.Z); for (int i = 0; i < testModel.Vertices.Count; i++) { var vertex = testModel.Vertices[i]; float u = ((i % 4) & 1) != 0 ? 255 : 0; float v = ((i % 4) & 2) != 0 ? 255 : 0; Vector3 position = new Vector3(vertex.X, vertex.Y, vertex.Z); TexturedVertex texturedVertex = new TexturedVertex(position, new Vector2(u, v)); trackVertices.Add(texturedVertex); } TexturedModel texturedModel = texturedGroup.Add(trackVertices.ToArray(), testModel.Indices.ToArray()); texturedGroup.Add(texturedModel, texture.Handle, new Vector3()); /* * List<TexturedVertex> trackVertices = new List<TexturedVertex>(); * List<uint> trackIndices = new List<uint>(); * Random random = new Random((int)DateTime.Now.Ticks); * TexturedVertex a = new TexturedVertex(new Vector3(-2, -0.2f, 0), new Vector2(0, 0)); * TexturedVertex b = new TexturedVertex(new Vector3(2, -0.2f, 0), new Vector2(255, 0)); * trackVertices.Add(a); * trackVertices.Add(b); * WindowsFormsApp1.Vector3d delta = new WindowsFormsApp1.Vector3d(0, 0, 10); * WindowsFormsApp1.Matrix3d matrix = WindowsFormsApp1.Matrix3d.RotationY(5 / 57.29577f); * * for (uint i = 0; i < 1; i++) * { * uint v = (i + 1) * 120 % 255; * delta.Mul(matrix); * * Vector3 d = new Vector3(b.Position.X + delta.X, b.Position.Y + delta.Y, b.Position.Z + delta.Z); * TexturedVertex texturedVertexD = new TexturedVertex(d, new Vector2(255, v)); * PointF dp = new PointF(b.Position.X, b.Position.Z); * PointF dv = new PointF(b.Position.X + delta.Z, b.Position.Z - delta.X); * PointF ap = new PointF(a.Position.X, a.Position.Z); * PointF av = new PointF(a.Position.X + delta.X, a.Position.Z + delta.Z); * PointF p = MathHelper2.Intersection(dp, dv, ap, av); * Vector3 c = new Vector3(p.X, a.Position.Y, p.Y); * TexturedVertex texturedVertexC = new TexturedVertex(c, new Vector2(0, v)); * trackVertices.Add(texturedVertexC); * trackVertices.Add(texturedVertexD); * trackIndices.Add(2 + i * 2); * trackIndices.Add(0 + i * 2); * trackIndices.Add(1 + i * 2); * trackIndices.Add(2 + i * 2); * trackIndices.Add(1 + i * 2); * trackIndices.Add(3 + i * 2); * a = texturedVertexC; * b = texturedVertexD; * } * * TexturedModel texturedModel = texturedGroup.Add(trackVertices.ToArray(), trackIndices.ToArray()); * texturedGroup.Add(texturedModel, texture.Handle, new Vector3()); */ }