Exemple #1
0
        /*         v6---------------v7
         *         /|               /|
         *        / |              / |
         *       /  |             /  |
         *     v2----------------v3  |
         |   |            |   |
         |  v4----------- |---v5
         |  /             |  /
         | /              | /
         |/               |/
         |      v0---------------v1
         |
         */

        public void GenerateGeometry(GraphicsDevice Graphics)
        {
            Geom = new Geometry3D("GridGeom");
            //Geom.SetVertexBuffer( new VertexPositionTexture[0]);

            Geom.SetTextures(new string[] { "GridColors" });

            BasicEffect BasicEffect = new BasicEffect(Graphics);

            BasicEffect.TextureEnabled = true;
            Geom.Shader       = BasicEffect;
            Geom.HasCull      = false;
            Geom.RenderBucket = Geometry3D.RenderQueue.Solid;
        }
        public virtual void GenerateGeometry(RenderManager RenderManager)
        {
            Geom = new Geometry3D(Name);
            Geom.SetTextures(new string[] { "Missing" });
            BasicEffect BasicEffect = new BasicEffect(RenderManager.Graphics);

            BasicEffect.TextureEnabled = true;
            Geom.Shader        = BasicEffect;
            Geom.HasCull       = false;
            Geom.LocalPosition = A;
            Geom.WorldPosition = WorldPosition;
            Geom.RenderBucket  = Geometry3D.RenderQueue.Solid;

            TransGeom = new Geometry3D("Trans" + Name);
            TransGeom.SetTextures(new string[] { "Missing" });
            BasicEffect.TextureEnabled = true;
            Geom.Shader             = BasicEffect;
            TransGeom.HasCull       = false;
            TransGeom.LocalPosition = A;
            TransGeom.WorldPosition = WorldPosition;
            TransGeom.RenderBucket  = Geometry3D.RenderQueue.Transparent;
        }
Exemple #3
0
        public void GenerateLookatCube(GraphicsDevice Graphics)
        {
            int[] Indices = new int[] { 2, 0, 1, 1, 3, 2, 7, 5, 4, 4, 6, 7, 6, 4, 0, 0, 2, 6, 3, 1, 5, 5, 7, 3, 6, 2, 3, 3, 7, 6, 0, 4, 5, 5, 1, 0 };

            Vector3[] LineLookup = new Vector3[8]
            {
                //X Axis
                new Vector3(-1.0f, -1.0f, -1.0f) * (Size + Buffer),
                new Vector3(1.0f, -1.0f, -1.0f) * (Size + Buffer),
                new Vector3(-1.0f, -1.0f, 1.0f) * (Size + Buffer),
                new Vector3(1.0f, -1.0f, 1.0f) * (Size + Buffer),

                new Vector3(-1.0f, 1.0f, -1.0f) * (Size + Buffer),
                new Vector3(1.0f, 1.0f, -1.0f) * (Size + Buffer),
                new Vector3(-1.0f, 1.0f, 1.0f) * (Size + Buffer),
                new Vector3(1.0f, 1.0f, 1.0f) * (Size + Buffer)
            };

            Geom = new Geometry3D("LookatCube");
            Geom.SetTextures(new string[] { "GridColors" });
            BasicEffect BasicEffect = new BasicEffect(Graphics);

            BasicEffect.TextureEnabled = true;
            Geom.Shader       = BasicEffect;
            Geom.Position     = Position;
            Geom.HasCull      = false;
            Geom.RenderBucket = RenderQueue.Solid;

            List <VertexPositionTexture> VertexList = new List <VertexPositionTexture>();
            Vector2 Color = new Vector2();

            switch (CubeColor)
            {
            case "red":
                Color = new Vector2(0.1875f, 0.1875f);
                break;

            case "green":
                Color = new Vector2(0.1875f, 0.3125f);
                break;

            case "blue":
                Color = new Vector2(0.3125f, 0.1875f);
                break;

            case "gray":
                Color = new Vector2(0.3125f, 0.3125f);
                break;

            default:
                Color = new Vector2(0.8125f, 0.8125f);
                break;
            }

            for (int i = Indices.Length - 1; i >= 0; i--)
            {
                VertexList.Add(new VertexPositionTexture(LineLookup[Indices[i]], Color));
            }

            VertexBuffer VertexBuffer = new VertexBuffer(Graphics, CubeVertex.VertexDeclaration, VertexList.Count, BufferUsage.WriteOnly);

            VertexBuffer.SetData(VertexList.ToArray());
            Geom.SetVertexBuffer(VertexBuffer);
        }