public static byte[] TransformToBytesByBuffer(ref VertexPositionColorTextureColor vpcc) { transform_buffer[0] = vpcc.b_x1; transform_buffer[1] = vpcc.b_x2; transform_buffer[2] = vpcc.b_x3; transform_buffer[3] = vpcc.b_x4; transform_buffer[4] = vpcc.b_y1; transform_buffer[5] = vpcc.b_y2; transform_buffer[6] = vpcc.b_y3; transform_buffer[7] = vpcc.b_y4; transform_buffer[8] = vpcc.b_u1; transform_buffer[9] = vpcc.b_u2; transform_buffer[10] = vpcc.b_u3; transform_buffer[11] = vpcc.b_u4; transform_buffer[12] = vpcc.b_v1; transform_buffer[13] = vpcc.b_v2; transform_buffer[14] = vpcc.b_v3; transform_buffer[15] = vpcc.b_v4; transform_buffer[16] = vpcc.R; transform_buffer[17] = vpcc.G; transform_buffer[18] = vpcc.B; transform_buffer[19] = vpcc.A; transform_buffer[20] = vpcc.R2; transform_buffer[21] = vpcc.G2; transform_buffer[22] = vpcc.B2; transform_buffer[23] = vpcc.A2; return(transform_buffer); }
public static byte[] TransformToBytes(ref VertexPositionColorTextureColor vpcc) { return(new byte[] { vpcc.b_x1, vpcc.b_x2, vpcc.b_x3, vpcc.b_x4, vpcc.b_y1, vpcc.b_y2, vpcc.b_y3, vpcc.b_y4, vpcc.b_u1, vpcc.b_u2, vpcc.b_u3, vpcc.b_u4, vpcc.b_v1, vpcc.b_v2, vpcc.b_v3, vpcc.b_v4, vpcc.R, vpcc.G, vpcc.B, vpcc.A, vpcc.R2, vpcc.G2, vpcc.B2, vpcc.A2, }); }
public void Transform(ref VertexPositionColorTextureColor vertex) { float x = vertex.X - worldX; float y = vertex.Y - worldY; float dist = (float)Math.Sqrt(x * x + y * y); if (dist < Radius) { float theta = Interpolation.Apply(0, angle, (Radius - dist) / Radius); float cos = MathUtils.Cos(theta), sin = MathUtils.Sin(theta); vertex.X = cos * x - sin * y + worldX; vertex.Y = sin * x + cos * y + worldY; } }
public void Transform(ref VertexPositionColorTextureColor vertex) { vertex.X += MathUtils.RandomTriangle(-JitterX, JitterY); vertex.Y += MathUtils.RandomTriangle(-JitterX, JitterY); }
public void Draw(Texture texture, float[] vertices, float[] uvs, int numVertices, int[] indices, Color color, Color darkColor, IVertexEffect vertexEffect) { var numIndices = indices.Length; if (texture != lastTexture) { Flush(); lastTexture = texture; mesh.SetTexture(texture); } if (this.verticesLength + numVertices >= this.maxVerticesLength || this.indicesLength + numIndices > this.maxIndicesLength) { Flush(); // overflow ..... to split ... //if (numVertices >= this.maxVerticesLength || numIndices > this.maxIndicesLength) //{ // int lenVertices = numVertices; // int lenIndices = indices.Length; // // full bufer // int maxVV = maxVerticesLength - 2; // int maxII = maxIndicesLength - 6; // var verticesA = GenCopyed(vertices, 0, maxVV); // var uvsA = GenCopyed(uvs, 0, maxVV); // var indicesA = GenCopyed(indices, 0, maxII); // Draw(texture, verticesA, uvsA, maxVV, indicesA, color, darkColor, vertexEffect); // // remain // var verticesB = GenCopyed(vertices, maxVV, lenVertices - maxVV); // var uvsB = GenCopyed(uvs, maxVV, lenVertices - maxVV); // var indicesB = GenCopyed(indices, maxII, lenIndices - maxII); // Draw(texture, verticesB, uvsB, lenVertices - maxVV, indicesB, color, darkColor, vertexEffect); // return; //} } var indexStart = this.indicesLength; var offset = this.verticesLength; var indexEnd = indexStart + numIndices; var meshIndices = this.indices; for (int i = 0; indexStart < indexEnd; i++) { meshIndices[indexStart] = (uint)(indices[i] + offset); indexStart = indexStart + 1; } this.indicesLength = this.indicesLength + numIndices; var vertexStart = this.verticesLength; var vertexEnd = vertexStart + numVertices; var vertex = this.vertex; if (vertexEffect != null) { for (int v = 0; vertexStart < vertexEnd; vertexStart += 1, v += 2) { tempVertex.X = vertices[v + 0]; tempVertex.Y = vertices[v + 1]; tempVertex.U = uvs[v + 0]; tempVertex.V = uvs[v + 1]; tempVertex.Light = color; tempVertex.Dark = darkColor; vertexEffect.Transform(ref tempVertex); vertex.X = tempVertex.X; vertex.Y = tempVertex.Y; vertex.U = tempVertex.U; vertex.V = tempVertex.V; vertex.Light = tempVertex.Light; vertex.Dark = tempVertex.Dark; //mesh.SetVertex(vertexStart, VertexPositionColorTextureColor.VertexInfo.GetData(new VertexPositionColorTextureColor[] { vertex })); mesh.SetVertex(vertexStart, VertexPositionColorTextureColor.TransformToBytesByBuffer(ref vertex)); //mesh.SetVertex(vertexStart, VertexPositionColorTextureColor.TransformToBytesByCopy(ref vertex)); } } else { for (int v = 0; vertexStart < vertexEnd; vertexStart += 1, v += 2) { vertex.X = vertices[v + 0]; vertex.Y = vertices[v + 1]; vertex.U = uvs[v + 0]; vertex.V = uvs[v + 1]; vertex.Light = color; vertex.Dark = darkColor; //mesh.SetVertex(vertexStart, VertexPositionColorTextureColor.VertexInfo.GetData(new VertexPositionColorTextureColor[] { vertex })); mesh.SetVertex(vertexStart, VertexPositionColorTextureColor.TransformToBytesByBuffer(ref vertex)); //mesh.SetVertex(vertexStart, VertexPositionColorTextureColor.TransformToBytesByCopy(ref vertex)); } } this.verticesLength = this.verticesLength + numVertices; }