public IVertex LerpTo(IVertex _other, float t) { CVertex other = (CVertex)_other; var newPos = OpenTK.Vector3.Lerp(this.Position, other.Position, t); var newNormal = OpenTK.Vector3.Lerp(this.Normal, other.Normal, t).Normalized(); var newUV = OpenTK.Vector2.Lerp(this.UV, other.UV, t); return(new CVertex { Position = newPos, Normal = newNormal, UV = newUV }); }
public CTriangle(OpenTK.Vector3[] v) { original_verts = new CVertex[4]; tex_index = 0; flags = 0; for (int i = 0; i < 4; i++) { original_verts[i] = new CVertex(); original_verts[i].Normal = new OpenTK.Vector3(0f, 1f, 0f); original_verts[i].UV = new OpenTK.Vector2(0f, 0f); original_verts[i].Position = v[i]; } }
public CTriangle ExtractClippedTriangle(int tri_idx) { CVertex[] extracted_verts = new CVertex[3]; extracted_verts[0] = new CVertex { Position = clipped_verts[0].Position, Normal = clipped_verts[0].Normal, UV = clipped_verts[0].UV }; extracted_verts[1] = new CVertex { Position = clipped_verts[tri_idx + 1].Position, Normal = clipped_verts[tri_idx + 1].Normal, UV = clipped_verts[tri_idx + 1].UV }; extracted_verts[2] = new CVertex { Position = clipped_verts[tri_idx + 2].Position, Normal = clipped_verts[tri_idx + 2].Normal, UV = clipped_verts[tri_idx + 2].UV }; return(new CTriangle(extracted_verts, this.tex_index, this.flags)); }
public CTriangle(DTriangle dtri, OpenTK.Vector3 v1, OpenTK.Vector3 v2, OpenTK.Vector3 v3) { // Always start with 3 verts original_verts = new CVertex[3]; tex_index = dtri.tex_index; flags = dtri.flags; for (int i = 0; i < 3; i++) { original_verts[i] = new CVertex(); original_verts[i].Normal = dtri.normal[i]; original_verts[i].UV = dtri.tex_uv[i]; } original_verts[0].Position = v1; original_verts[1].Position = v2; original_verts[2].Position = v3; }