public virtual void Draw(Tessellator par1Tessellator, float par2) { Vec3D vec3d = VertexPositions[1].Vector3D.Subtract(VertexPositions[0].Vector3D); Vec3D vec3d1 = VertexPositions[1].Vector3D.Subtract(VertexPositions[2].Vector3D); Vec3D vec3d2 = vec3d1.CrossProduct(vec3d).Normalize(); par1Tessellator.StartDrawingQuads(); if (InvertNormal) { par1Tessellator.SetNormal(-(float)vec3d2.XCoord, -(float)vec3d2.YCoord, -(float)vec3d2.ZCoord); } else { par1Tessellator.SetNormal((float)vec3d2.XCoord, (float)vec3d2.YCoord, (float)vec3d2.ZCoord); } for (int i = 0; i < 4; i++) { PositionTextureVertex positiontexturevertex = VertexPositions[i]; par1Tessellator.AddVertexWithUV((float)positiontexturevertex.Vector3D.XCoord * par2, (float)positiontexturevertex.Vector3D.YCoord * par2, (float)positiontexturevertex.Vector3D.ZCoord * par2, positiontexturevertex.TexturePositionX, positiontexturevertex.TexturePositionY); } par1Tessellator.Draw(); }
public ModelBox(ModelRenderer par1ModelRenderer, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10) { PosX1 = par4; PosY1 = par5; PosZ1 = par6; PosX2 = par4 + (float)par7; PosY2 = par5 + (float)par8; PosZ2 = par6 + (float)par9; VertexPositions = new PositionTextureVertex[8]; QuadList = new TexturedQuad[6]; float f = par4 + (float)par7; float f1 = par5 + (float)par8; float f2 = par6 + (float)par9; par4 -= par10; par5 -= par10; par6 -= par10; f += par10; f1 += par10; f2 += par10; if (par1ModelRenderer.Mirror) { float f3 = f; f = par4; par4 = f3; } PositionTextureVertex positiontexturevertex = new PositionTextureVertex(par4, par5, par6, 0.0F, 0.0F); PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f, par5, par6, 0.0F, 8F); PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(f, f1, par6, 8F, 8F); PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(par4, f1, par6, 8F, 0.0F); PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(par4, par5, f2, 0.0F, 0.0F); PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f, par5, f2, 0.0F, 8F); PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(f, f1, f2, 8F, 8F); PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(par4, f1, f2, 8F, 0.0F); VertexPositions[0] = positiontexturevertex; VertexPositions[1] = positiontexturevertex1; VertexPositions[2] = positiontexturevertex2; VertexPositions[3] = positiontexturevertex3; VertexPositions[4] = positiontexturevertex4; VertexPositions[5] = positiontexturevertex5; VertexPositions[6] = positiontexturevertex6; VertexPositions[7] = positiontexturevertex7; QuadList[0] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex5, positiontexturevertex1, positiontexturevertex2, positiontexturevertex6 }, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.TextureWidth, par1ModelRenderer.TextureHeight); QuadList[1] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex, positiontexturevertex4, positiontexturevertex7, positiontexturevertex3 }, par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.TextureWidth, par1ModelRenderer.TextureHeight); QuadList[2] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex5, positiontexturevertex4, positiontexturevertex, positiontexturevertex1 }, par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.TextureWidth, par1ModelRenderer.TextureHeight); QuadList[3] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex2, positiontexturevertex3, positiontexturevertex7, positiontexturevertex6 }, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.TextureWidth, par1ModelRenderer.TextureHeight); QuadList[4] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex1, positiontexturevertex, positiontexturevertex3, positiontexturevertex2 }, par2 + par9, par3 + par9, par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.TextureWidth, par1ModelRenderer.TextureHeight); QuadList[5] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex4, positiontexturevertex5, positiontexturevertex6, positiontexturevertex7 }, par2 + par9 + par7 + par9, par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.TextureWidth, par1ModelRenderer.TextureHeight); if (par1ModelRenderer.Mirror) { for (int i = 0; i < QuadList.Length; i++) { QuadList[i].FlipFace(); } } }
/** * Draw this primitve. This is typically called only once as the generated drawing instructions are saved by the * renderer and reused later. */ public void draw(VertexBuffer renderer, float scale) { Vec3d vec3d = this.vertexPositions[1].vector3D.subtractReverse(this.vertexPositions[0].vector3D); Vec3d vec3d1 = this.vertexPositions[1].vector3D.subtractReverse(this.vertexPositions[2].vector3D); Vec3d vec3d2 = vec3d1.crossProduct(vec3d).normalize(); float f = (float)vec3d2.xCoord; float f1 = (float)vec3d2.yCoord; float f2 = (float)vec3d2.zCoord; if (this.invertNormal) { f = -f; f1 = -f1; f2 = -f2; } renderer.begin(7, DefaultVertexFormats.OLDMODEL_POSITION_TEX_NORMAL); for (int i = 0; i < 4; ++i) { PositionTextureVertex positiontexturevertex = this.vertexPositions[i]; renderer.pos(positiontexturevertex.vector3D.xCoord * (double)scale, positiontexturevertex.vector3D.yCoord * (double)scale, positiontexturevertex.vector3D.zCoord * (double)scale).tex((double)positiontexturevertex.texturePositionX, (double)positiontexturevertex.texturePositionY).normal(f, f1, f2).endVertex(); } Tessellator.getInstance().draw(); }
public void addTopPlane(float f, float f1, float f2, int i, int j, int k, float f3) { Side = 2; Offset = f3; x = f; y = f1; z = f2; xMax = (f + i); yMax = (f1 + j); zMax = (f2 + k); corners = new PositionTextureVertex[8]; faces = new TexturedQuad[1]; float f4 = f + i; float f5 = f1 + j; float f6 = f2 + k; f -= f3; f1 -= f3; f2 -= f3; f4 += f3; f5 += f3; f6 += f3; if (mirror) { float f7 = f4; f4 = f; f = f7; } var positiontexturevertex = new PositionTextureVertex(f, f1, f2, 0.0F, 0.0F); var positiontexturevertex1 = new PositionTextureVertex(f4, f1, f2, 0.0F, 8.0F); var positiontexturevertex2 = new PositionTextureVertex(f4, f5, f2, 8.0F, 8.0F); var positiontexturevertex3 = new PositionTextureVertex(f, f5, f2, 8.0F, 0.0F); var positiontexturevertex4 = new PositionTextureVertex(f, f1, f6, 0.0F, 0.0F); var positiontexturevertex5 = new PositionTextureVertex(f4, f1, f6, 0.0F, 8.0F); var positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8.0F, 8.0F); var positiontexturevertex7 = new PositionTextureVertex(f, f5, f6, 8.0F, 0.0F); corners[0] = positiontexturevertex; corners[1] = positiontexturevertex1; corners[2] = positiontexturevertex2; corners[3] = positiontexturevertex3; corners[4] = positiontexturevertex4; corners[5] = positiontexturevertex5; corners[6] = positiontexturevertex6; corners[7] = positiontexturevertex7; faces[0] = new TexturedQuad( new[] { positiontexturevertex5, positiontexturevertex4, positiontexturevertex, positiontexturevertex1 }, textureOffsetX, textureOffsetY, textureOffsetX + i, textureOffsetY + k, textureWidth, textureHeight); if (mirror) { faces[0].flipFace(); } }
private bool InitialiseSentence(Device device, Font font, string text, Coordinate2D <int> position, Colour colour, DeviceContext deviceContext) { VertexCount = 6 * MaxLength; IndexCount = 6 * MaxLength; var vertices = new PositionTextureVertex[VertexCount]; var indices = new int[IndexCount]; for (var i = 0; i < vertices.Length; ++i) { vertices[i].position = Vector3.Zero; vertices[i].texture = Vector2.Zero; } for (var i = 0; i < IndexCount; ++i) { indices[i] = i; } var vertexBufferDescription = new BufferDescription() { Usage = ResourceUsage.Dynamic, SizeInBytes = SharpDX.Utilities.SizeOf <PositionTextureVertex>() * VertexCount, BindFlags = BindFlags.VertexBuffer, CpuAccessFlags = CpuAccessFlags.Write, OptionFlags = ResourceOptionFlags.None, StructureByteStride = 0 }; VertexBuffer = Buffer.Create(device, vertices, vertexBufferDescription); IndexBuffer = Buffer.Create(device, BindFlags.IndexBuffer, indices); var result = true; if (Shadowed) { try { VertexBuffer2 = Buffer.Create(device, vertices, vertexBufferDescription); IndexBuffer2 = Buffer.Create(device, BindFlags.IndexBuffer, indices); } catch { result = false; } } vertices = null; indices = null; result &= UpdateSentence(font, text, position, colour, deviceContext); return(result); }
public virtual void FlipFace() { PositionTextureVertex[] apositiontexturevertex = new PositionTextureVertex[VertexPositions.Length]; for (int i = 0; i < VertexPositions.Length; i++) { apositiontexturevertex[i] = VertexPositions[VertexPositions.Length - i - 1]; } VertexPositions = apositiontexturevertex; }
private bool InitialiseBuffers(Device device) { VertexCount = 6; var vertices = new PositionTextureVertex[VertexCount]; vertices[0].position = new Vector3(0.0f, 0.0f, 0.0f); vertices[0].texture = new Vector2(0.0f, 1.0f); vertices[1].position = new Vector3(0.0f, 1.0f, 0.0f); vertices[1].texture = new Vector2(0.0f, 0.0f); vertices[2].position = new Vector3(1.0f, 0.0f, 0.0f); vertices[2].texture = new Vector2(1.0f, 1.0f); vertices[3].position = new Vector3(1.0f, 0.0f, 0.0f); vertices[3].texture = new Vector2(1.0f, 1.0f); vertices[4].position = new Vector3(0.0f, 1.0f, 0.0f); vertices[4].texture = new Vector2(0.0f, 0.0f); vertices[5].position = new Vector3(1.0f, 1.0f, 0.0f); vertices[5].texture = new Vector2(1.0f, 0.0f); VertexBuffer = Buffer.Create(device, BindFlags.VertexBuffer, vertices); vertices = null; InstanceCount = FoliageCount; Instances = new InstanceType[InstanceCount]; var matrix = Matrix.Identity; for (int i = 0; i < InstanceCount; ++i) { Instances[i].matrix = matrix; Instances[i].colour = new Vector3(FoliageArray[i].r, FoliageArray[i].g, FoliageArray[i].b); } var instanceBufferDescription = new BufferDescription() { Usage = ResourceUsage.Dynamic, SizeInBytes = SharpDX.Utilities.SizeOf <InstanceType>() * InstanceCount, BindFlags = BindFlags.VertexBuffer, CpuAccessFlags = CpuAccessFlags.Write, OptionFlags = ResourceOptionFlags.None, StructureByteStride = 0 }; InstanceBuffer = Buffer.Create(device, Instances, instanceBufferDescription); return(true); }
public void flipFace() { PositionTextureVertex[] apositiontexturevertex = new PositionTextureVertex[this.vertexPositions.Length]; for (int i = 0; i < this.vertexPositions.Length; ++i) { apositiontexturevertex[i] = this.vertexPositions[this.vertexPositions.Length - i - 1]; } this.vertexPositions = apositiontexturevertex; }
public void flipFace() { var apositiontexturevertex = new PositionTextureVertex[vertexPositions.Length]; for (int i = 0; i < vertexPositions.Length; i++) { apositiontexturevertex[i] = vertexPositions[vertexPositions.Length - i - 1]; } vertexPositions = apositiontexturevertex; }
public bool UpdateSentence(Font font, string text, Coordinate2D <int> position, Colour colour, DeviceContext deviceContext) { PixelColour = new Vector4(colour.Red, colour.Green, colour.Blue, 1.0f); var numLetters = text.Length; var result = false; if (numLetters <= MaxLength) { var drawPosition = new Coordinate2D <float>() { X = -(ScreenSize.Width >> 1) + position.X, Y = (ScreenSize.Height >> 1) - position.Y }; font.BuildVertexArray(out List <PositionTextureVertex> vertices, text, drawPosition); for (var i = numLetters; i < MaxLength; ++i) { var emptyVertex = new PositionTextureVertex() { position = Vector3.Zero, texture = Vector2.Zero }; vertices.Add(emptyVertex); } deviceContext.MapSubresource(VertexBuffer, MapMode.WriteDiscard, MapFlags.None, out DataStream mappedResource); mappedResource.WriteRange(vertices.ToArray()); deviceContext.UnmapSubresource(VertexBuffer, 0); // If shadowed then do the same for the second vertex buffer but offset by one pixel. if (Shadowed) { // Perform same mapping and writings code as above except for the shadows offset position for the effect. } vertices?.Clear(); vertices = null; result = true; } return(result); }
public TexturedQuad(PositionTextureVertex[] apositiontexturevertex) { nVertices = 0; vertexPositions = apositiontexturevertex; nVertices = apositiontexturevertex.Length; }
public PositionTextureVertex(PositionTextureVertex positiontexturevertex, float f, float f1) { vector3D = positiontexturevertex.vector3D; texturePositionX = f; texturePositionY = f1; }
public ModelBox(ModelRenderer modelrenderer, string name, int i, int j, float f, float f1, float f2, int k, int l, int i1, float f3) { sizeOfs = f3; texX = i; texY = j; Name = name; x = f; y = f1; z = f2; xMax = f + k; yMax = f1 + l; zMax = f2 + i1; field_40679_h = new PositionTextureVertex[8]; field_40680_i = new TexturedQuad[6]; float f4 = f + k; float f5 = f1 + l; float f6 = f2 + i1; f -= f3; f1 -= f3; f2 -= f3; f4 += f3; f5 += f3; f6 += f3; if (modelrenderer.mirror) { float f7 = f4; f4 = f; f = f7; } var positiontexturevertex = new PositionTextureVertex(f, f1, f2, 0.0F, 0.0F); var positiontexturevertex1 = new PositionTextureVertex(f4, f1, f2, 0.0F, 8F); var positiontexturevertex2 = new PositionTextureVertex(f4, f5, f2, 8F, 8F); var positiontexturevertex3 = new PositionTextureVertex(f, f5, f2, 8F, 0.0F); var positiontexturevertex4 = new PositionTextureVertex(f, f1, f6, 0.0F, 0.0F); var positiontexturevertex5 = new PositionTextureVertex(f4, f1, f6, 0.0F, 8F); var positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8F, 8F); var positiontexturevertex7 = new PositionTextureVertex(f, f5, f6, 8F, 0.0F); field_40679_h[0] = positiontexturevertex; field_40679_h[1] = positiontexturevertex1; field_40679_h[2] = positiontexturevertex2; field_40679_h[3] = positiontexturevertex3; field_40679_h[4] = positiontexturevertex4; field_40679_h[5] = positiontexturevertex5; field_40679_h[6] = positiontexturevertex6; field_40679_h[7] = positiontexturevertex7; field_40680_i[0] = new TexturedQuad(new[] { positiontexturevertex5, positiontexturevertex1, positiontexturevertex2, positiontexturevertex6 }, i + i1 + k, j + i1, i + i1 + k + i1, j + i1 + l, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[1] = new TexturedQuad(new[] { positiontexturevertex, positiontexturevertex4, positiontexturevertex7, positiontexturevertex3 }, i + 0, j + i1, i + i1, j + i1 + l, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[2] = new TexturedQuad(new[] { positiontexturevertex5, positiontexturevertex4, positiontexturevertex, positiontexturevertex1 }, i + i1, j + 0, i + i1 + k, j + i1, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[3] = new TexturedQuad(new[] { positiontexturevertex2, positiontexturevertex3, positiontexturevertex7, positiontexturevertex6 }, i + i1 + k, j + i1, i + i1 + k + k, j + 0, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[4] = new TexturedQuad(new[] { positiontexturevertex1, positiontexturevertex, positiontexturevertex3, positiontexturevertex2 }, i + i1, j + i1, i + i1 + k, j + i1 + l, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[5] = new TexturedQuad(new[] { positiontexturevertex4, positiontexturevertex5, positiontexturevertex6, positiontexturevertex7 }, i + i1 + k + i1, j + i1, i + i1 + k + i1 + k, j + i1 + l, modelrenderer.textureWidth, modelrenderer.textureHeight); if (modelrenderer.mirror) { for (int j1 = 0; j1 < field_40680_i.Length; j1++) field_40680_i[j1].flipFace(); } }
public ModelBox(ModelRenderer modelrenderer, string name, int i, int j, float f, float f1, float f2, int k, int l, int i1, float f3) { sizeOfs = f3; texX = i; texY = j; Name = name; x = f; y = f1; z = f2; xMax = f + k; yMax = f1 + l; zMax = f2 + i1; field_40679_h = new PositionTextureVertex[8]; field_40680_i = new TexturedQuad[6]; float f4 = f + k; float f5 = f1 + l; float f6 = f2 + i1; f -= f3; f1 -= f3; f2 -= f3; f4 += f3; f5 += f3; f6 += f3; if (modelrenderer.mirror) { float f7 = f4; f4 = f; f = f7; } var positiontexturevertex = new PositionTextureVertex(f, f1, f2, 0.0F, 0.0F); var positiontexturevertex1 = new PositionTextureVertex(f4, f1, f2, 0.0F, 8F); var positiontexturevertex2 = new PositionTextureVertex(f4, f5, f2, 8F, 8F); var positiontexturevertex3 = new PositionTextureVertex(f, f5, f2, 8F, 0.0F); var positiontexturevertex4 = new PositionTextureVertex(f, f1, f6, 0.0F, 0.0F); var positiontexturevertex5 = new PositionTextureVertex(f4, f1, f6, 0.0F, 8F); var positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8F, 8F); var positiontexturevertex7 = new PositionTextureVertex(f, f5, f6, 8F, 0.0F); field_40679_h[0] = positiontexturevertex; field_40679_h[1] = positiontexturevertex1; field_40679_h[2] = positiontexturevertex2; field_40679_h[3] = positiontexturevertex3; field_40679_h[4] = positiontexturevertex4; field_40679_h[5] = positiontexturevertex5; field_40679_h[6] = positiontexturevertex6; field_40679_h[7] = positiontexturevertex7; field_40680_i[0] = new TexturedQuad(new[] { positiontexturevertex5, positiontexturevertex1, positiontexturevertex2, positiontexturevertex6 }, i + i1 + k, j + i1, i + i1 + k + i1, j + i1 + l, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[1] = new TexturedQuad(new[] { positiontexturevertex, positiontexturevertex4, positiontexturevertex7, positiontexturevertex3 }, i + 0, j + i1, i + i1, j + i1 + l, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[2] = new TexturedQuad(new[] { positiontexturevertex5, positiontexturevertex4, positiontexturevertex, positiontexturevertex1 }, i + i1, j + 0, i + i1 + k, j + i1, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[3] = new TexturedQuad(new[] { positiontexturevertex2, positiontexturevertex3, positiontexturevertex7, positiontexturevertex6 }, i + i1 + k, j + i1, i + i1 + k + k, j + 0, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[4] = new TexturedQuad(new[] { positiontexturevertex1, positiontexturevertex, positiontexturevertex3, positiontexturevertex2 }, i + i1, j + i1, i + i1 + k, j + i1 + l, modelrenderer.textureWidth, modelrenderer.textureHeight); field_40680_i[5] = new TexturedQuad(new[] { positiontexturevertex4, positiontexturevertex5, positiontexturevertex6, positiontexturevertex7 }, i + i1 + k + i1, j + i1, i + i1 + k + i1 + k, j + i1 + l, modelrenderer.textureWidth, modelrenderer.textureHeight); if (modelrenderer.mirror) { for (int j1 = 0; j1 < field_40680_i.Length; j1++) { field_40680_i[j1].flipFace(); } } }
private bool InitializeBuffers(SharpDX.Direct3D11.Device device, int skyPlaneResolution) { // Calculate the number of vertices in the sky plane mesh. VertexCount = (skyPlaneResolution + 1) * (skyPlaneResolution + 1) * 6; // Set the index count to the same as the vertex count. IndexCount = VertexCount; // Create the vertex array. var vertices = new PositionTextureVertex[VertexCount]; // Create the index array. int[] indices = new int[IndexCount]; // Initialize the index into the vertex array. int index = 0; // Load the vertex and index array with the sky plane array data. for (int j = 0; j < skyPlaneResolution; j++) { for (int i = 0; i < skyPlaneResolution; i++) { int index1 = j * (skyPlaneResolution + 1) + i; int index2 = j * (skyPlaneResolution + 1) + (i + 1); int index3 = (j + 1) * (skyPlaneResolution + 1) + i; int index4 = (j + 1) * (skyPlaneResolution + 1) + (i + 1); // Triangle 1 - Upper Left vertices[index].position = new Vector3(SkyPlaneModel[index1].x, SkyPlaneModel[index1].y, SkyPlaneModel[index1].z); vertices[index].texture = new Vector2(SkyPlaneModel[index1].tu, SkyPlaneModel[index1].tv); indices[index] = index; index++; // Triangle 1 - Upper Right vertices[index].position = new Vector3(SkyPlaneModel[index2].x, SkyPlaneModel[index2].y, SkyPlaneModel[index2].z); vertices[index].texture = new Vector2(SkyPlaneModel[index2].tu, SkyPlaneModel[index2].tv); indices[index] = index; index++; // Triangle 1 - Bottom Left vertices[index].position = new Vector3(SkyPlaneModel[index3].x, SkyPlaneModel[index3].y, SkyPlaneModel[index3].z); vertices[index].texture = new Vector2(SkyPlaneModel[index3].tu, SkyPlaneModel[index3].tv); indices[index] = index; index++; // Triangle 2 - Bottom Left vertices[index].position = new Vector3(SkyPlaneModel[index3].x, SkyPlaneModel[index3].y, SkyPlaneModel[index3].z); vertices[index].texture = new Vector2(SkyPlaneModel[index3].tu, SkyPlaneModel[index3].tv); indices[index] = index; index++; // Triangle 2 - Upper Right vertices[index].position = new Vector3(SkyPlaneModel[index2].x, SkyPlaneModel[index2].y, SkyPlaneModel[index2].z); vertices[index].texture = new Vector2(SkyPlaneModel[index2].tu, SkyPlaneModel[index2].tv); indices[index] = index; index++; // Triangle 2 - Bottom Right vertices[index].position = new Vector3(SkyPlaneModel[index4].x, SkyPlaneModel[index4].y, SkyPlaneModel[index4].z); vertices[index].texture = new Vector2(SkyPlaneModel[index4].tu, SkyPlaneModel[index4].tv); indices[index] = index; index++; } } // Set up the description of the vertex buffer. // Create the vertex buffer. VertexBuffer = SharpDX.Direct3D11.Buffer.Create(device, BindFlags.VertexBuffer, vertices); // Create the index buffer. IndexBuffer = SharpDX.Direct3D11.Buffer.Create(device, BindFlags.IndexBuffer, indices); // Release the arrays now that the buffers have been created and loaded. vertices = null; indices = null; return(true); }
public void addTopPlane(float f, float f1, float f2, int i, int j, int k, float f3) { Side = 2; Offset = f3; x = f; y = f1; z = f2; xMax = (f + i); yMax = (f1 + j); zMax = (f2 + k); corners = new PositionTextureVertex[8]; faces = new TexturedQuad[1]; float f4 = f + i; float f5 = f1 + j; float f6 = f2 + k; f -= f3; f1 -= f3; f2 -= f3; f4 += f3; f5 += f3; f6 += f3; if (mirror) { float f7 = f4; f4 = f; f = f7; } var positiontexturevertex = new PositionTextureVertex(f, f1, f2, 0.0F, 0.0F); var positiontexturevertex1 = new PositionTextureVertex(f4, f1, f2, 0.0F, 8.0F); var positiontexturevertex2 = new PositionTextureVertex(f4, f5, f2, 8.0F, 8.0F); var positiontexturevertex3 = new PositionTextureVertex(f, f5, f2, 8.0F, 0.0F); var positiontexturevertex4 = new PositionTextureVertex(f, f1, f6, 0.0F, 0.0F); var positiontexturevertex5 = new PositionTextureVertex(f4, f1, f6, 0.0F, 8.0F); var positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8.0F, 8.0F); var positiontexturevertex7 = new PositionTextureVertex(f, f5, f6, 8.0F, 0.0F); corners[0] = positiontexturevertex; corners[1] = positiontexturevertex1; corners[2] = positiontexturevertex2; corners[3] = positiontexturevertex3; corners[4] = positiontexturevertex4; corners[5] = positiontexturevertex5; corners[6] = positiontexturevertex6; corners[7] = positiontexturevertex7; faces[0] = new TexturedQuad( new[] {positiontexturevertex5, positiontexturevertex4, positiontexturevertex, positiontexturevertex1}, textureOffsetX, textureOffsetY, textureOffsetX + i, textureOffsetY + k, textureWidth, textureHeight); if (mirror) faces[0].flipFace(); }
public TexturedQuad(PositionTextureVertex[] apositiontexturevertex, int i, int j, int k, int l, float f, float f1) : this(apositiontexturevertex) { float f2 = 0.0F / f; float f3 = 0.0F / f1; apositiontexturevertex[0] = apositiontexturevertex[0].setTexturePosition(k / f - f2, j / f1 + f3); apositiontexturevertex[1] = apositiontexturevertex[1].setTexturePosition(i / f + f2, j / f1 + f3); apositiontexturevertex[2] = apositiontexturevertex[2].setTexturePosition(i / f + f2, l / f1 - f3); apositiontexturevertex[3] = apositiontexturevertex[3].setTexturePosition(k / f - f2, l / f1 - f3); }
public PositionTextureVertex(PositionTextureVertex par1PositionTextureVertex, float par2, float par3) { Vector3D = par1PositionTextureVertex.Vector3D; TexturePositionX = par2; TexturePositionY = par3; }
public PositionTextureVertex(PositionTextureVertex textureVertex, float texturePositionXIn, float texturePositionYIn) { this.vector3D = textureVertex.vector3D; this.texturePositionX = texturePositionXIn; this.texturePositionY = texturePositionYIn; }
public ModelBox(ModelRenderer renderer, int textureX, int textureY, float p_i46301_4_, float p_i46301_5_, float p_i46301_6_, int p_i46301_7_, int p_i46301_8_, int p_i46301_9_, float p_i46301_10_, bool p_i46301_11_) { this.textureX = textureX; this.textureY = textureY; this.sizeOfs = p_i46301_10_; this.mirrored = p_i46301_11_; this.posX1 = p_i46301_4_; this.posY1 = p_i46301_5_; this.posZ1 = p_i46301_6_; this.posX2 = p_i46301_4_ + (float)p_i46301_7_; this.posY2 = p_i46301_5_ + (float)p_i46301_8_; this.posZ2 = p_i46301_6_ + (float)p_i46301_9_; this.vertexPositions = new PositionTextureVertex[8]; this.quadList = new TexturedQuad[6]; float f = p_i46301_4_ + (float)p_i46301_7_; float f1 = p_i46301_5_ + (float)p_i46301_8_; float f2 = p_i46301_6_ + (float)p_i46301_9_; p_i46301_4_ = p_i46301_4_ - p_i46301_10_; p_i46301_5_ = p_i46301_5_ - p_i46301_10_; p_i46301_6_ = p_i46301_6_ - p_i46301_10_; f = f + p_i46301_10_; f1 = f1 + p_i46301_10_; f2 = f2 + p_i46301_10_; if (p_i46301_11_) { float f3 = f; f = p_i46301_4_; p_i46301_4_ = f3; } PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(p_i46301_4_, p_i46301_5_, p_i46301_6_, 0.0F, 0.0F); PositionTextureVertex positiontexturevertex = new PositionTextureVertex(f, p_i46301_5_, p_i46301_6_, 0.0F, 8.0F); PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f, f1, p_i46301_6_, 8.0F, 8.0F); PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(p_i46301_4_, f1, p_i46301_6_, 8.0F, 0.0F); PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(p_i46301_4_, p_i46301_5_, f2, 0.0F, 0.0F); PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(f, p_i46301_5_, f2, 0.0F, 8.0F); PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f, f1, f2, 8.0F, 8.0F); PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(p_i46301_4_, f1, f2, 8.0F, 0.0F); this.vertexPositions[0] = positiontexturevertex7; this.vertexPositions[1] = positiontexturevertex; this.vertexPositions[2] = positiontexturevertex1; this.vertexPositions[3] = positiontexturevertex2; this.vertexPositions[4] = positiontexturevertex3; this.vertexPositions[5] = positiontexturevertex4; this.vertexPositions[6] = positiontexturevertex5; this.vertexPositions[7] = positiontexturevertex6; this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex4, positiontexturevertex, positiontexturevertex1, positiontexturevertex5 }, textureX + p_i46301_9_ + p_i46301_7_, textureY + p_i46301_9_, textureX + p_i46301_9_ + p_i46301_7_ + p_i46301_9_, textureY + p_i46301_9_ + p_i46301_8_, renderer.textureWidth, renderer.textureHeight); this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex7, positiontexturevertex3, positiontexturevertex6, positiontexturevertex2 }, textureX, textureY + p_i46301_9_, textureX + p_i46301_9_, textureY + p_i46301_9_ + p_i46301_8_, renderer.textureWidth, renderer.textureHeight); this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex4, positiontexturevertex3, positiontexturevertex7, positiontexturevertex }, textureX + p_i46301_9_, textureY, textureX + p_i46301_9_ + p_i46301_7_, textureY + p_i46301_9_, renderer.textureWidth, renderer.textureHeight); this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex1, positiontexturevertex2, positiontexturevertex6, positiontexturevertex5 }, textureX + p_i46301_9_ + p_i46301_7_, textureY + p_i46301_9_, textureX + p_i46301_9_ + p_i46301_7_ + p_i46301_7_, textureY, renderer.textureWidth, renderer.textureHeight); this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex, positiontexturevertex7, positiontexturevertex2, positiontexturevertex1 }, textureX + p_i46301_9_, textureY + p_i46301_9_, textureX + p_i46301_9_ + p_i46301_7_, textureY + p_i46301_9_ + p_i46301_8_, renderer.textureWidth, renderer.textureHeight); this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] { positiontexturevertex3, positiontexturevertex4, positiontexturevertex5, positiontexturevertex6 }, textureX + p_i46301_9_ + p_i46301_7_ + p_i46301_9_, textureY + p_i46301_9_, textureX + p_i46301_9_ + p_i46301_7_ + p_i46301_9_ + p_i46301_7_, textureY + p_i46301_9_ + p_i46301_8_, renderer.textureWidth, renderer.textureHeight); if (p_i46301_11_) { for (int i = 0; i < this.quadList.Length; ++i) { this.quadList[i].flipFace(); } } }
public void flipFace() { var apositiontexturevertex = new PositionTextureVertex[vertexPositions.Length]; for (int i = 0; i < vertexPositions.Length; i++) apositiontexturevertex[i] = vertexPositions[vertexPositions.Length - i - 1]; vertexPositions = apositiontexturevertex; }