コード例 #1
0
ファイル: FunctionalObject.cs プロジェクト: samhogan/AUG
    //adds a node to the mesh and to the node list
    protected void addNode <T>(MeshBuilder mb, Vector3 pos, Quaternion rot) where T : Node
    {
        //move the mesh out just a bit to prevent z fighting
        //maybe add the node to the list first then change this
        pos += rot * Vector3.up * .01f;


        //set colors of nodes
        //TODO: change this
        Sub sub = Sub.Foyaite;

        if (typeof(T) == typeof(PowerInNode))
        {
            sub = Sub.Vegitation1;
        }
        else if (typeof(T) == typeof(PowerOutNode))
        {
            sub = Sub.Foyaite;
        }
        else if (typeof(T) == typeof(NeutralNode))
        {
            sub = Sub.IronDioxide;
        }


        // ProcMesh.addCube(mb, pos, .4f, .4f, .1f, Sub.Foyaite, rot);
        ProcMesh.addQuad(mb, pos, rot * Vector3.right * .4f, rot * Vector3.forward * .4f, sub);

        //create the node
        Node node;

        if (typeof(T) == typeof(PowerInNode))
        {
            node = new PowerInNode(pos, rot)
            {
                go = this.gameObject
            }
        }
        ;
        else if (typeof(T) == typeof(PowerOutNode))
        {
            node = new PowerOutNode(pos, rot)
            {
                go = this.gameObject
            }
        }
        ;
        else
        {
            node = new NeutralNode(pos, rot)
            {
                go = this.gameObject
            }
        };

        nodes.Add(node);
        Node.curNodes.Add(node);
    }
}
コード例 #2
0
    //build the mesh of the square made up of these four voxels
    private static void marchSquare(MeshBuilder mb, SVox v1, SVox v2, SVox v3, SVox v4, Sub sub)
    {
        //calculate the cell type
        int cellType = 0;

        if (v1.state)
        {
            cellType |= 1;
        }
        if (v2.state)
        {
            cellType |= 2;
        }
        if (v3.state)
        {
            cellType |= 4;
        }
        if (v4.state)
        {
            cellType |= 8;
        }

        //Sub sub = Sub.Foyaite;
        //now build the mesh based on the cell type
        switch (cellType)
        {
        case 0:
            return;

        case 1:
            ProcMesh.addTri(mb, v1.pos, v1.yEdge, v1.xEdge, sub);
            return;

        case 2:
            ProcMesh.addTri(mb, v2.pos, v1.xEdge, v2.yEdge, sub);
            return;

        case 3:
            ProcMesh.addQuad(mb, v1.pos, v1.yEdge, v2.yEdge, v2.pos, sub);
            return;

        case 4:
            ProcMesh.addTri(mb, v3.pos, v3.xEdge, v1.yEdge, sub);
            return;

        case 5:
            ProcMesh.addQuad(mb, v1.pos, v3.pos, v3.xEdge, v1.xEdge, sub);

            return;

        case 6:
            ProcMesh.addTri(mb, v3.pos, v3.xEdge, v1.yEdge, sub);
            ProcMesh.addTri(mb, v2.pos, v1.xEdge, v2.yEdge, sub);
            //ProcMesh.addQuad(mb, v1.yEdge, v3.xEdge, v2.yEdge, v1.xEdge, Sub.Limestone);
            return;

        case 7:
            ProcMesh.addTri(mb, v1.pos, v3.pos, v2.pos, sub);
            ProcMesh.addQuad(mb, v3.pos, v3.xEdge, v2.yEdge, v2.pos, sub);
            return;

        case 8:
            ProcMesh.addTri(mb, v4.pos, v2.yEdge, v3.xEdge, sub);
            return;

        case 9:
            ProcMesh.addTri(mb, v1.pos, v1.yEdge, v1.xEdge, sub);
            ProcMesh.addTri(mb, v4.pos, v2.yEdge, v3.xEdge, sub);
            //ProcMesh.addQuad(mb, v1.yEdge, v3.xEdge, v2.yEdge, v1.xEdge, Sub.Limestone);
            return;

        case 10:
            ProcMesh.addQuad(mb, v2.pos, v1.xEdge, v3.xEdge, v4.pos, sub);
            return;

        case 11:
            ProcMesh.addTri(mb, v1.pos, v4.pos, v2.pos, sub);
            ProcMesh.addQuad(mb, v1.pos, v1.yEdge, v3.xEdge, v4.pos, sub);
            return;

        case 12:
            ProcMesh.addQuad(mb, v3.pos, v4.pos, v2.yEdge, v1.yEdge, sub);
            return;

        case 13:
            ProcMesh.addTri(mb, v1.pos, v3.pos, v4.pos, sub);
            ProcMesh.addQuad(mb, v1.pos, v4.pos, v2.yEdge, v1.xEdge, sub);
            return;

        case 14:
            ProcMesh.addTri(mb, v3.pos, v4.pos, v2.pos, sub);
            ProcMesh.addQuad(mb, v3.pos, v2.pos, v1.xEdge, v1.yEdge, sub);
            return;

        case 15:
            //ProcMesh.addQuad(mb, v1.pos, v3.pos, v4.pos, v2.pos, sub);//Sub.TEST);
            return;

        default:
            return;
        }
    }