Esempio n. 1
0
        public GeometryElements(uint batchSize, GeometryData sharedGeometry, RenderOptions sharedRenderOptions) : base(BatchExecution.DrawElements, batchSize)
        {
            this.sharedGeometry      = sharedGeometry;
            this.sharedRenderOptions = sharedRenderOptions;

            maxBatchSize = (uint)(short.MaxValue / TotalIndices);

            if (BatchSize > maxBatchSize)
            {
                throw new RelatusException($"Given the shared geometry, PolygonElements does not support support a batch size greater than {maxBatchSize}.", new ArgumentOutOfRangeException());
            }

            vertexPositions = new VertexPosition[batchSize * TotalVertices];
            transforms      = new VertexTransform[batchSize * TotalVertices];
            colors          = new VertexColor[batchSize * TotalVertices];

            indices = new short[batchSize * TotalIndices];

            for (int i = 0; i < batchSize; i++)
            {
                int start  = TotalIndices * i;
                int buffer = TotalVertices * i;

                for (int j = 0; j < TotalIndices; j++)
                {
                    indices[start + j] = (short)(buffer + this.sharedGeometry.Mesh.Indices[j]);
                }
            }

            indexBuffer = new IndexBuffer(graphicsDevice, typeof(short), indices.Length, BufferUsage.WriteOnly);
            indexBuffer.SetData(indices);
        }
        static SpriteElementsInstanced()
        {
            graphicsDevice = Engine.Graphics.GraphicsDevice;
            spriteShader   = AssetManager.GetEffect("Relatus_RelatusEffect");
            spritePass     = spriteShader.Techniques[2].Passes[0];

            sharedGeometry = GeometryManager.GetShapeData(ShapeType.Square);
        }
Esempio n. 3
0
        public GeometryElementsInstanced(uint batchSize, GeometryData sharedGeometry, RenderOptions sharedRenderOptions) : base(BatchExecution.DrawElementsInstanced, batchSize)
        {
            this.sharedGeometry      = sharedGeometry;
            this.sharedRenderOptions = sharedRenderOptions;

            transforms = new VertexTransform[batchSize];
            colors     = new VertexColor[batchSize];
        }
Esempio n. 4
0
        public static void DrawTriangle(Vector3 a, Vector3 b, Vector3 c, Color color, Camera camera)
        {
            GeometryData  temp          = new GeometryData(new Mesh(new Vector3[] { a, b, c }, new short[] { 0, 1, 2 }));
            RenderOptions renderOptions = new RenderOptions(); //{ RasterizerState = RasterizerState.CullNone };

            using GeometryElements geometryGroup = new GeometryElements(1, temp, renderOptions);
            geometryGroup.Add(new Polygon()
            {
                GeometryData = temp, RenderOptions = renderOptions, Tint = color
            });
            geometryGroup.ApplyChanges();
            geometryGroup.Draw(camera);
        }
Esempio n. 5
0
 public bool Equals(GeometryData other)
 {
     return(Mesh == other.Mesh);
 }
Esempio n. 6
0
 public PolygonGroup(GeometryData sharedShapeData, int capacity) : base(capacity)
 {
     this.sharedShapeData = sharedShapeData;
     transforms           = new VertexTransformColor[capacity];
     group = null;
 }