private void init(SSScene sunScene, SSObjectBillboard sun, SSTexture texture, RectangleF[] spriteRects, Vector2[] spriteScales) { base.textureMaterial = new SSTextureMaterial(texture); this.sunBillboard = sun; this.sunScene = sunScene; this.numElements = spriteRects.Length; if (spriteScales == null) { spriteScales = new Vector2[numElements]; for (int i = 0; i < numElements; ++i) { spriteScales [i] = new Vector2(1f); } } else { if (spriteScales.Length != numElements) { throw new Exception("texture coordinate array size does not match that of sprite scale array"); spriteScales = new Vector2[numElements]; for (int i = 0; i < numElements; ++i) { spriteScales [i] = new Vector2(1f); } } } this.spriteScales = spriteScales; UInt16[] indices = new UInt16[numElements * 6]; for (int i = 0; i < numElements; ++i) { int baseLoc = i * 6; int baseVal = i * 4; indices [baseLoc] = (UInt16)baseVal; indices [baseLoc + 1] = (UInt16)(baseVal + 2); indices [baseLoc + 2] = (UInt16)(baseVal + 1); indices [baseLoc + 3] = (UInt16)baseVal; indices [baseLoc + 4] = (UInt16)(baseVal + 3); indices [baseLoc + 5] = (UInt16)(baseVal + 2); } Mesh = new SSIndexedMesh <SSVertex_PosTex> (null, indices); vertices = new SSVertex_PosTex[numElements * 4]; for (int r = 0; r < spriteRects.Length; ++r) { RectangleF rect = spriteRects [r]; int baseIdx = r * 4; vertices [baseIdx] = new SSVertex_PosTex(0f, 0f, 0f, rect.Left, rect.Bottom); vertices [baseIdx + 1] = new SSVertex_PosTex(0f, 0f, 0f, rect.Right, rect.Bottom); vertices [baseIdx + 2] = new SSVertex_PosTex(0f, 0f, 0f, rect.Right, rect.Top); vertices [baseIdx + 3] = new SSVertex_PosTex(0f, 0f, 0f, rect.Left, rect.Top); } }
protected void _initInterferenceVertices() { _interferenceVertices = new SSVertex_PosTex[4]; _interferenceMesh = new SSIndexedMesh <SSVertex_PosTex> (null, _interferenceIndices); _interferenceVertices[0].Position = new Vector3(-0.5f, +0.5f, 0f); _interferenceVertices[1].Position = new Vector3(-0.5f, -0.5f, 0f); _interferenceVertices[2].Position = new Vector3(+0.5f, +0.5f, 0f); _interferenceVertices[3].Position = new Vector3(+0.5f, -0.5f, 0f); _interferenceVertices[0].TexCoord.Y = _interferenceVertices[2].TexCoord.Y = 1f; _interferenceVertices[1].TexCoord.Y = _interferenceVertices[3].TexCoord.Y = 0f; }
protected void _initMiddleMesh() { float padding = _laser.parameters.middleSpritePadding; _middleVertices = new SSVertex_PosTex[8]; _middleVertices [0].TexCoord = new Vector2(padding, padding); _middleVertices [1].TexCoord = new Vector2(padding, 1f - padding); _middleVertices [2].TexCoord = new Vector2(1f - padding, padding); _middleVertices [3].TexCoord = new Vector2(1f - padding, 1f - padding); _middleVertices [4].TexCoord = new Vector2(1f - padding, padding); _middleVertices [5].TexCoord = new Vector2(1f - padding, 1f - padding); _middleVertices [6].TexCoord = new Vector2(1f, padding); _middleVertices [7].TexCoord = new Vector2(1f, 1f - padding); _middleMesh = new SSIndexedMesh <SSVertex_PosTex>(null, _middleIndices); }
private void init(SSScene sunScene, SSObjectBillboard sun, SSTexture texture, RectangleF[] spriteRects, Vector2[] spriteScales) { base.textureMaterial = new SSTextureMaterial (texture); this.sunBillboard = sun; this.sunScene = sunScene; this.numElements = spriteRects.Length; if (spriteScales == null) { spriteScales = new Vector2[numElements]; for (int i = 0; i < numElements; ++i) { spriteScales [i] = new Vector2(1f); } } else { if (spriteScales.Length != numElements) { throw new Exception ("texture coordinate array size does not match that of sprite scale array"); spriteScales = new Vector2[numElements]; for (int i = 0; i < numElements; ++i) { spriteScales [i] = new Vector2(1f); } } } this.spriteScales = spriteScales; UInt16[] indices = new UInt16[numElements*6]; for (int i = 0; i < numElements; ++i) { int baseLoc = i * 6; int baseVal = i * 4; indices [baseLoc] = (UInt16)baseVal; indices [baseLoc + 1] = (UInt16)(baseVal + 2); indices [baseLoc + 2] = (UInt16)(baseVal + 1); indices [baseLoc + 3] = (UInt16)baseVal; indices [baseLoc + 4] = (UInt16)(baseVal + 3); indices [baseLoc + 5] = (UInt16)(baseVal + 2); } Mesh = new SSIndexedMesh<SSVertex_PosTex> (null, indices); vertices = new SSVertex_PosTex[numElements * 4]; for (int r = 0; r < spriteRects.Length; ++r) { RectangleF rect = spriteRects [r]; int baseIdx = r * 4; vertices [baseIdx] = new SSVertex_PosTex (0f, 0f, 0f, rect.Left, rect.Bottom); vertices [baseIdx+1] = new SSVertex_PosTex (0f, 0f, 0f, rect.Right, rect.Bottom); vertices [baseIdx+2] = new SSVertex_PosTex (0f, 0f, 0f, rect.Right, rect.Top); vertices [baseIdx+3] = new SSVertex_PosTex (0f, 0f, 0f, rect.Left, rect.Top); } }
public SSMeshOBJSubsetData(SSVertex_PosNormTexDiff[] vertices, UInt16[] indices, UInt16[] wireframeIndices) { SSVertexBuffer<SSVertex_PosNormTexDiff> vbo = new SSVertexBuffer<SSVertex_PosNormTexDiff>(vertices, BufferUsageHint.StaticDraw); SSIndexBuffer triIbo = new SSIndexBuffer(indices, vbo, BufferUsageHint.StaticDraw); SSIndexBuffer wireframeIbo = new SSIndexBuffer(wireframeIndices, vbo, BufferUsageHint.StaticDraw); this.triangleMesh = new SSIndexedMesh<SSVertex_PosNormTexDiff>(vbo, triIbo); this.wireframeMesh = new SSIndexedMesh<SSVertex_PosNormTexDiff>(vbo, wireframeIbo); }
protected void _initMiddleMesh() { float padding = _laser.parameters.middleSpritePadding; _middleVertices = new SSVertex_PosTex[8]; _middleVertices [0].TexCoord = new Vector2 (padding, padding); _middleVertices [1].TexCoord = new Vector2 (padding, 1f-padding); _middleVertices [2].TexCoord = new Vector2 (1f-padding, padding); _middleVertices [3].TexCoord = new Vector2 (1f-padding, 1f-padding); _middleVertices [4].TexCoord = new Vector2 (1f-padding, padding); _middleVertices [5].TexCoord = new Vector2 (1f-padding, 1f-padding); _middleVertices [6].TexCoord = new Vector2 (1f, padding); _middleVertices [7].TexCoord = new Vector2 (1f, 1f-padding); _middleMesh = new SSIndexedMesh<SSVertex_PosTex>(null, _middleIndices); }
protected void _initInterferenceVertices() { _interferenceVertices = new SSVertex_PosTex[4]; _interferenceMesh = new SSIndexedMesh<SSVertex_PosTex> (null, _interferenceIndices); _interferenceVertices[0].Position = new Vector3(-0.5f, +0.5f, 0f); _interferenceVertices[1].Position = new Vector3(-0.5f, -0.5f, 0f); _interferenceVertices[2].Position = new Vector3(+0.5f, +0.5f, 0f); _interferenceVertices[3].Position = new Vector3(+0.5f, -0.5f, 0f); _interferenceVertices[0].TexCoord.Y = _interferenceVertices[2].TexCoord.Y = 1f; _interferenceVertices[1].TexCoord.Y = _interferenceVertices[3].TexCoord.Y = 0f; }