示例#1
0
        public void removeMutliBlock()
        {
            List <NodeLocation> newNodes = new List <NodeLocation>();

            foreach (NodeLocation n in myEditor.context.selectedNodes)
            {
                NodeLocation nl = n;
                //determine the opposite face
                int faceId = (int)myEditor.context.currentFace;
                if ((faceId & 0x1) == 1)
                {
                    faceId--;
                }
                else
                {
                    faceId++;
                }

                newNodes.Add(nl.getNeighborLocation((Face)faceId));
                //send delete blocks command
                DeleteBlockCommand cmd = new DeleteBlockCommand(nl);
                myEditor.world.dispatch(cmd);
            }

            myEditor.context.selectedNodes.Clear();
            myEditor.context.selectedNodes.AddRange(newNodes);
        }
示例#2
0
        public void createBlock()
        {
            //get current material
            UInt32 mat = Terrain.MaterialManager.getMaterialIndex(myEditor.context.currentMaterial);

            //get block selection
            NodeLocation nl = myEditor.context.currentLocation;

            if (nl != null)
            {
                nl = nl.getNeighborLocation(myEditor.context.currentFace);

                //send create blocks cmd
                AddBlockCommand cmd = new AddBlockCommand(nl, mat);
                myEditor.world.dispatch(cmd);
            }
        }
示例#3
0
        public NodeLocation getMouseOverLocation(int x, int y)
        {
            Ray r = myEditor.camera.getPickRay(x, (int)ImGui.displaySize.Y - y);

            myCurrentHit      = myEditor.world.getNodeIntersection(r, myEditor.camera.near, myEditor.camera.far);
            myClampedLocation = null;

            if (myCurrentHit != null)
            {
                if (myEditor.cursorDepth <= myCurrentHit.node.depth)
                {
                    Node n = myCurrentHit.node;
                    myClampedLocation = myCurrentHit.node.location;
                    while (n.depth != myEditor.cursorDepth)
                    {
                        n = n.myParent;
                        myClampedLocation = n.location;
                    }
                }
                else
                {
                    myClampedLocation = new NodeLocation(myCurrentHit.location, myEditor.cursorDepth);

                    //may need to adjust the clamped location to be within the node that is hit
                    //since sometimes the conversion to a clamped node location causes it to be the next node since
                    //nodes boundaries are [min..max) inclusion
                    if (myCurrentHit.node.contains(myClampedLocation) == false)
                    {
                        foreach (Face f in Enum.GetValues(typeof(Face)))
                        {
                            NodeLocation nl = myClampedLocation.getNeighborLocation(f);
                            if (myCurrentHit.node.contains(nl) == true)
                            {
                                myClampedLocation = nl;
                                break;
                            }
                        }
                    }
                }
            }

            return(myClampedLocation);
        }
示例#4
0
        public void createMultiBlocks()
        {
            //get current material
            UInt32 mat = MaterialManager.getMaterialIndex(myEditor.context.currentMaterial);
            List <NodeLocation> newNodes = new List <NodeLocation>();

            foreach (NodeLocation n in myEditor.context.selectedNodes)
            {
                NodeLocation nl = n;
                nl = nl.getNeighborLocation(myEditor.context.currentFace);
                newNodes.Add(nl);

                //send create blocks cmd
                AddBlockCommand cmd = new AddBlockCommand(nl, mat);
                myEditor.world.dispatch(cmd);
            }

            myEditor.context.selectedNodes.Clear();
            myEditor.context.selectedNodes.AddRange(newNodes);
        }