示例#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);
        }
示例#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];
        }
示例#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);
        }
示例#5
0
 public bool Equals(GeometryData other)
 {
     return(Mesh == other.Mesh);
 }
示例#6
0
 public PolygonGroup(GeometryData sharedShapeData, int capacity) : base(capacity)
 {
     this.sharedShapeData = sharedShapeData;
     transforms           = new VertexTransformColor[capacity];
     group = null;
 }