Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
TexturedBatch2D.cs
浏览该文件的文档.
1namespace Engine.Graphics {
9
10 public void QueueBatch(TexturedBatch2D batch, Matrix? matrix = null, Color? color = null) {
11 int count = TriangleVertices.Count;
12 TriangleVertices.AddRange(batch.TriangleVertices);
13 for (int i = 0; i < batch.TriangleIndices.Count; i++) {
14 TriangleIndices.Add(batch.TriangleIndices[i] + count);
15 }
16 if (matrix.HasValue
17 && matrix != Matrix.Identity) {
18 TransformTriangles(matrix.Value, count);
19 }
20 if (color.HasValue
21 && color != Color.White) {
22 TransformTrianglesColors(color.Value, count);
23 }
24 }
25
26 public void QueueTriangle(Vector2 p1,
27 Vector2 p2,
28 Vector2 p3,
29 float depth,
30 Vector2 texCoord1,
31 Vector2 texCoord2,
32 Vector2 texCoord3,
33 Color color) {
34 int count = TriangleVertices.Count;
35 TriangleVertices.Count += 3;
36 TriangleVertices.Array[count] = new VertexPositionColorTexture(new Vector3(p1.X, p1.Y, depth), color, texCoord1);
37 TriangleVertices.Array[count + 1] = new VertexPositionColorTexture(new Vector3(p2.X, p2.Y, depth), color, texCoord2);
38 TriangleVertices.Array[count + 2] = new VertexPositionColorTexture(new Vector3(p3.X, p3.Y, depth), color, texCoord3);
39 int count2 = TriangleIndices.Count;
40 TriangleIndices.Count += 3;
41 TriangleIndices.Array[count2] = count;
42 TriangleIndices.Array[count2 + 1] = count + 1;
43 TriangleIndices.Array[count2 + 2] = count + 2;
44 }
45
46 public void QueueTriangle(Vector2 p1,
47 Vector2 p2,
48 Vector2 p3,
49 float depth,
50 Vector2 texCoord1,
51 Vector2 texCoord2,
52 Vector2 texCoord3,
53 Color color1,
54 Color color2,
55 Color color3) {
56 int count = TriangleVertices.Count;
57 TriangleVertices.Count += 3;
58 TriangleVertices.Array[count] = new VertexPositionColorTexture(new Vector3(p1.X, p1.Y, depth), color1, texCoord1);
59 TriangleVertices.Array[count + 1] = new VertexPositionColorTexture(new Vector3(p2.X, p2.Y, depth), color2, texCoord2);
60 TriangleVertices.Array[count + 2] = new VertexPositionColorTexture(new Vector3(p3.X, p3.Y, depth), color3, texCoord3);
61 int count2 = TriangleIndices.Count;
62 TriangleIndices.Count += 3;
63 TriangleIndices.Array[count2] = count;
64 TriangleIndices.Array[count2 + 1] = count + 1;
65 TriangleIndices.Array[count2 + 2] = count + 2;
66 }
67
68 public void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Vector2 texCoord1, Vector2 texCoord2, Color color) {
69 int count = TriangleVertices.Count;
70 TriangleVertices.Count += 4;
72 new Vector3(corner1.X, corner1.Y, depth),
73 color,
74 new Vector2(texCoord1.X, texCoord1.Y)
75 );
76 TriangleVertices.Array[count + 1] = new VertexPositionColorTexture(
77 new Vector3(corner1.X, corner2.Y, depth),
78 color,
79 new Vector2(texCoord1.X, texCoord2.Y)
80 );
81 TriangleVertices.Array[count + 2] = new VertexPositionColorTexture(
82 new Vector3(corner2.X, corner2.Y, depth),
83 color,
84 new Vector2(texCoord2.X, texCoord2.Y)
85 );
86 TriangleVertices.Array[count + 3] = new VertexPositionColorTexture(
87 new Vector3(corner2.X, corner1.Y, depth),
88 color,
89 new Vector2(texCoord2.X, texCoord1.Y)
90 );
91 int count2 = TriangleIndices.Count;
92 TriangleIndices.Count += 6;
93 TriangleIndices.Array[count2] = count;
94 TriangleIndices.Array[count2 + 1] = count + 1;
95 TriangleIndices.Array[count2 + 2] = count + 2;
96 TriangleIndices.Array[count2 + 3] = count + 2;
97 TriangleIndices.Array[count2 + 4] = count + 3;
98 TriangleIndices.Array[count2 + 5] = count;
99 }
100
101 public void QueueQuad(Vector2 p1,
102 Vector2 p2,
103 Vector2 p3,
104 Vector2 p4,
105 float depth,
106 Vector2 texCoord1,
107 Vector2 texCoord2,
108 Vector2 texCoord3,
109 Vector2 texCoord4,
110 Color color) {
111 int count = TriangleVertices.Count;
112 TriangleVertices.Count += 4;
113 TriangleVertices.Array[count] = new VertexPositionColorTexture(new Vector3(p1.X, p1.Y, depth), color, texCoord1);
114 TriangleVertices.Array[count + 1] = new VertexPositionColorTexture(new Vector3(p2.X, p2.Y, depth), color, texCoord2);
115 TriangleVertices.Array[count + 2] = new VertexPositionColorTexture(new Vector3(p3.X, p3.Y, depth), color, texCoord3);
116 TriangleVertices.Array[count + 3] = new VertexPositionColorTexture(new Vector3(p4.X, p4.Y, depth), color, texCoord4);
117 int count2 = TriangleIndices.Count;
118 TriangleIndices.Count += 6;
119 TriangleIndices.Array[count2] = count;
120 TriangleIndices.Array[count2 + 1] = count + 1;
121 TriangleIndices.Array[count2 + 2] = count + 2;
122 TriangleIndices.Array[count2 + 3] = count + 2;
123 TriangleIndices.Array[count2 + 4] = count + 3;
124 TriangleIndices.Array[count2 + 5] = count;
125 }
126
127 public void QueueQuad(Vector2 p1,
128 Vector2 p2,
129 Vector2 p3,
130 Vector2 p4,
131 float depth,
132 Vector2 texCoord1,
133 Vector2 texCoord2,
134 Vector2 texCoord3,
135 Vector2 texCoord4,
136 Color color1,
137 Color color2,
138 Color color3,
139 Color color4) {
140 int count = TriangleVertices.Count;
141 TriangleVertices.Count += 4;
142 TriangleVertices.Array[count] = new VertexPositionColorTexture(new Vector3(p1.X, p1.Y, depth), color1, texCoord1);
143 TriangleVertices.Array[count + 1] = new VertexPositionColorTexture(new Vector3(p2.X, p2.Y, depth), color2, texCoord2);
144 TriangleVertices.Array[count + 2] = new VertexPositionColorTexture(new Vector3(p3.X, p3.Y, depth), color3, texCoord3);
145 TriangleVertices.Array[count + 3] = new VertexPositionColorTexture(new Vector3(p4.X, p4.Y, depth), color4, texCoord4);
146 int count2 = TriangleIndices.Count;
147 TriangleIndices.Count += 6;
148 TriangleIndices.Array[count2] = count;
149 TriangleIndices.Array[count2 + 1] = count + 1;
150 TriangleIndices.Array[count2 + 2] = count + 2;
151 TriangleIndices.Array[count2 + 3] = count + 2;
152 TriangleIndices.Array[count2 + 4] = count + 3;
153 TriangleIndices.Array[count2 + 5] = count;
154 }
155
156 public void Flush(bool clearAfterFlush = true) {
157 Flush(PrimitivesRenderer2D.ViewportMatrix(), clearAfterFlush);
158 }
159 }
160}
Engine.Vector3 Vector3
void TransformTriangles(Matrix matrix, int start=0, int end=-1)
readonly DynamicArray< int > TriangleIndices
readonly DynamicArray< VertexPositionColorTexture > TriangleVertices
void TransformTrianglesColors(Color color, int start=0, int end=-1)
static readonly BlendState AlphaBlend
static readonly DepthStencilState None
static readonly RasterizerState CullNoneScissor
void QueueQuad(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float depth, Vector2 texCoord1, Vector2 texCoord2, Vector2 texCoord3, Vector2 texCoord4, Color color1, Color color2, Color color3, Color color4)
void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Vector2 texCoord1, Vector2 texCoord2, Color color)
void QueueTriangle(Vector2 p1, Vector2 p2, Vector2 p3, float depth, Vector2 texCoord1, Vector2 texCoord2, Vector2 texCoord3, Color color1, Color color2, Color color3)
void QueueTriangle(Vector2 p1, Vector2 p2, Vector2 p3, float depth, Vector2 texCoord1, Vector2 texCoord2, Vector2 texCoord3, Color color)
void QueueBatch(TexturedBatch2D batch, Matrix? matrix=null, Color? color=null)
void QueueQuad(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float depth, Vector2 texCoord1, Vector2 texCoord2, Vector2 texCoord3, Vector2 texCoord4, Color color)
void Flush(bool clearAfterFlush=true)
static Color White
static readonly Matrix Identity