private static PartialModel GenerateCircleModel() { float stepAngle = (float)Math.PI * 2f / 32f; var indices = new List <int>(); var vertices = new List <VertVN>(); //Cone vertices and indices for (int i = 0; i < 32; i++) { var pt = new Vector3((float)Math.Cos(stepAngle * i), 0f, (float)Math.Sin(stepAngle * i)) * 0.5f; vertices.Add(new VertVN(pt, pt.Normalized())); indices.Add((i + 1) % 32); indices.Add(i); //indices.Add(32); } int curIdx = GeneralMeshBuffer.IndexCount; int curVert = GeneralMeshBuffer.VertexCount; GeneralMeshBuffer.AppendVertices(vertices); GeneralMeshBuffer.AppendIndices(indices); int idxCount = GeneralMeshBuffer.IndexCount - curIdx; var vertexPositions = vertices.Select(x => x.Position).ToList(); var bounding = BBox.FromVertices(vertexPositions); var model = new PartialModel(GeneralMeshBuffer, curIdx, curVert, idxCount, OpenTK.Graphics.OpenGL.PrimitiveType.Lines); model.BoundingBox = bounding; model.Vertices = vertexPositions; LoadedModels.Add(model); return(model); }
private static PartialModel AppendPartialMesh(Assimp.Mesh mesh) { var primitiveType = OpenTK.Graphics.OpenGL.PrimitiveType.Triangles; if (mesh.Faces[0].IndexCount == 4) { primitiveType = OpenTK.Graphics.OpenGL.PrimitiveType.Quads; } int curIdx = GeneralMeshBuffer.IndexCount; int curVert = GeneralMeshBuffer.VertexCount; GeneralMeshBuffer.LoadModelVertices(mesh, true); int idxCount = GeneralMeshBuffer.IndexCount - curIdx; var vertices = GeneralMeshBuffer.GetVertices().Skip(curVert); var vertexPositions = vertices.Select(x => x.Position).ToList(); var bounding = BBox.FromVertices(vertexPositions); var model = new PartialModel(GeneralMeshBuffer, curIdx, curVert, idxCount, primitiveType); model.BoundingBox = bounding; model.Vertices = vertexPositions; LoadedModels.Add(model); //model.LoadVertices(); //model.CalculateBoundingBox(); return(model); }