Exemplo n.º 1
0
 public RenderNodeAction OnFaceBegin(FaceNode node)
 {
     return(0);
 }
Exemplo n.º 2
0
    public void generateNewFlapCreases(Plane p, VertexNode v1)
    {
        List <EdgeNode>   activeEdgeNodes = edgeBTL.getLeaveNodes();
        List <VertexNode> activeVertices  = getVertices();
        List <Edge>       flapEdges       = v1.edges;
        List <VertexNode> prevCutVertices = new List <VertexNode>();


        List <VertexNode> cutVertices = new List <VertexNode>();

        /// si tallo un vertex el tinc en compte d(etermineSide =0)
        for (int i = 0; i < activeVertices.Count; i++)
        {
            if (p.determineSide(activeVertices[i].peek()) == 0)
            {
                cutVertices.Add(activeVertices[i]);
                prevCutVertices.Add(activeVertices[i]);
            }
        }

        /// per cada aresta que es talla faig split i genero un vertex
        for (int i = 0; i < activeEdgeNodes.Count; i++)
        {
            if (flapEdges.Contains(activeEdgeNodes[i].edge))
            {
                EdgeNode   parent = activeEdgeNodes[i];
                VertexNode o      = parent.edge.origin;
                VertexNode e      = parent.edge.end;


                Vector3 point = parent.edge.isCut(p);

                Vector3 inf = new Vector3(9999, 9999, 9999);

                bool close = isClose(point, prevCutVertices);

                if (point != inf && !close) //
                {
                    Vertex v = new Vertex(point, step, vertexLL.vll.Count);
                    vertexLL.count++;
                    VertexNode vn = new VertexNode(v);
                    cutVertices.Add(vn);
                    vertexLL.addVertex(vn);

                    Edge edgel = new Edge(o, vn, step, edgeBTL.count);
                    edgeBTL.count++;
                    EdgeNode ls = new EdgeNode(parent, edgel);
                    vn.addEdge(edgel);
                    edgel.origin.edges.Remove(parent.edge);
                    edgel.origin.addEdge(edgel);

                    Edge edger = new Edge(vn, e, step, edgeBTL.count);
                    edgeBTL.count++;
                    EdgeNode rs = new EdgeNode(parent, edger);
                    vn.addEdge(edger);
                    edger.end.edges.Remove(parent.edge);
                    edger.end.addEdge(edger);

                    for (int j = 0; j < parent.edge.faces.Count; j++)
                    {
                        parent.edge.faces[j].extraV.Add(vn);
                    }

                    parent.setSons(ls, rs);
                }
            }
        }

        /// per cada vertex que comparteix cara 2 a 2 genero una aresta
        for (int i = 0; i < cutVertices.Count; i++)
        {
            for (int j = i + 1; j < cutVertices.Count; j++)
            {
                FaceNode f = shareFace(cutVertices[i], cutVertices[j]);
                if (f != null && !doesEdgeExist(cutVertices[i], cutVertices[j]))
                {
                    Edge e = new Edge(cutVertices[i], cutVertices[j], step, edgeBTL.count);
                    edgeBTL.count++;
                    cutVertices[i].addEdge(e);
                    cutVertices[j].addEdge(e);

                    edgeBTL.addEdge(e);

                    List <VertexNode> l  = f.face.vList;
                    List <VertexNode> l1 = new List <VertexNode>();
                    List <VertexNode> l2 = new List <VertexNode>();
                    int side;

                    l1.Add(cutVertices[i]);
                    l2.Add(cutVertices[i]);
                    l1.Add(cutVertices[j]);
                    l2.Add(cutVertices[j]);

                    for (int k = 0; k < l.Count; k++)
                    {
                        side = p.determineSide(l[k].peek());
                        if (side == 1)
                        {
                            l1.Add(l[k]);
                        }
                        else if (side == -1)
                        {
                            l2.Add(l[k]);
                        }
                    }
                    Face f1 = new Face(l1, step, faceTree.count);
                    faceTree.count++;
                    Face f2 = new Face(l2, step, faceTree.count);
                    faceTree.count++;


                    FaceNode fn1 = new FaceNode(f, f1);
                    FaceNode fn2 = new FaceNode(f, f2);

                    for (int k = 0; k < l1.Count; k++)
                    {
                        for (int m = k + 1; m < l1.Count; m++)
                        {
                            Edge foundEdge = edgeExists(l1[k], l1[m]);
                            if (foundEdge != null)
                            {
                                foundEdge.faces.Add(f1);
                            }
                        }
                    }
                    for (int k = 0; k < l2.Count; k++)
                    {
                        for (int m = k + 1; m < l2.Count; m++)
                        {
                            Edge foundEdge = edgeExists(l2[k], l2[m]);
                            if (foundEdge != null)
                            {
                                foundEdge.faces.Add(f2);
                            }
                        }
                    }
                }
            }
        }
        List <Face> faces = getFaces();

        for (int i = 0; i < faces.Count; i++)
        {
            //faces[i].sortVertices();
        }

        List <Edge> activeE = getEdges();

        for (int i = 0; i < activeE.Count; i++)
        {
            activeE[i].cleanFaces(faces);
        }
    }
Exemplo n.º 3
0
 void IExportContext.OnFaceEnd(FaceNode node)
 {
     MessageBox.Show("OnFaceEnd方法结束");
 }
Exemplo n.º 4
0
 public void OnFaceEnd(FaceNode node)
 {
     Debug.Print("OnFaceEnd not implemented.");
 }
Exemplo n.º 5
0
 public void OnFaceEnd(FaceNode node)
 {
     throw new NotImplementedException();
 }
 public void OnFaceEnd(FaceNode node)
 {
     // This method is invoked only if the custom exporter was set to include faces.
     // Note: This method is invoked even for faces that were skipped.
 }
Exemplo n.º 7
0
        public static ObjObject LoadObjFromText(string[] obj)
        {
            ObjObject retObj = new ObjObject();
            uint      faceId = 0;

            for (uint i = 0; i < obj.Length; i++)
            {
                string[] words = obj[i].Split(' ');

                if (words[0] == "v" || words[0] == "vt" || words[0] == "vn")
                {
                    Vector3 v = new Vector3();
                    v.x = float.Parse(words[1]);
                    v.y = float.Parse(words[2]);

                    if (words[0] != "vt")
                    {
                        v.z = float.Parse(words[3]);

                        if (words[0] == "v")
                        {
                            retObj.AddVertex(v);
                        }
                        else
                        {
                            retObj.AddNormalVertex(v);
                        }
                    }
                    else
                    {
                        retObj.AddTextureVertex(v);
                    }
                }
                else if (words[0] == "f")
                {
                    Face f = new Face(faceId);
                    faceId++;

                    for (uint k = 1; k < words.Length; k++)
                    {
                        FaceNode node      = new FaceNode();
                        string[] faceWords = words[k].Split('/');
                        int      points    = words[k].Length - words[k].Replace("/", "").Length;

                        if (faceWords[0] != "")
                        {
                            node.Vertex = uint.Parse(faceWords[0]) - 1;
                        }

                        if (faceWords[1] != "")
                        {
                            node.TextureVertex = uint.Parse(faceWords[1]) - 1;
                        }

                        if (faceWords[2] != "")
                        {
                            node.NormalVertex = uint.Parse(faceWords[2]) - 1;
                        }

                        f.AddNode(node);
                    }

                    retObj.AddFace(f);

                    if (f.Nodes > 3)
                    {
                        Face[] faces = trianguliza(f, retObj);

                        for (int k = 0; k < faces.Length; k++)
                        {
                            retObj.AddFace(faces[k]);
                        }
                    }
                }
            }

            return(retObj);
        }
 /// <summary>
 ///     his method marks the end of the current face being exported.
 /// </summary>
 /// <param name="node">The face node.</param>
 public void OnFaceEnd(FaceNode node)
 {
     // do nothing
 }
 public RenderNodeAction OnFaceBegin(FaceNode inNode)
 {
     return 0;
 }
 public void OnFaceEnd(FaceNode inNode)
 {
 }
Exemplo n.º 11
0
 /// <summary>
 /// 标记要导出的当前面的末端。
 /// </summary>
 /// <param name="node">表示面的输出节点。</param>
 void IExportContext.OnFaceEnd(FaceNode node)
 {
 }
Exemplo n.º 12
0
 /// <summary>
 /// 标记要导出的Face的开始。
 /// </summary>
 /// <param name="node">表示面的输出节点。</param>
 /// <returns>返回RenderNodeAction。 如果希望接收此面的几何图形(多边形),请继续,否则返回RenderNodeAction.Skip。</returns>
 RenderNodeAction IExportContext.OnFaceBegin(FaceNode node)
 {
     return(RenderNodeAction.Proceed);
 }
Exemplo n.º 13
0
 public void OnFaceEnd(FaceNode inNode)
 {
 }
Exemplo n.º 14
0
 public FaceNode(FaceNode p, Face f)
 {
     sons   = new List <FaceNode>();
     face   = f;
     parent = p;
 }
Exemplo n.º 15
0
        public override SCNScene GetInitialScene()
        {
            FaceNode = new FaceNode(ARSCNFaceGeometry.Create(SCNView.Device));

            return(base.GetInitialScene());
        }
Exemplo n.º 16
0
 // OnFaceEnd marks the end of the current face being exported.
 // This method is invoked only when the custom exporter was set up to include geometric objects in the output stream (IncludeGeometricObjects).
 // This method is invoked even for faces that were skipped.
 public void OnFaceEnd(
     FaceNode InFaceNode             // face output node
     )
 {
     // Nothing to do here.
 }
Exemplo n.º 17
0
 public RenderNodeAction OnFaceBegin(FaceNode node)
 {
     Debug.WriteLine(" OnFaceBegin: " + node.NodeName);
     return(RenderNodeAction.Proceed);
 }
Exemplo n.º 18
0
 public RenderNodeAction OnFaceBegin(FaceNode node)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 19
0
 public void OnFaceEnd(FaceNode node)
 {
     Debug.WriteLine(" OnFaceEnd: " + node.NodeName);
 }
Exemplo n.º 20
0
 public RenderNodeAction OnFaceBegin(FaceNode node)
 {
     // This method is invoked only if the custom exporter was set to include faces.
     return(RenderNodeAction.Proceed);
 }
Exemplo n.º 21
0
        public RenderNodeAction OnFaceBegin(FaceNode node)
        {
            // remember, the exporter notifies about faces only
            // when it was requested at the time the export process started.
            // If it was not requested, the context would receive tessellated
            // meshes only, but not faces. Otherwise, both woudl be received
            // and it woudl be up to this context here to use what is needed.

            num++;
            return RenderNodeAction.Proceed;
        }
Exemplo n.º 22
0
 public RenderNodeAction OnFaceBegin(FaceNode node)
 {
     return(RenderNodeAction.Proceed);
 }
Exemplo n.º 23
0
 public void OnFaceEnd(FaceNode node)
 {
 }
Exemplo n.º 24
0
 public RenderNodeAction OnFaceBegin(FaceNode node)
 {
     Debug.Print("OnFaceBegin not implemented.");
     return(RenderNodeAction.Skip);
 }
Exemplo n.º 25
0
 public RenderNodeAction OnFaceBegin(FaceNode node)
 {
     Debug.Print("OnFaceBegin not implemented.");
     throw new NotImplementedException();
     return(RenderNodeAction.Skip);
 }
Exemplo n.º 26
0
        public static CLMSH ConvertOBJ(ObjObject obj)
        {
            tempVertex[] newVertices = new tempVertex[obj.Vertices];
            bool[]       inited      = new bool[obj.Vertices];
            uint         indices     = 256;

            uint[] indexBuffer = new uint[256];
            uint   index       = 0;

            Vector3 maxData = obj.Vertex[0];
            Vector3 minData = obj.Vertex[0];

            for (uint i = 0; i < obj.Vertices; i++)
            {
                inited[i] = false;

                if (maxData.x < obj.Vertex[i].x)
                {
                    maxData.x = obj.Vertex[i].x;
                }

                if (maxData.y < obj.Vertex[i].y)
                {
                    maxData.y = obj.Vertex[i].y;
                }

                if (maxData.z < obj.Vertex[i].z)
                {
                    maxData.z = obj.Vertex[i].z;
                }

                if (minData.x > obj.Vertex[i].x)
                {
                    minData.x = obj.Vertex[i].x;
                }

                if (minData.y > obj.Vertex[i].y)
                {
                    minData.y = obj.Vertex[i].y;
                }

                if (minData.z > obj.Vertex[i].z)
                {
                    minData.z = obj.Vertex[i].z;
                }
            }

            Vector3 dims = new Vector3();

            dims.x = maxData.x - minData.x;
            dims.y = maxData.y - minData.y;
            dims.z = maxData.z - minData.z;

            for (uint i = 0; i < obj.Faces; i++)
            {
                uint faceId   = index / 3;
                Face faceHere = obj.Face[i];

                for (uint k = 0; k < faceHere.Nodes; k++)
                {
                    FaceNode node = faceHere.Node[k];

                    if (!inited[node.Vertex])
                    {
                        inited[node.Vertex]                  = true;
                        newVertices[node.Vertex]             = new tempVertex(obj.Vertex[node.Vertex], obj.NormalVertex[node.NormalVertex], obj.TextureVertex[node.TextureVertex], faceId, faceHere.FaceId);
                        newVertices[node.Vertex].position.x /= dims.x;
                        newVertices[node.Vertex].position.y /= dims.y;
                        newVertices[node.Vertex].position.z /= dims.z;
                    }

                    newVertices[node.Vertex].AddFace(obj.NormalVertex[node.NormalVertex], faceId, faceHere.FaceId);

                    if (index >= indices)
                    {
                        indices += 256;
                        Array.Resize <uint>(ref indexBuffer, (int)indices);
                    }

                    indexBuffer[index] = node.Vertex;
                    index++;
                }
            }

            CLMSH retVal = new CLMSH(dims);

            for (uint i = 0; i < obj.Vertices; i++)
            {
                float normalLength = (float)Math.Sqrt(
                    Math.Pow(newVertices[i].normal.x, 2) +
                    Math.Pow(newVertices[i].normal.y, 2) +
                    Math.Pow(newVertices[i].normal.z, 2));

                newVertices[i].normal.x /= normalLength;
                newVertices[i].normal.y /= normalLength;
                newVertices[i].normal.z /= normalLength;

                Vertex v = new Vertex();
                v.pos  = newVertices[i].position;
                v.uv   = newVertices[i].uv;
                v.norm = newVertices[i].normal;
                retVal.AddVertex(v);
            }

            for (uint i = 0; i < index; i++)
            {
                tempVertex tv       = newVertices[indexBuffer[i]];
                uint       faceHere = i / 3;
                uint       next     = faceHere * 3 + ((i + 1) % 3);
                retVal.AddIndex(indexBuffer[i]);
                bool foundNeighbour = false;
                uint nIndex         = 0;

                for (uint k = 0; k < tv.nrFaces && !foundNeighbour; k++)
                {
                    uint faceStart = tv.faces[k] * 3;

                    for (uint j = 0; j < 3 && !foundNeighbour; j++)
                    {
                        foundNeighbour = indexBuffer[faceStart + j] == indexBuffer[next] &&
                                         tv.faces[k] != faceHere;

                        if (foundNeighbour)
                        {
                            for (int h = 0; h < 3; h++)
                            {
                                if (indexBuffer[faceStart + h] != indexBuffer[i] &&
                                    indexBuffer[faceStart + h] != indexBuffer[next])
                                {
                                    nIndex = indexBuffer[faceStart + h];
                                }
                            }
                        }
                    }
                }

                if (!foundNeighbour)
                {
                    nIndex = indexBuffer[i];
                }

                retVal.AddIndex(nIndex);
            }

            return(retVal);
        }
Exemplo n.º 27
0
 public void OnFaceEnd(FaceNode node)
 {
     Debug.Print("OnFaceEnd not implemented.");
     throw new NotImplementedException();
 }
Exemplo n.º 28
0
 public void OnFaceEnd(FaceNode node)
 {
 }
Exemplo n.º 29
0
 public void OnFaceEnd(FaceNode node)
 {
     // This method is invoked only if the
     // custom exporter was set to include faces.
 }
Exemplo n.º 30
0
 public void setRoot(Face f)
 {
     root = new FaceNode(f);
 }
 /// <summary>
 ///     This method marks the beginning of a Face to be exported.
 /// </summary>
 /// <param name="node">The face node.</param>
 /// <returns></returns>
 public RenderNodeAction OnFaceBegin(FaceNode node)
 {
     // just go on with export
     return(RenderNodeAction.Proceed);
 }
Exemplo n.º 32
0
    public float strength = 2f; // the spring constant

    #endregion Fields

    #region Constructors

    public Edge(FaceNode _n1, FaceNode _n2, float _strength = 2f)
    {
        n1 = _n1;
        n2 = _n2;
        strength = _strength;
    }
Exemplo n.º 33
0
 // Adds a son to the node
 public void addSon(FaceNode fn)
 {
     sons.Add(fn);
     hasSons = true;
 }