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); } }
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); } }