コード例 #1
0
ファイル: EditingVoxture.cs プロジェクト: littlebeast/Outpost
        public void makeSelection(bool isSelected)
        {
            if(isSelected)
            {
                for(int i=0; i<8; i++)
                {
                    wireframeVertices[i].Color = Color.Red;
                }
            }
            else
            {
                for(int i=0; i<8; i++)
                {
                    wireframeVertices[i].Color = Color.Black;
                }
            }

            wfVBuff.SetData<VertexPositionColor>(wireframeVertices);

            lastSelected = null;
        }
コード例 #2
0
ファイル: EditingVoxture.cs プロジェクト: littlebeast/Outpost
        public void makeVertices(float spread, bool isSelected)
        {
           float midpoint = (voxelSize * Sizes.VoxelsPerEdge + spread * (Sizes.VoxelsPerEdge - 1)) * 0.5f;

            List<VertexPositionColorNormal> verts = new List<VertexPositionColorNormal>();

            List<VertexPositionColor> wfVerts = new List<VertexPositionColor>();

            for (int x = 0; x < Sizes.VoxelsPerEdge; x++)
            {
                float xPos = (x * (voxelSize + spread)) - midpoint;

                for (int y = 0; y < Sizes.VoxelsPerEdge; y++)
                {
                    float yPos = (y * (voxelSize + spread)) - midpoint;

                    for (int z = 0; z < Sizes.VoxelsPerEdge; z++)
                    {
                        float zPos = (z * (voxelSize + spread)) - midpoint;

                        Vector3 pos = new Vector3(xPos, yPos, zPos);

                        makeVoxelVerts(verts, vox[x, y, z].color, pos);
                    }
                }
            }

            {
                Color c = Color.Black;
                if (isSelected)
                    c = Color.Red;

                float low = -midpoint;
                float high = (Sizes.VoxelsPerEdge * voxelSize + (Sizes.VoxelsPerEdge - 1) * spread) - midpoint;

                wfVerts.Add(new VertexPositionColor(new Vector3(low, low, low), c));
                wfVerts.Add(new VertexPositionColor(new Vector3(high, low, low), c));
                wfVerts.Add(new VertexPositionColor(new Vector3(high, high, low), c));
                wfVerts.Add(new VertexPositionColor(new Vector3(low, high, low), c));
                wfVerts.Add(new VertexPositionColor(new Vector3(low, low, high), c));
                wfVerts.Add(new VertexPositionColor(new Vector3(high, low, high), c));
                wfVerts.Add(new VertexPositionColor(new Vector3(high, high, high), c));
                wfVerts.Add(new VertexPositionColor(new Vector3(low, high, high), c));
            }

            vertices = verts.ToArray();
            wireframeVertices = wfVerts.ToArray();

            vBuff.SetData<VertexPositionColorNormal>(vertices);
            wfVBuff.SetData<VertexPositionColor>(wireframeVertices);

            lastSelected = null;
        }
コード例 #3
0
ファイル: EditingVoxture.cs プロジェクト: littlebeast/Outpost
        public void makeSelection(OutpostLibrary.IntVector3 selected)
        {
            if (selected == lastSelected)
                return;  //it's still selected

            int voxPerEdge = OutpostLibrary.Navigation.Sizes.VoxelsPerEdge;

            if ((lastSelected.X >= 0 && lastSelected.X < voxPerEdge) &&
                (lastSelected.Y >= 0 && lastSelected.Y < voxPerEdge) &&
                (lastSelected.Z >= 0 && lastSelected.Z < voxPerEdge))
            {
                int offset = lastSelected.X * voxPerEdge * voxPerEdge +
                             lastSelected.Y * voxPerEdge +
                             lastSelected.Z;
                offset = offset * 8; //a bit "magic number"-y, but it's the number of vertices per voxel.
                for (int i = 0; i < 8; i++)
                {
                    wireframeVertices[i + offset].Color = Color.Black;
                }
            }

            if ((selected.X >= 0 && selected.X < voxPerEdge) &&
                (selected.Y >= 0 && selected.Y < voxPerEdge) &&
                (selected.Z >= 0 && selected.Z < voxPerEdge))
            {
                int offset = selected.X * voxPerEdge * voxPerEdge +
                             selected.Y * voxPerEdge +
                             selected.Z;
                offset = offset * 8; //a bit "magic number"-y, but it's the number of vertices per voxel.
                for (int i = 0; i < 8; i++)
                {
                    wireframeVertices[i + offset].Color = Color.Red;
                }
            }

            lastSelected = selected;

            wfVBuff.SetData<VertexPositionColor>(wireframeVertices);
            //actually, is that even necessary?
            //ah well
            //it doesn't hurt

            //I mean... except for optimization
            //but I don't think it makes a big difference there
        }
コード例 #4
0
ファイル: EditingVoxture.cs プロジェクト: littlebeast/Outpost
        public void makeVertices(float spread, OutpostLibrary.IntVector3 selected)
        {
            float midpoint = (voxelSize * Sizes.VoxelsPerEdge + spread * (Sizes.VoxelsPerEdge - 1)) * 0.5f;

            List<VertexPositionColorNormal> verts = new List<VertexPositionColorNormal>();

            List<VertexPositionColor> wfVerts = new List<VertexPositionColor>();

            for (int x = 0; x < Sizes.VoxelsPerEdge; x++)
            {
                float xPos = (x * (voxelSize + spread)) - midpoint;

                for (int y = 0; y < Sizes.VoxelsPerEdge; y++)
                {
                    float yPos = (y * (voxelSize + spread)) - midpoint;

                    for (int z = 0; z < Sizes.VoxelsPerEdge; z++)
                    {
                        float zPos = (z * (voxelSize + spread)) - midpoint;

                        Vector3 pos = new Vector3(xPos, yPos, zPos);

                        bool isSelected = false;
                        if (selected.X == x && selected.Y == y && selected.Z == z)
                            isSelected = true;

                        makeVoxelVerts(verts, wfVerts, vox[x, y, z].color, pos, isSelected);
                    }
                }
            }

            vertices = verts.ToArray();
            wireframeVertices = wfVerts.ToArray();

            vBuff.SetData<VertexPositionColorNormal>(vertices);
            wfVBuff.SetData<VertexPositionColor>(wireframeVertices);

            lastSelected = selected;
        }