public void Add(SpriteB spriteB) { if(cnt >= m_maxNumOfSprite) return; this.spriteList.Add(spriteB); ++cnt; }
public void Add(SpriteB spriteB) { if (cnt >= m_maxNumOfSprite) { return; } this.spriteList.Add(spriteB); ++cnt; }
public SpriteAnimation(string pngFilePath, string xmlFilePath) { texture = new Texture2D (pngFilePath, false); this.RegisterDisposeOnExit (texture); dicTextureInfo = UnifiedTexture.GetDictionaryTextureInfo (xmlFilePath); sbuffer = new SpriteBuffer (Director.Instance.GL.Context, dicTextureInfo.Count); animationList.AddRange (dicTextureInfo.Keys); animationList.Sort (); sprite = new SpriteB (dicTextureInfo [animationList [0]]); }
static public int CompareZDepthBackToFront(SpriteB sprite01, SpriteB sprite02) { //float ff=sprite02.Position.Z - sprite01.Position.Z; if (sprite02.Position.Z - sprite01.Position.Z > 0.0f) { return(1); } else if (sprite02.Position.Z - sprite01.Position.Z < 0.0f) { return(-1); } else { return(0); } }
public void Copy2Buffer(SpriteB spriteB, int index) { // 頂点座標の計算。 bufferVerties[index * FNUM_VERTEX_PER_SPRITE] = 0; //0.0f; // x0 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 1] = 0; //0.0f; // y0 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 2] = 0; // z0 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 3] = 0; //0.0f; // x1 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 4] = spriteB.Height; //1.0f; // y1 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 5] = 0; // z1 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 6] = spriteB.Width; //1.0f; // x2 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 7] = 0; //0.0f; // y2 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 8] = 0; // z2 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 9] = spriteB.Width; //1.0f; // x3 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 10] = spriteB.Height; //1.0f; // y3 bufferVerties[index * FNUM_VERTEX_PER_SPRITE + 11] = 0; // z3 bufferWH[index * FNUM_WH_PER_SPRITE] = spriteB.Width; bufferWH[index * FNUM_WH_PER_SPRITE + 1] = spriteB.Height; bufferWH[index * FNUM_WH_PER_SPRITE + 2] = spriteB.Width; bufferWH[index * FNUM_WH_PER_SPRITE + 3] = spriteB.Height; bufferWH[index * FNUM_WH_PER_SPRITE + 4] = spriteB.Width; bufferWH[index * FNUM_WH_PER_SPRITE + 5] = spriteB.Height; bufferWH[index * FNUM_WH_PER_SPRITE + 6] = spriteB.Width; bufferWH[index * FNUM_WH_PER_SPRITE + 7] = spriteB.Height; bufferCenter[index * FNUM_CENTER_PER_SPRITE] = spriteB.Center.X; bufferCenter[index * FNUM_CENTER_PER_SPRITE + 1] = spriteB.Center.Y; bufferCenter[index * FNUM_CENTER_PER_SPRITE + 2] = spriteB.Center.X; bufferCenter[index * FNUM_CENTER_PER_SPRITE + 3] = spriteB.Center.Y; bufferCenter[index * FNUM_CENTER_PER_SPRITE + 4] = spriteB.Center.X; bufferCenter[index * FNUM_CENTER_PER_SPRITE + 5] = spriteB.Center.Y; bufferCenter[index * FNUM_CENTER_PER_SPRITE + 6] = spriteB.Center.X; bufferCenter[index * FNUM_CENTER_PER_SPRITE + 7] = spriteB.Center.Y; bufferRot[index * FNUM_ROT_PER_SPRITE] = spriteB.Rotation; bufferRot[index * FNUM_ROT_PER_SPRITE + 1] = 0.0f; bufferRot[index * FNUM_ROT_PER_SPRITE + 2] = spriteB.Rotation; bufferRot[index * FNUM_ROT_PER_SPRITE + 3] = 0.0f; bufferRot[index * FNUM_ROT_PER_SPRITE + 4] = spriteB.Rotation; bufferRot[index * FNUM_ROT_PER_SPRITE + 5] = 0.0f; bufferRot[index * FNUM_ROT_PER_SPRITE + 6] = spriteB.Rotation; bufferRot[index * FNUM_ROT_PER_SPRITE + 7] = 0.0f; bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE] = spriteB.Position.X; //x bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 1] = spriteB.Position.Y; //y bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 2] = spriteB.Position.Z; //z bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 3] = spriteB.Position.X; //x bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 4] = spriteB.Position.Y; //y bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 5] = spriteB.Position.Z; //z bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 6] = spriteB.Position.X; //x bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 7] = spriteB.Position.Y; //y bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 8] = spriteB.Position.Z; //z bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 9] = spriteB.Position.X; //x bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 10] = spriteB.Position.Y; //y bufferSpritePosition[index * FNUM_SPOSITION_PER_SPRITE + 11] = spriteB.Position.Z; //z // テクスチャ座標のコピー。 #if false bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE] = texcoords[0]; // left top u bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 1] = texcoords[1]; // left top v bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 2] = texcoords[2]; // left bottom u bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 3] = texcoords[3]; // left bottom v bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 4] = texcoords[4]; // right top u bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 5] = texcoords[5]; // right top v bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 6] = texcoords[6]; // right bottom u bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 7] = texcoords[7]; // right bottom v #else Buffer.BlockCopy(spriteB.Texcoords, 0, bufferTexcoords, index * FNUM_TEXCOORD_PER_SPRITE * sizeof(float), 8 * sizeof(float)); #endif // colorのコピー。 #if false bufferColors[index * COLOR_SIZE_PER_SPRITE] = colors[0]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 1] = colors[1]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 2] = colors[2]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 3] = colors[3]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 4] = colors[4]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 5] = colors[5]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 6] = colors[6]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 7] = colors[7]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 8] = colors[8]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 9] = colors[9]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 10] = colors[10]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 11] = colors[11]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 12] = colors[12]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 13] = colors[13]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 14] = colors[14]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 15] = colors[15]; #else Buffer.BlockCopy(spriteB.Colors, 0, bufferColors, index * FNUM_COLOR_PER_SPRITE * sizeof(float), 16 * sizeof(float)); #endif bufferIndices[index * INDEX_SIZE_PER_SPRITE] = (ushort)(index * VERTEX_NUM_PER_SPRITE); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 1] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 1); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 2] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 2); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 3] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 1); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 4] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 2); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 5] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 3); }
public static int CompareZDepthBackToFront(SpriteB sprite01, SpriteB sprite02) { //float ff=sprite02.Position.Z - sprite01.Position.Z; if( sprite02.Position.Z - sprite01.Position.Z > 0.0f) return 1; else if(sprite02.Position.Z - sprite01.Position.Z<0.0f) return -1; else return 0; }
public void Copy2Buffer(SpriteB spriteB, int index) { if(spriteB.Rotation == 0.0f) { bufferVerties[index*VERTEX_SIZE_PER_SPRITE]=spriteB.Position.X - spriteB.Width*spriteB.Center.X;//0.0f; // x0 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+1]=spriteB.Position.Y - spriteB.Height*spriteB.Center.Y;//0.0f; // y0 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+2]=spriteB.Position.Z; // z0 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+3]=spriteB.Position.X - spriteB.Width*spriteB.Center.X;//0.0f; // x1 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+4]=spriteB.Position.Y + spriteB.Height*(1.0f-spriteB.Center.Y);//1.0f; // y1 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+5]=spriteB.Position.Z; // z1 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+6]=spriteB.Position.X + spriteB.Width*(1.0f-spriteB.Center.X);//1.0f; // x2 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+7]=spriteB.Position.Y - spriteB.Height*spriteB.Center.Y;//0.0f; // y2 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+8]=spriteB.Position.Z; // z2 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+9]=spriteB.Position.X + spriteB.Width*(1.0f-spriteB.Center.X);//1.0f; // x3 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+10]=spriteB.Position.Y + spriteB.Height*(1.0f-spriteB.Center.Y);//1.0f; // y3 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+11]=spriteB.Position.Z; // z3 } else { float x,y, rc, rs; rc=FMath.Cos(spriteB.Rotation); rs=FMath.Sin(spriteB.Rotation); x=-spriteB.Width*spriteB.Center.X; y=-spriteB.Height*spriteB.Center.Y; bufferVerties[index*VERTEX_SIZE_PER_SPRITE]=spriteB.Position.X + (float)(x*rc - y*rs);// x0 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+1]=spriteB.Position.Y + (float)(x*rs + y*rc);// y0 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+2]=spriteB.Position.Z; // z0 x=-spriteB.Width*spriteB.Center.X; y=spriteB.Height*(1.0f-spriteB.Center.Y); bufferVerties[index*VERTEX_SIZE_PER_SPRITE+3]=spriteB.Position.X + (float)(x*rc - y*rs);// x1 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+4]=spriteB.Position.Y + (float)(x*rs + y*rc);// y1 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+5]=spriteB.Position.Z; // z1 x=spriteB.Width*(1.0f-spriteB.Center.X); y=-spriteB.Height*spriteB.Center.Y; bufferVerties[index*VERTEX_SIZE_PER_SPRITE+6]=spriteB.Position.X + (float)(x*rc-y*rs);// x2 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+7]=spriteB.Position.Y + (float)(x*rs+y*rc);// y2 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+8]=spriteB.Position.Z; // z2 x=spriteB.Width*(1.0f-spriteB.Center.X); y=spriteB.Height*(1.0f-spriteB.Center.Y); bufferVerties[index*VERTEX_SIZE_PER_SPRITE+9]=spriteB.Position.X + (float)(x*rc-y*rs);// x3 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+10]=spriteB.Position.Y + (float)(x*rs+y*rc);// y3 bufferVerties[index*VERTEX_SIZE_PER_SPRITE+11]=spriteB.Position.Z; // z3 } #if false bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE]=texcoords[0]; // left top u bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+1]=texcoords[1]; // left top v bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+2]=texcoords[2]; // left bottom u bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+3]=texcoords[3]; // left bottom v bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+4]=texcoords[4]; // right top u bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+5]=texcoords[5]; // right top v bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+6]=texcoords[6]; // right bottom u bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+7]=texcoords[7]; // right bottom v #else Buffer.BlockCopy(spriteB.Texcoords, 0, bufferTexcoords, index*TEXCOORD_SIZE_PER_SPRITE*sizeof(float), 8*sizeof(float)); #endif // color #if false bufferColors[index*COLOR_SIZE_PER_SPRITE]=colors[0]; bufferColors[index*COLOR_SIZE_PER_SPRITE+1]=colors[1]; bufferColors[index*COLOR_SIZE_PER_SPRITE+2]=colors[2]; bufferColors[index*COLOR_SIZE_PER_SPRITE+3]=colors[3]; bufferColors[index*COLOR_SIZE_PER_SPRITE+4]=colors[4]; bufferColors[index*COLOR_SIZE_PER_SPRITE+5]=colors[5]; bufferColors[index*COLOR_SIZE_PER_SPRITE+6]=colors[6]; bufferColors[index*COLOR_SIZE_PER_SPRITE+7]=colors[7]; bufferColors[index*COLOR_SIZE_PER_SPRITE+8]=colors[8]; bufferColors[index*COLOR_SIZE_PER_SPRITE+9]=colors[9]; bufferColors[index*COLOR_SIZE_PER_SPRITE+10]=colors[10]; bufferColors[index*COLOR_SIZE_PER_SPRITE+11]=colors[11]; bufferColors[index*COLOR_SIZE_PER_SPRITE+12]=colors[12]; bufferColors[index*COLOR_SIZE_PER_SPRITE+13]=colors[13]; bufferColors[index*COLOR_SIZE_PER_SPRITE+14]=colors[14]; bufferColors[index*COLOR_SIZE_PER_SPRITE+15]=colors[15]; #else Buffer.BlockCopy(spriteB.Colors, 0, bufferColors, index*COLOR_SIZE_PER_SPRITE*sizeof(float), 16*sizeof(float)); #endif bufferIndices[index*INDEX_SIZE_PER_SPRITE] = (ushort)(index*VERTEX_NUM_PER_SPRITE); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 1] = (ushort)(index*VERTEX_NUM_PER_SPRITE+1); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 2] = (ushort)(index*VERTEX_NUM_PER_SPRITE+2); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 3] = (ushort)(index*VERTEX_NUM_PER_SPRITE+1); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 4] = (ushort)(index*VERTEX_NUM_PER_SPRITE+2); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 5] = (ushort)(index*VERTEX_NUM_PER_SPRITE+3); }
public void Copy2Buffer(SpriteB spriteB, int index) { if (spriteB.Rotation == 0.0f) { bufferVerties[index * VERTEX_SIZE_PER_SPRITE] = spriteB.Position.X - spriteB.Width * spriteB.Center.X; //0.0f; // x0 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 1] = spriteB.Position.Y - spriteB.Height * spriteB.Center.Y; //0.0f; // y0 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 2] = spriteB.Position.Z; // z0 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 3] = spriteB.Position.X - spriteB.Width * spriteB.Center.X; //0.0f; // x1 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 4] = spriteB.Position.Y + spriteB.Height * (1.0f - spriteB.Center.Y); //1.0f; // y1 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 5] = spriteB.Position.Z; // z1 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 6] = spriteB.Position.X + spriteB.Width * (1.0f - spriteB.Center.X); //1.0f; // x2 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 7] = spriteB.Position.Y - spriteB.Height * spriteB.Center.Y; //0.0f; // y2 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 8] = spriteB.Position.Z; // z2 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 9] = spriteB.Position.X + spriteB.Width * (1.0f - spriteB.Center.X); //1.0f; // x3 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 10] = spriteB.Position.Y + spriteB.Height * (1.0f - spriteB.Center.Y); //1.0f; // y3 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 11] = spriteB.Position.Z; // z3 } else { float x, y, rc, rs; rc = FMath.Cos(spriteB.Rotation); rs = FMath.Sin(spriteB.Rotation); x = -spriteB.Width * spriteB.Center.X; y = -spriteB.Height * spriteB.Center.Y; bufferVerties[index * VERTEX_SIZE_PER_SPRITE] = spriteB.Position.X + (float)(x * rc - y * rs); // x0 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 1] = spriteB.Position.Y + (float)(x * rs + y * rc); // y0 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 2] = spriteB.Position.Z; // z0 x = -spriteB.Width * spriteB.Center.X; y = spriteB.Height * (1.0f - spriteB.Center.Y); bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 3] = spriteB.Position.X + (float)(x * rc - y * rs); // x1 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 4] = spriteB.Position.Y + (float)(x * rs + y * rc); // y1 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 5] = spriteB.Position.Z; // z1 x = spriteB.Width * (1.0f - spriteB.Center.X); y = -spriteB.Height * spriteB.Center.Y; bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 6] = spriteB.Position.X + (float)(x * rc - y * rs); // x2 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 7] = spriteB.Position.Y + (float)(x * rs + y * rc); // y2 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 8] = spriteB.Position.Z; // z2 x = spriteB.Width * (1.0f - spriteB.Center.X); y = spriteB.Height * (1.0f - spriteB.Center.Y); bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 9] = spriteB.Position.X + (float)(x * rc - y * rs); // x3 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 10] = spriteB.Position.Y + (float)(x * rs + y * rc); // y3 bufferVerties[index * VERTEX_SIZE_PER_SPRITE + 11] = spriteB.Position.Z; // z3 } #if false bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE] = texcoords[0]; // left top u bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 1] = texcoords[1]; // left top v bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 2] = texcoords[2]; // left bottom u bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 3] = texcoords[3]; // left bottom v bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 4] = texcoords[4]; // right top u bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 5] = texcoords[5]; // right top v bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 6] = texcoords[6]; // right bottom u bufferTexcoords[index * TEXCOORD_SIZE_PER_SPRITE + 7] = texcoords[7]; // right bottom v #else Buffer.BlockCopy(spriteB.Texcoords, 0, bufferTexcoords, index * TEXCOORD_SIZE_PER_SPRITE * sizeof(float), 8 * sizeof(float)); #endif // color #if false bufferColors[index * COLOR_SIZE_PER_SPRITE] = colors[0]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 1] = colors[1]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 2] = colors[2]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 3] = colors[3]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 4] = colors[4]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 5] = colors[5]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 6] = colors[6]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 7] = colors[7]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 8] = colors[8]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 9] = colors[9]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 10] = colors[10]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 11] = colors[11]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 12] = colors[12]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 13] = colors[13]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 14] = colors[14]; bufferColors[index * COLOR_SIZE_PER_SPRITE + 15] = colors[15]; #else Buffer.BlockCopy(spriteB.Colors, 0, bufferColors, index * COLOR_SIZE_PER_SPRITE * sizeof(float), 16 * sizeof(float)); #endif bufferIndices[index * INDEX_SIZE_PER_SPRITE] = (ushort)(index * VERTEX_NUM_PER_SPRITE); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 1] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 1); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 2] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 2); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 3] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 1); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 4] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 2); bufferIndices[index * INDEX_SIZE_PER_SPRITE + 5] = (ushort)(index * VERTEX_NUM_PER_SPRITE + 3); }
private void SetSpritePrimitive( out SpritePrim spritePrim, SpriteB spriteB ) { spritePrim.V0.Color = _color; spritePrim.V1.Color = _color; spritePrim.V2.Color = _color; spritePrim.V3.Color = _color; spritePrim.V0.UV = spriteB._uv[0]; spritePrim.V1.UV = spriteB._uv[1]; spritePrim.V2.UV = spriteB._uv[2]; spritePrim.V3.UV = spriteB._uv[3]; if(spriteB.Rotation == 0.0f) { spritePrim.V0.Position.X = (short)(spriteB.Position.X - spriteB.Width*spriteB.Center.X);//0.0f; // x0 spritePrim.V0.Position.Y = (short)(spriteB.Position.Y - spriteB.Height*spriteB.Center.Y);//0.0f; // y0 spritePrim.V1.Position.X = (short)(spriteB.Position.X - spriteB.Width*spriteB.Center.X);//0.0f; // x1 spritePrim.V1.Position.Y = (short)(spriteB.Position.Y + spriteB.Height*(1.0f-spriteB.Center.Y));//1.0f; // y1 spritePrim.V2.Position.X = (short)(spriteB.Position.X + spriteB.Width*(1.0f-spriteB.Center.X));//1.0f; // x2 spritePrim.V2.Position.Y = (short)(spriteB.Position.Y - spriteB.Height*spriteB.Center.Y);//0.0f; // y2 spritePrim.V3.Position.X = (short)(spriteB.Position.X + spriteB.Width*(1.0f-spriteB.Center.X));//1.0f; // x3 spritePrim.V3.Position.Y = (short)(spriteB.Position.Y + spriteB.Height*(1.0f-spriteB.Center.Y));//1.0f; // y3 } else { float x,y, rc, rs; rc=FMath.Cos(spriteB.Rotation); rs=FMath.Sin(spriteB.Rotation); x=-spriteB.Width*spriteB.Center.X; y=-spriteB.Height*spriteB.Center.Y; spritePrim.V0.Position.X=(short)(spriteB.Position.X + (float)(x*rc - y*rs));// x0 spritePrim.V0.Position.Y=(short)(spriteB.Position.Y + (float)(x*rs + y*rc));// y0 x=-spriteB.Width*spriteB.Center.X; y=spriteB.Height*(1.0f-spriteB.Center.Y); spritePrim.V1.Position.X=(short)(spriteB.Position.X + (float)(x*rc - y*rs));// x1 spritePrim.V1.Position.Y=(short)(spriteB.Position.Y + (float)(x*rs + y*rc));// y1 x=spriteB.Width*(1.0f-spriteB.Center.X); y=-spriteB.Height*spriteB.Center.Y; spritePrim.V2.Position.X=(short)(spriteB.Position.X + (float)(x*rc-y*rs));// x2 spritePrim.V2.Position.Y=(short)(spriteB.Position.Y + (float)(x*rs+y*rc));// y2 x=spriteB.Width*(1.0f-spriteB.Center.X); y=spriteB.Height*(1.0f-spriteB.Center.Y); spritePrim.V3.Position.X=(short)(spriteB.Position.X + (float)(x*rc-y*rs));// x3 spritePrim.V3.Position.Y=(short)(spriteB.Position.Y + (float)(x*rs+y*rc));// y3 } }
public void Copy2Buffer(SpriteB spriteB, int index) { // 頂点座標の計算。 bufferVerties[index*FNUM_VERTEX_PER_SPRITE]=0; //0.0f; // x0 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+1]=0; //0.0f; // y0 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+2]=0; // z0 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+3]=0; //0.0f; // x1 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+4]=spriteB.Height;//1.0f; // y1 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+5]=0; // z1 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+6]=spriteB.Width;//1.0f; // x2 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+7]=0; //0.0f; // y2 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+8]=0; // z2 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+9]=spriteB.Width;//1.0f; // x3 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+10]=spriteB.Height;//1.0f; // y3 bufferVerties[index*FNUM_VERTEX_PER_SPRITE+11]=0; // z3 bufferWH[index*FNUM_WH_PER_SPRITE]=spriteB.Width; bufferWH[index*FNUM_WH_PER_SPRITE+1]=spriteB.Height; bufferWH[index*FNUM_WH_PER_SPRITE+2]=spriteB.Width; bufferWH[index*FNUM_WH_PER_SPRITE+3]=spriteB.Height; bufferWH[index*FNUM_WH_PER_SPRITE+4]=spriteB.Width; bufferWH[index*FNUM_WH_PER_SPRITE+5]=spriteB.Height; bufferWH[index*FNUM_WH_PER_SPRITE+6]=spriteB.Width; bufferWH[index*FNUM_WH_PER_SPRITE+7]=spriteB.Height; bufferCenter[index*FNUM_CENTER_PER_SPRITE]=spriteB.Center.X; bufferCenter[index*FNUM_CENTER_PER_SPRITE+1]=spriteB.Center.Y; bufferCenter[index*FNUM_CENTER_PER_SPRITE+2]=spriteB.Center.X; bufferCenter[index*FNUM_CENTER_PER_SPRITE+3]=spriteB.Center.Y; bufferCenter[index*FNUM_CENTER_PER_SPRITE+4]=spriteB.Center.X; bufferCenter[index*FNUM_CENTER_PER_SPRITE+5]=spriteB.Center.Y; bufferCenter[index*FNUM_CENTER_PER_SPRITE+6]=spriteB.Center.X; bufferCenter[index*FNUM_CENTER_PER_SPRITE+7]=spriteB.Center.Y; bufferRot[index*FNUM_ROT_PER_SPRITE]=spriteB.Rotation; bufferRot[index*FNUM_ROT_PER_SPRITE+1]=0.0f; bufferRot[index*FNUM_ROT_PER_SPRITE+2]=spriteB.Rotation; bufferRot[index*FNUM_ROT_PER_SPRITE+3]=0.0f; bufferRot[index*FNUM_ROT_PER_SPRITE+4]=spriteB.Rotation; bufferRot[index*FNUM_ROT_PER_SPRITE+5]=0.0f; bufferRot[index*FNUM_ROT_PER_SPRITE+6]=spriteB.Rotation; bufferRot[index*FNUM_ROT_PER_SPRITE+7]=0.0f; bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE]=spriteB.Position.X; //x bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+1]=spriteB.Position.Y; //y bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+2]=spriteB.Position.Z; //z bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+3]=spriteB.Position.X; //x bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+4]=spriteB.Position.Y; //y bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+5]=spriteB.Position.Z; //z bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+6]=spriteB.Position.X; //x bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+7]=spriteB.Position.Y; //y bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+8]=spriteB.Position.Z; //z bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+9]=spriteB.Position.X; //x bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+10]=spriteB.Position.Y;//y bufferSpritePosition[index*FNUM_SPOSITION_PER_SPRITE+11]=spriteB.Position.Z;//z // テクスチャ座標のコピー。 #if false bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE]=texcoords[0]; // left top u bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+1]=texcoords[1]; // left top v bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+2]=texcoords[2]; // left bottom u bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+3]=texcoords[3]; // left bottom v bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+4]=texcoords[4]; // right top u bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+5]=texcoords[5]; // right top v bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+6]=texcoords[6]; // right bottom u bufferTexcoords[index*TEXCOORD_SIZE_PER_SPRITE+7]=texcoords[7]; // right bottom v #else Buffer.BlockCopy(spriteB.Texcoords, 0, bufferTexcoords, index*FNUM_TEXCOORD_PER_SPRITE*sizeof(float), 8*sizeof(float)); #endif // colorのコピー。 #if false bufferColors[index*COLOR_SIZE_PER_SPRITE]=colors[0]; bufferColors[index*COLOR_SIZE_PER_SPRITE+1]=colors[1]; bufferColors[index*COLOR_SIZE_PER_SPRITE+2]=colors[2]; bufferColors[index*COLOR_SIZE_PER_SPRITE+3]=colors[3]; bufferColors[index*COLOR_SIZE_PER_SPRITE+4]=colors[4]; bufferColors[index*COLOR_SIZE_PER_SPRITE+5]=colors[5]; bufferColors[index*COLOR_SIZE_PER_SPRITE+6]=colors[6]; bufferColors[index*COLOR_SIZE_PER_SPRITE+7]=colors[7]; bufferColors[index*COLOR_SIZE_PER_SPRITE+8]=colors[8]; bufferColors[index*COLOR_SIZE_PER_SPRITE+9]=colors[9]; bufferColors[index*COLOR_SIZE_PER_SPRITE+10]=colors[10]; bufferColors[index*COLOR_SIZE_PER_SPRITE+11]=colors[11]; bufferColors[index*COLOR_SIZE_PER_SPRITE+12]=colors[12]; bufferColors[index*COLOR_SIZE_PER_SPRITE+13]=colors[13]; bufferColors[index*COLOR_SIZE_PER_SPRITE+14]=colors[14]; bufferColors[index*COLOR_SIZE_PER_SPRITE+15]=colors[15]; #else Buffer.BlockCopy(spriteB.Colors, 0, bufferColors, index*FNUM_COLOR_PER_SPRITE*sizeof(float), 16*sizeof(float)); #endif bufferIndices[index*INDEX_SIZE_PER_SPRITE] = (ushort)(index*VERTEX_NUM_PER_SPRITE); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 1] = (ushort)(index*VERTEX_NUM_PER_SPRITE+1); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 2] = (ushort)(index*VERTEX_NUM_PER_SPRITE+2); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 3] = (ushort)(index*VERTEX_NUM_PER_SPRITE+1); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 4] = (ushort)(index*VERTEX_NUM_PER_SPRITE+2); bufferIndices[index*INDEX_SIZE_PER_SPRITE + 5] = (ushort)(index*VERTEX_NUM_PER_SPRITE+3); }