protected RoamVertex AllocVertex() { var vertex = new RoamVertex(); vertex.InsertBefore(ActiveVertexes); return(vertex); }
// public Vector3d Center; // public double TwoDivArea; // 2/area // public double Radius; // radius public void Init(RoamVertex v0, RoamVertex v1, RoamVertex v2, Vector2d tex0, Vector2d tex1, Vector2d tex2, ushort material) { Material = material; SetVertexes(v0, v1, v2); TextureCoords0 = tex0; TextureCoords1 = tex1; TextureCoords2 = tex2; }
public void Set(RoamTriangle parent, RoamVertex v0, RoamVertex v1, RoamVertex v2, Vector2d texCoord0, Vector2d texCoord1, Vector2d texCoord2) { SetVertexes(v0, v1, v2); TextureCoords0 = texCoord0; TextureCoords1 = texCoord1; TextureCoords2 = texCoord2; Parent = parent; Level = (ushort)(parent.Level + 1); Flags = RoamTriangleFlags.Modified; Material = parent.Material; }
void SetVertexes(RoamVertex v0, RoamVertex v1, RoamVertex v2) { Vertexes0 = v0; Vertexes1 = v1; Vertexes2 = v2; //Center = Vector3d.Center(v0.Position, v1.Position, v2.Position); // Compute plane and area // Vector3d n = Vector3d.CrossProduct(v2.Position - v1.Position, v0.Position - v1.Position); // _area = 1 / n.Abs(); // plane.x = n.x _area; // plane.y = n.y _area; // plane.z = n.z _area; // plane.w = -(plane.x center.x + plane.y center.y + plane.z center.z); // double r = center.distance2(v0.position); // double rt = center.distance2(v1.position); // if (rt > r) r = rt; // rt = center.distance2(v2.position); // if (rt > r) r = rt; // radius = sqrt(r); }
public bool HasVertex(RoamVertex v) { return(Vertexes0 == v || Vertexes1 == v || Vertexes2 == v); }
protected void FreeVertex(RoamVertex vertex) { vertex.Remove(); }
// { // vertex.LinearPosition = normal; // vertex.Normal = normal; // vertex.Position = normal; // } protected abstract void ComputeVertexAltitude(RoamVertex vertex, RoamTriangle triangle);
protected abstract void ComputeVertexAltitude(RoamVertex vertex, Vector3d position);