public void DrawRecorderItem(ref RecorderFrameItem frame) { MTSpriteBatchItem batchItem = this._batcher.CreateBatchItem(); batchItem.Depth = frame.depth; if (frame.texture == (short)-1) { batchItem.Texture = DuckGame.Graphics.blankWhiteSquare.nativeObject as Texture2D; } else { Tex2D tex2DfromIndex = Content.GetTex2DFromIndex(frame.texture); if (tex2DfromIndex == null) { return; } batchItem.Texture = tex2DfromIndex.nativeObject as Texture2D; } if (batchItem.Texture == null) { return; } float num1 = (float)Math.Abs(frame.texW); float num2 = (float)Math.Abs(frame.texH); this._texCoordTL.x = (float)((double)frame.texX / (double)batchItem.Texture.Width + 9.99999974737875E-06); this._texCoordTL.y = (float)((double)frame.texY / (double)batchItem.Texture.Height + 9.99999974737875E-06); this._texCoordBR.x = (float)(((double)frame.texX + (double)num1) / (double)batchItem.Texture.Width - 9.99999974737875E-06); this._texCoordBR.y = (float)(((double)frame.texY + (double)num2) / (double)batchItem.Texture.Height - 9.99999974737875E-06); if (frame.texH < (short)0) { float y = this._texCoordBR.y; this._texCoordBR.y = this._texCoordTL.y; this._texCoordTL.y = y; } if (frame.texW < (short)0) { float x = this._texCoordBR.x; this._texCoordBR.x = this._texCoordTL.x; this._texCoordTL.x = x; } Vec2 vec2 = frame.bottomRight.Rotate(-frame.rotation, frame.topLeft); batchItem.Set(frame.topLeft.x, frame.topLeft.y, 0.0f, 0.0f, vec2.x - frame.topLeft.x, vec2.y - frame.topLeft.y, (float)Math.Sin((double)frame.rotation), (float)Math.Cos((double)frame.rotation), frame.color, this._texCoordTL, this._texCoordBR); }
public void DrawQuad( Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, Vec2 t1, Vec2 t2, Vec2 t3, Vec2 t4, float depth, Tex2D tex, Color c) { ++DuckGame.Graphics.currentDrawIndex; MTSpriteBatchItem batchItem = this._batcher.CreateBatchItem(); batchItem.Depth = depth; batchItem.Texture = tex.nativeObject as Texture2D; batchItem.Material = (Material)null; batchItem.Set(p1, p2, p3, p4, t1, t2, t3, t4, c); }
internal void DoDrawInternalTex2D( Tex2D texture, Vec4 destinationRectangle, Rectangle?sourceRectangle, Color color, float rotation, Vec2 origin, SpriteEffects effect, float depth, bool autoFlush, Material fx) { ++DuckGame.Graphics.currentDrawIndex; MTSpriteBatchItem batchItem = this._batcher.CreateBatchItem(); batchItem.Depth = depth; batchItem.Texture = texture.nativeObject as Texture2D; batchItem.Material = fx; if (sourceRectangle.HasValue) { this._tempRect = sourceRectangle.Value; } else { this._tempRect.x = 0.0f; this._tempRect.y = 0.0f; this._tempRect.width = (float)texture.width; this._tempRect.height = (float)texture.height; } this._texCoordTL.x = (float)((double)this._tempRect.x / (double)texture.width + 9.99999974737875E-06); this._texCoordTL.y = (float)((double)this._tempRect.y / (double)texture.height + 9.99999974737875E-06); this._texCoordBR.x = (float)(((double)this._tempRect.x + (double)this._tempRect.width) / (double)texture.width - 9.99999974737875E-06); this._texCoordBR.y = (float)(((double)this._tempRect.y + (double)this._tempRect.height) / (double)texture.height - 9.99999974737875E-06); if ((effect & SpriteEffects.FlipVertically) != SpriteEffects.None) { float y = this._texCoordBR.y; this._texCoordBR.y = this._texCoordTL.y; this._texCoordTL.y = y; } if ((effect & SpriteEffects.FlipHorizontally) != SpriteEffects.None) { float x = this._texCoordBR.x; this._texCoordBR.x = this._texCoordTL.x; this._texCoordTL.x = x; } batchItem.Set(destinationRectangle.x, destinationRectangle.y, -origin.x, -origin.y, destinationRectangle.z, destinationRectangle.w, (float)Math.Sin((double)rotation), (float)Math.Cos((double)rotation), color, this._texCoordTL, this._texCoordBR); if (Recorder.currentRecording != null) { if (DuckGame.Graphics.recordMetadata) { batchItem.MetaData = new MTSpriteBatchItemMetaData(); batchItem.MetaData.texture = texture; batchItem.MetaData.rotation = rotation; batchItem.MetaData.color = color; batchItem.MetaData.tempRect = this._tempRect; batchItem.MetaData.effect = effect; batchItem.MetaData.depth = depth; } Recorder.currentRecording.LogDraw(texture.textureIndex, new Vec2(batchItem.vertexTL.Position.X, batchItem.vertexTL.Position.Y), new Vec2(batchItem.vertexBR.Position.X, batchItem.vertexBR.Position.Y), rotation, color, (short)this._tempRect.x, (short)this._tempRect.y, (short)((double)this._tempRect.width * ((effect & SpriteEffects.FlipHorizontally) != SpriteEffects.None ? -1.0 : 1.0)), (short)((double)this._tempRect.height * ((effect & SpriteEffects.FlipVertically) != SpriteEffects.None ? -1.0 : 1.0)), depth, texture.currentObjectIndex, DuckGame.Graphics.currentObjectIndex, DuckGame.Graphics.currentDrawIndex); } if (Recorder.globalRecording != null) { Recorder.globalRecording.LogDraw(texture.textureIndex, new Vec2(batchItem.vertexTL.Position.X, batchItem.vertexTL.Position.Y), new Vec2(batchItem.vertexBR.Position.X, batchItem.vertexBR.Position.Y), rotation, color, (short)this._tempRect.x, (short)this._tempRect.y, (short)((double)this._tempRect.width * ((effect & SpriteEffects.FlipHorizontally) != SpriteEffects.None ? -1.0 : 1.0)), (short)((double)this._tempRect.height * ((effect & SpriteEffects.FlipVertically) != SpriteEffects.None ? -1.0 : 1.0)), depth, texture.currentObjectIndex, DuckGame.Graphics.currentObjectIndex, DuckGame.Graphics.currentDrawIndex); } if (!autoFlush) { return; } this.FlushIfNeeded(); }