public Color(Vec4 vec) : this(vec.x, vec.y, vec.z, vec.w) { }
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(); }
public static bool Rect(Rectangle r1, Vec4 r2) => (double)r1.y + (double)r1.height >= (double)r2.y && (double)r1.y <= (double)r2.y + (double)r2.w && (double)r1.x <= (double)r2.x + (double)r2.z && (double)r1.x + (double)r1.width >= (double)r2.x;
public void Dot(ref Vec4 value, out float result) => result = (float)((double)this.normal.x * (double)value.x + (double)this.normal.y * (double)value.y + (double)this.normal.z * (double)value.z + (double)this.d * (double)value.w);
public float Dot(Vec4 value) => (float)((double)this.normal.x * (double)value.x + (double)this.normal.y * (double)value.y + (double)this.normal.z * (double)value.z + (double)this.d * (double)value.w);
public Plane(Vec4 value) : this(new Vec3(value.x, value.y, value.z), value.w) { }