public HalfPlane(Vector2 linePoint1, Vector2 linePoint2, Vector2 halflanePoint) { if (linePoint1 == linePoint2) { throw new ArgumentException("Line is undefined"); } Point1 = linePoint1; Point2 = linePoint2; //Create common line equation var a = linePoint1.Y - linePoint2.Y; var b = linePoint2.X - linePoint1.X; var c = linePoint1.X * linePoint2.Y - linePoint2.X * linePoint1.Y; var commonLine = a * halflanePoint.X + b * halflanePoint.Y + c; if (Mathf.Approximately(commonLine, 0)) { throw new ArgumentException("Plane half is not defined"); } if (commonLine < 0) { a = -a; b = -b; c = -c; } _a = a; _b = b; _c = c; }
public override void SetPars() { float sw, sh; sw = Vivid.App.AppInfo.RW; sh = Vivid.App.AppInfo.RH; float px, py; // px = Light.X + Graph.X; py = Light.Y + Graph.Y; px = Light.X * Graph.Z; py = Light.Y * Graph.Z; //px = (sw / 2) + px; //py = (sh / 2) + py; px = px - Graph.X * Graph.Z; py = py - Graph.Y * Graph.Z; OpenTK.Vector2 res = Maths.Rotate(px, py, Graph.Rot, 1.0f); res = Maths.Push(res, sw / 2, sh / 2); SetVec3("lPos", new OpenTK.Vector3(res.X, res.Y, 0)); SetTex("tShadow", 0); SetFloat("lRange", Light.Range * Graph.Z); SetFloat("sWidth", Vivid.App.AppInfo.RW); SetFloat("sHeight", Vivid.App.AppInfo.RH); SetMat("proj", OpenTK.Matrix4.CreateOrthographicOffCenter(0, Vivid.App.AppInfo.RW, Vivid.App.AppInfo.RH, 0, -1, 1000)); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.fieldpad = binaryReader.ReadBytes(2); this.Type = binaryReader.ReadInt16(); this.FramebufferBlendFunc = ((FramebufferBlendFuncEnum)(binaryReader.ReadInt16())); this.fieldpad0 = binaryReader.ReadBytes(2); this.fieldpad1 = binaryReader.ReadBytes(32); this.PrimaryAnchor = ((PrimaryAnchorEnum)(binaryReader.ReadInt16())); this.SecondaryAnchor = ((SecondaryAnchorEnum)(binaryReader.ReadInt16())); this.TertiaryAnchor = ((TertiaryAnchorEnum)(binaryReader.ReadInt16())); this._0To1BlendFunc = ((_0To1BlendFuncEnum)(binaryReader.ReadInt16())); this._1To2BlendFunc = ((_1To2BlendFuncEnum)(binaryReader.ReadInt16())); this.fieldpad2 = binaryReader.ReadBytes(2); this.PrimaryScale = binaryReader.ReadVector2(); this.SecondaryScale = binaryReader.ReadVector2(); this.TertiaryScale = binaryReader.ReadVector2(); this.PrimaryOffset = binaryReader.ReadVector2(); this.SecondaryOffset = binaryReader.ReadVector2(); this.TertiaryOffset = binaryReader.ReadVector2(); this.Primary = binaryReader.ReadTagReference(); this.Secondary = binaryReader.ReadTagReference(); this.Tertiary = binaryReader.ReadTagReference(); this.PrimaryWrapMode = ((PrimaryWrapModeEnum)(binaryReader.ReadInt16())); this.SecondaryWrapMode = ((SecondaryWrapModeEnum)(binaryReader.ReadInt16())); this.TertiaryWrapMode = ((TertiaryWrapModeEnum)(binaryReader.ReadInt16())); this.fieldpad3 = binaryReader.ReadBytes(2); this.fieldpad4 = binaryReader.ReadBytes(184); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(220)); this.fieldpad5 = binaryReader.ReadBytes(128); return(pointerQueue); }
private static Ray ConstructRayFromMousePosition(Vector3 localPosition) { Vector2 mpos = GameEngine.Instance.MousePosition; Vector3 mousepos = GameEngine.Instance.ConvertScreenToWorldCoords((int)mpos.X, (int)mpos.Y); return(new Ray(localPosition, (mousepos - localPosition).Normalized())); }
/// <summary> /// x = distance | /// y = theta /// </summary> /// <param name="coords"></param> /// <returns></returns> public static OpenTK.Vector2 GetPolarCoords(OpenTK.Vector2 value) { OpenTK.Vector2 vector = new OpenTK.Vector2(value.Length,(value.X != 0 ? (float)Math.Atan(value.Y / value.X) : (value.Y < 0 ? (float)Math.PI : 0)) + (GetSign(value.X) == 1 ? 1.5f : 0.5f) * (float)Math.PI);//fix errors //fix errors return vector; }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.FalloffAngle = binaryReader.ReadSingle(); this.CutoffAngle = binaryReader.ReadSingle(); this.fieldskip = binaryReader.ReadBytes(4); this.fieldskip0 = binaryReader.ReadBytes(4); this.OcclusionRadius = binaryReader.ReadSingle(); this.OcclusionOffsetDirection = ((OcclusionOffsetDirectionEnum)(binaryReader.ReadInt16())); this.OcclusionInnerRadiusScale = ((OcclusionInnerRadiusScaleEnum)(binaryReader.ReadInt16())); this.NearFadeDistance = binaryReader.ReadSingle(); this.FarFadeDistance = binaryReader.ReadSingle(); this.Bitmap = binaryReader.ReadTagReference(); this.LensFlareFlags = ((Flags)(binaryReader.ReadInt16())); this.fieldskip1 = binaryReader.ReadBytes(2); this.RotationFunction = ((RotationFunctionEnum)(binaryReader.ReadInt16())); this.fieldpad = binaryReader.ReadBytes(2); this.RotationFunctionScale = binaryReader.ReadSingle(); this.CoronaScale = binaryReader.ReadVector2(); this.FalloffFunction = ((FalloffFunctionEnum)(binaryReader.ReadInt16())); this.fieldpad0 = binaryReader.ReadBytes(2); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(48)); this.LensFlareLensFlareFlags0 = ((LensFlareFlags0)(binaryReader.ReadInt16())); this.fieldpad1 = binaryReader.ReadBytes(2); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(8)); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(8)); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(8)); return(pointerQueue); }
public Projectile(OpenTK.Vector2 position, OpenTK.Vector2 speed) { rotation = (float)r.NextDouble() * 360.0f; rotSpeed = ((float)r.NextDouble() * 10.0f) - ((float)r.NextDouble() * 10.0f); this.position = position; this.speed = speed; }
public override void SetPars( ) { float sw, sh; sw = FusionEngine.App.FusionApp.W; sh = FusionEngine.App.FusionApp.H; float px, py; // px = Light.X + Graph.X; py = Light.Y + Graph.Y; px = Light.X * Graph.Z; py = Light.Y * Graph.Z; //px = (sw / 2) + px; //py = (sh / 2) + py; px = px - Graph.X * Graph.Z; py = py - Graph.Y * Graph.Z; OpenTK.Vector2 res = Maths.Rotate(px, py, Graph.Rot, 1.0f); res = Maths.Push(res, sw / 2, sh / 2); SetTex("tDiffuse", 0); SetVec3("lPos", new OpenTK.Vector3(res.X, res.Y, 0)); SetVec3("lDif", Light.Diffuse); SetVec3("lSpec", Light.Specular); SetFloat("lShiny", Light.Shiny); SetFloat("lRange", Light.Range * Graph.Z); SetFloat("sWidth", FusionEngine.App.FusionApp.W); SetFloat("sHeight", FusionEngine.App.FusionApp.H); }
public override Blocks GenerateBlock2(Vector2i position, Heights macroHeight) { var rotatedPos = Vector2.Transform((Vector2)position, Quaternion.FromEulerAngles(0, 0, _hillsOrientation)); return(new Blocks(BlockType.Sand, BlockType.GoldOre, new Heights((float)(_dunesNoise.GetSimplex(rotatedPos.X / 10f, rotatedPos.Y / 30f)) * 2 + macroHeight.Main, macroHeight.Underground, macroHeight.Base))); //Вытянутые дюны }
public override void Render(OpenTK.Vector2 pos, float dis) { Draw.Pen2D.BlendMod = Draw.PenBlend.Alpha; float fW = 4690; float fH = 3300; float df = dis / 180000; df = 1.0f - df; if (df < 0) { df = 0.0f; } if (df == 0.0f) { return; } fW = fW * df; fH = fH * df; Draw.Pen2D.Rect(pos.X - fW / 2, pos.Y - fH / 2, fW, fH, BaseImg, new OpenTK.Vector4(1, 1, 1, 0.5f)); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.ScenarioFunctionFlags = ((Flags)(binaryReader.ReadInt32())); this.Name = binaryReader.ReadString32(); this.Period = binaryReader.ReadSingle(); this.ScalePeriodBy = binaryReader.ReadShortBlockIndex1(); this.Function = ((FunctionEnum)(binaryReader.ReadInt16())); this.ScaleFunctionBy = binaryReader.ReadShortBlockIndex1(); this.WobbleFunction = ((WobbleFunctionEnum)(binaryReader.ReadInt16())); this.WobblePeriod = binaryReader.ReadSingle(); this.WobbleMagnitude = binaryReader.ReadSingle(); this.SquareWaveThreshold = binaryReader.ReadSingle(); this.StepCount = binaryReader.ReadInt16(); this.MapTo = ((MapToEnum)(binaryReader.ReadInt16())); this.SawtoothCount = binaryReader.ReadInt16(); this.fieldpad = binaryReader.ReadBytes(2); this.ScaleResultBy = binaryReader.ReadShortBlockIndex1(); this.BoundsMode = ((BoundsModeEnum)(binaryReader.ReadInt16())); this.Bounds = binaryReader.ReadVector2(); this.fieldpad0 = binaryReader.ReadBytes(4); this.fieldpad1 = binaryReader.ReadBytes(2); this.TurnOffWith = binaryReader.ReadShortBlockIndex1(); this.fieldpad2 = binaryReader.ReadBytes(16); this.fieldpad3 = binaryReader.ReadBytes(16); return(pointerQueue); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.MagnetismFriction = binaryReader.ReadSingle(); this.MagnetismAdhesion = binaryReader.ReadSingle(); this.InconsequentialTargetScale = binaryReader.ReadSingle(); this.fieldpad = binaryReader.ReadBytes(12); this.CrosshairLocation = binaryReader.ReadVector2(); this.SecondsToStart = binaryReader.ReadSingle(); this.SecondsToFullSpeed = binaryReader.ReadSingle(); this.DecayRate = binaryReader.ReadSingle(); this.FullSpeedMultiplier = binaryReader.ReadSingle(); this.PeggedMagnitude = binaryReader.ReadSingle(); this.PeggedAngularThreshold = binaryReader.ReadSingle(); this.fieldpad0 = binaryReader.ReadBytes(8); this.LookDefaultPitchRate = binaryReader.ReadSingle(); this.LookDefaultYawRate = binaryReader.ReadSingle(); this.LookPegThreshold01 = binaryReader.ReadSingle(); this.LookYawAccelerationTime = binaryReader.ReadSingle(); this.LookYawAccelerationScale = binaryReader.ReadSingle(); this.LookPitchAccelerationTime = binaryReader.ReadSingle(); this.LookPitchAccelerationScale = binaryReader.ReadSingle(); this.LookAutolevellingScale = binaryReader.ReadSingle(); this.fieldpad1 = binaryReader.ReadBytes(8); this.GravityScale = binaryReader.ReadSingle(); this.fieldpad2 = binaryReader.ReadBytes(2); this.MinimumAutolevellingTicks = binaryReader.ReadInt16(); this.MinimumAngleForVehicleFlipping = binaryReader.ReadSingle(); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(4)); this.MinimumActionHoldTime = binaryReader.ReadSingle(); return(pointerQueue); }
private void editorY_Edited(object sender, EventArgs e) { if (this.IsUpdating) { return; } if (this.Disposed) { return; } if (!this.ReadOnly) { object[] values = this.GetValue().ToArray(); Vector2 newVal = (Vector2)this.DisplayedValue; for (int i = 0; i < values.Length; i++) { if (values[i] == null) { values[i] = this.DisplayedValue; } else { Vector2 oldVal = (Vector2)values[i]; values[i] = new Vector2(oldVal.X, newVal.Y); } } this.SetValues(values); } this.PerformGetValue(); }
public void PickScene(MouseEventInfo e, bool selectAction) { if (!_context.ColorPicker.EnablePicking) { return; } if (selectAction && !Keyboard.GetState().IsKeyDown(Key.ControlLeft)) { _context.Scene.ResetSelected(); } OpenTK.Vector2 position = new OpenTK.Vector2(e.Position.X, _context.Height - e.Position.Y); var pickable = _context.Scene.FindPickableAtPosition(_context, position); if (pickable != null) { pickable.IsHovered = true; if (selectAction) { pickable.IsSelected = true; } } GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); GL.Viewport(0, 0, Width, Height); if (_context.Scene.GetSelected().Count == 0) { _context.Scene.ActiveAction = null; } }
public void TestDefaultParams() { AssertReturn(TestStructDefaultParams(), 5, "TestStructDefaultParams"); OpenTK.Vector3 ZeroVec3 = OpenTK.Vector3.Zero; AssertReturn(TestStructDefaultParams(ZeroVec3), 4, "TestStructDefaultParams", "ZeroVec3"); OpenTK.Vector2 NonzeroVec2 = new OpenTK.Vector2(22.0f, 108.0f); AssertReturn(TestStructDefaultParams(ZeroVec3, NonzeroVec2), 3, "TestStructDefaultParams", "ZeroVec3, NonzeroVec2"); UnrealEngine.Core.LinearColor Black = new UnrealEngine.Core.LinearColor { R = 0.0f, G = 0.0f, B = 0.0f, A = 1.0f }; AssertReturn(TestStructDefaultParams(ZeroVec3, NonzeroVec2, Black), 2, "TestStructDefaultParams", "ZeroVec3, NonzeroVec2, Black"); Rotator NonzeroRotation = new Rotator(24.0f, 60.0f, 1.0f); AssertReturn(TestStructDefaultParams(ZeroVec3, NonzeroVec2, Black, NonzeroRotation), 1, "TestStructDefaultParams", "ZeroVec3, NonzeroVec2, Black, NonzeroRotation"); UnrealEngine.Core.Color Yellow = new UnrealEngine.Core.Color(255, 255, 0, 255); AssertReturn(TestStructDefaultParams(ZeroVec3, NonzeroVec2, Black, NonzeroRotation, Yellow), 0, "TestStructDefaultParams", "ZeroVec3, NonzeroVec2, Black, NonzeroRotation, Yellow"); }
/// <summary> Updates the position of the sprite based on the physics object </summary> public virtual void UpdatePosition() { Vector2 position = ConvertUnits.ToDisplayUnits(_MainBody.Position); Position = new OpenTK.Vector2(position.X, position.Y); Rotation = _MainBody.Rotation; }
public static void GenerateFace(List <Vector3> Verts, List <Vector2> UVs, List <INDEX_TYPE> TexIDs, INDEX_TYPE TexID, //Vector3 Normal, Vector3 A, Vector2 UVA, Vector3 B, Vector2 UVB, Vector3 C, Vector2 UVC, Vector3 D, Vector2 UVD) { for (int i = 0; i < 6; i++) { //Norms.Add(Normal); TexIDs.Add(TexID); } Verts.Add(A); Verts.Add(B); Verts.Add(C); Verts.Add(A); Verts.Add(C); Verts.Add(D); UVs.Add(UVA); UVs.Add(UVB); UVs.Add(UVC); UVs.Add(UVA); UVs.Add(UVC); UVs.Add(UVD); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.Name = binaryReader.ReadStringID(); this.Position = binaryReader.ReadVector3(); this.ReferenceFrame = binaryReader.ReadInt16(); this.fieldpad = binaryReader.ReadBytes(2); this.Facing = binaryReader.ReadVector2(); this.ActorStartingLocationsFlags = ((Flags)(binaryReader.ReadInt32())); this.CharacterType = binaryReader.ReadShortBlockIndex1(); this.InitialWeapon = binaryReader.ReadShortBlockIndex1(); this.InitialSecondaryWeapon = binaryReader.ReadShortBlockIndex1(); this.fieldpad0 = binaryReader.ReadBytes(2); this.VehicleType = binaryReader.ReadShortBlockIndex1(); this.SeatType = ((SeatTypeEnum)(binaryReader.ReadInt16())); this.GrenadeType = ((GrenadeTypeEnum)(binaryReader.ReadInt16())); this.SwarmCount = binaryReader.ReadInt16(); this.ActorVariantName = binaryReader.ReadStringID(); this.VehicleVariantName = binaryReader.ReadStringID(); this.InitialMovementDistance = binaryReader.ReadSingle(); this.EmitterVehicle = binaryReader.ReadShortBlockIndex1(); this.InitialMovementMode = ((InitialMovementModeEnum)(binaryReader.ReadInt16())); this.PlacementScript = binaryReader.ReadString32(); this.fieldskip = binaryReader.ReadBytes(2); this.fieldpad1 = binaryReader.ReadBytes(2); return(pointerQueue); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.Shader = binaryReader.ReadTagReference(); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(68)); pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.GeometryBlockInfo.ReadFields(binaryReader))); this.SunSpotColor = binaryReader.ReadColorR8G8B8(); this.ReflectionTint = binaryReader.ReadColorR8G8B8(); this.RefractionTint = binaryReader.ReadColorR8G8B8(); this.HorizonColor = binaryReader.ReadColorR8G8B8(); this.SunSpecularPower = binaryReader.ReadSingle(); this.ReflectionBumpScale = binaryReader.ReadSingle(); this.RefractionBumpScale = binaryReader.ReadSingle(); this.FresnelScale = binaryReader.ReadSingle(); this.SunDirHeading = binaryReader.ReadSingle(); this.SunDirPitch = binaryReader.ReadSingle(); this.FOV = binaryReader.ReadSingle(); this.Aspect = binaryReader.ReadSingle(); this.Height = binaryReader.ReadSingle(); this.Farz = binaryReader.ReadSingle(); this.RotateOffset = binaryReader.ReadSingle(); this.Center = binaryReader.ReadVector2(); this.Extents = binaryReader.ReadVector2(); this.FogNear = binaryReader.ReadSingle(); this.FogFar = binaryReader.ReadSingle(); this.DynamicHeightBias = binaryReader.ReadSingle(); return(pointerQueue); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.Name = binaryReader.ReadStringID(); pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.HudWidgetInputsStruct.ReadFields(binaryReader))); pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.HudWidgetStateDefinitionStruct.ReadFields(binaryReader))); this.Anchor = ((AnchorEnum)(binaryReader.ReadInt16())); this.HudBitmapWidgetsFlags = ((Flags)(binaryReader.ReadInt16())); this.Bitmap = binaryReader.ReadTagReference(); this.Shader = binaryReader.ReadTagReference(); this.FullscreenSequenceIndex = binaryReader.ReadByte(); this.HalfscreenSequenceIndex = binaryReader.ReadByte(); this.QuarterscreenSequenceIndex = binaryReader.ReadByte(); this.fieldpad = binaryReader.ReadBytes(1); this.FullscreenOffset = binaryReader.ReadPoint(); this.HalfscreenOffset = binaryReader.ReadPoint(); this.QuarterscreenOffset = binaryReader.ReadPoint(); this.FullscreenRegistrationPoint = binaryReader.ReadVector2(); this.HalfscreenRegistrationPoint = binaryReader.ReadVector2(); this.QuarterscreenRegistrationPoint = binaryReader.ReadVector2(); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(104)); this.SpecialHudType = ((SpecialHudTypeEnum)(binaryReader.ReadInt16())); this.fieldpad0 = binaryReader.ReadBytes(2); return(pointerQueue); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.InitialPosition = binaryReader.ReadVector3(); this.Uv = binaryReader.ReadVector2(); return(pointerQueue); }
//TODO: Maybe rewrite and document? /// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="name"></param> /// <param name="input"></param> public void SetAttribute <T>(String name, T input) { Int32 program = GL.GetUniformLocation(this.address, name); switch (typeof(T).Name) //hmm { case nameof(Int16): { Int16 output = (Int16)(Object)input; GL.Uniform1(program, output); break; } case nameof(Int32): { Int32 output = (Int32)(Object)input; GL.Uniform1(program, output); break; } case nameof(Int64): { Int64 output = (Int64)(Object)input; GL.Uniform1(program, output); break; } case nameof(Single): { Single output = (Single)(Object)input; GL.Uniform1(program, output); break; } case nameof(Double): { Double output = (Double)(Object)input; GL.Uniform1(program, output); break; } case nameof(OpenTK.Vector2): { OpenTK.Vector2 output = (OpenTK.Vector2)(Object) input; GL.Uniform2(program, ref output); break; } case nameof(OpenTK.Vector3): { OpenTK.Vector3 output = (OpenTK.Vector3)(Object) input; GL.Uniform3(program, ref output); break; } case nameof(OpenTK.Vector4): { OpenTK.Vector4 output = (OpenTK.Vector4)(Object) input; GL.Uniform4(program, ref output); break; } case nameof(OpenTK.Matrix2): { OpenTK.Matrix2 output = (OpenTK.Matrix2)(Object) input; GL.UniformMatrix2(program, false, ref output); break; } case nameof(OpenTK.Matrix3): { OpenTK.Matrix3 output = (OpenTK.Matrix3)(Object) input; GL.UniformMatrix3(program, false, ref output); break; } case nameof(OpenTK.Matrix4): { OpenTK.Matrix4 output = (OpenTK.Matrix4)(Object) input; GL.UniformMatrix4(program, false, ref output); break; } default: throw new Exception("Bad type providen"); } }
private float CalculateLength(float prec = 0.01f) { float sum = 0; for (float f = 0; f < 1f; f += prec) { if (f > 1) { f = 1; } float fplus = f + prec; if (fplus > 1) { fplus = 1; } Vector2 a = this.Interpolate(f); Vector2 b = this.Interpolate(fplus); float distance = this.Distance(a, b); if (sum == 0 || (this.PixelLength > 0 && distance + sum <= this.PixelLength)) { sum += distance; // take a snapshot of the current position, t value, and distance along the curve this.AddDistanceTime(sum, f, b); } else { break; } } return(sum); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.UpdatesPerSecond = binaryReader.ReadInt16(); this.fieldpad = binaryReader.ReadBytes(2); this.DeadCellPenalty = binaryReader.ReadSingle(); this.LiveCellBonus = binaryReader.ReadSingle(); this.fieldpad0 = binaryReader.ReadBytes(80); this.Width = binaryReader.ReadInt16(); this.Height = binaryReader.ReadInt16(); this.CellWidth = binaryReader.ReadSingle(); this.Height0 = binaryReader.ReadSingle(); this.Velocity = binaryReader.ReadVector2(); this.fieldpad1 = binaryReader.ReadBytes(28); this.Marker = binaryReader.ReadStringID(); this.CellularAutomata2dInterpolationFlags = ((InterpolationFlags)(binaryReader.ReadInt32())); this.BaseColor = binaryReader.ReadColorR8G8B8(); this.PeakColor = binaryReader.ReadColorR8G8B8(); this.fieldpad2 = binaryReader.ReadBytes(76); this.Width0 = binaryReader.ReadInt16(); this.Height1 = binaryReader.ReadInt16(); this.CellWidth0 = binaryReader.ReadSingle(); this.Velocity0 = binaryReader.ReadVector2(); this.fieldpad3 = binaryReader.ReadBytes(48); this.Marker0 = binaryReader.ReadStringID(); this.TextureWidth = binaryReader.ReadInt16(); this.fieldpad4 = binaryReader.ReadBytes(2); this.fieldpad5 = binaryReader.ReadBytes(48); this.Texture = binaryReader.ReadTagReference(); this.fieldpad6 = binaryReader.ReadBytes(160); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(84)); return(pointerQueue); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.GainModifier = binaryReader.ReadRange(); this.PitchModifier = binaryReader.ReadInt32(); this.SkipFractionModifier = binaryReader.ReadVector2(); return(pointerQueue); }
public void SetValue(Vector2 value) { GL.UseProgram(_parentEffect.CurrentTechnique.Passes[0].shaderProgram); OpenTK.Vector2 vect2 = new OpenTK.Vector2(value.X, value.Y); _cachedValue = vect2; GL.Uniform2(internalIndex, vect2.X, vect2.Y); GL.UseProgram(0); }
public Moveable(OpenTK.Vector3 pos, OpenTK.Vector2 dim, string filepath, float speed) : base(pos, dim, filepath) { direction = new OpenTK.Vector2(0.1f, 0.1f); moving_SBy = 0; speed_F = speed; ShadowCaster = true; }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.Position = binaryReader.ReadVector3(); this.Texcoord0 = binaryReader.ReadVector2(); this.Texcoord1 = binaryReader.ReadVector2(); this.Color = binaryReader.ReadColourR1G1B1(); return(pointerQueue); }
public override OpenTK.Vector2 Deserialize(ref byte[] bytes, int offset, DirtyTracker tracker, out int byteSize) { var result = new OpenTK.Vector2(); result.X = (float)BinaryUtil.ReadSingle(ref bytes, offset); result.Y = (float)BinaryUtil.ReadSingle(ref bytes, offset + Marshal.SizeOf(typeof(float))); byteSize = OpenTK.Vector2.SizeInBytes; return(result); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.fieldpad = binaryReader.ReadBytes(4); this.Name = binaryReader.ReadString32(); this.Position = binaryReader.ReadVector3(); this.Facing = binaryReader.ReadVector2(); return(pointerQueue); }
public Particle(OpenTK.Vector2 position, OpenTK.Vector2 vel, System.Drawing.Color theColor, float size) { this.size = size; this.theColor = theColor; this.position = position; this.vel = vel; rotation = (float)r.NextDouble() * 360.0f; rotationSpeed = (float)(r.NextDouble() - r.NextDouble()) *4.0f; }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.Position = binaryReader.ReadVector3(); this.StartingYawPitch = binaryReader.ReadVector2(); this.Radius = binaryReader.ReadSingle(); this.Weight = binaryReader.ReadSingle(); return(pointerQueue); }
private void AddDistanceTime(float distance, float time, Vector2 point) { DistanceTime dt = new DistanceTime(); dt.distance = distance; dt.t = time; dt.point = point; this.CurveSnapshots.Add(dt); }
internal bool MoveCheck(Vector2 Point, out Cursor.Status Status) { if (!Loading.SimulationSetup) { Status = Cursor.Status.Default; return(false); } if (renderer.Camera.CurrentMode != CameraViewMode.Interior && renderer.Camera.CurrentMode != CameraViewMode.InteriorLookAhead) { Status = Cursor.Status.Default; return(false); } Status = Cursor.Status.Default; CarBase Car = TrainManager.PlayerTrain.Cars[TrainManager.PlayerTrain.DriverCar]; int add = Car.CarSections[0].CurrentAdditionalGroup + 1; if (add >= Car.CarSections[0].Groups.Length) { return(false); } TouchElement[] TouchElements = Car.CarSections[0].Groups[add].TouchElements; if (TouchElements == null) { return(false); } ObjectState pickedObject = renderer.AvailableNewRenderer ? ParseFBO(Point, 5, 5) : RenderSceneSelection(Point, new Vector2(5.0f)); foreach (TouchElement TouchElement in TouchElements.Where(x => x.Element.internalObject == pickedObject)) { foreach (int index in TouchElement.ControlIndices) { switch (Interface.CurrentControls[index].Command) { case Translations.Command.PowerIncrease: case Translations.Command.BrakeIncrease: case Translations.Command.ReverserForward: Status = Cursor.Status.Plus; break; case Translations.Command.PowerDecrease: case Translations.Command.BrakeDecrease: case Translations.Command.ReverserBackward: Status = Cursor.Status.Minus; break; } } } return(pickedObject != null); }
public void tick() { this.position += vel; this.rotation += rotationSpeed; life -= 0.01f; if (life < 0.01f) { life = 0.0f; dead = true; } }
public Map(int w, int h) { map = new Tile[w,h]; for (int i = 0; i < w; i++) { for(int j = 0; j < h; j++) { map[i,j] = new Tile(); } } Size = new Vector2(w, h); }
public Corner(int vertexIndex, Vertex3f vertex, Colour4f colour, int triangleNumber) { this.vertexIndex = vertexIndex; this.triangleNumber = triangleNumber; this.visited = false; this.colour = new Colour4f(colour); this.textured = false; this.textureCenter = false; this.branched = false; this.textureCoordinates = new OpenTK.Vector2(0.0f, 0.0f); this.vertex = vertex; }
private void editorX_Edited(object sender, EventArgs e) { if (this.IsUpdatingFromObject) return; if (!this.ReadOnly) { object[] values = this.GetValue().ToArray(); Vector2 newVal = (Vector2)this.DisplayedValue; for (int i = 0; i < values.Length; i++) { if (values[i] == null) values[i] = this.DisplayedValue; else { Vector2 oldVal = (Vector2)values[i]; values[i] = new Vector2(newVal.X, oldVal.Y); } } this.SetValues(values); } this.PerformGetValue(); }
public int IndexOf(TriangulationPoint p) { int i = this.Points.IndexOf(p); if (i == -1) { throw new Exception("Calling index with a point that doesn't exist in triangle"); } return i; }
public void SetValue (Vector2 value) { GL.UseProgram(_parentEffect.CurrentTechnique.Passes[0].shaderProgram); OpenTK.Vector2 vect2 = new OpenTK.Vector2(value.X, value.Y); _cachedValue = vect2; GL.Uniform2(internalIndex,vect2.X, vect2.Y); GL.UseProgram(0); }
/// <summary> /// Update neighbor pointers /// </summary> /// <param name="p1">Point 1 of the shared edge</param> /// <param name="p2">Point 2 of the shared edge</param> /// <param name="t">This triangle's new neighbor</param> private void MarkNeighbor(TriangulationPoint p1, TriangulationPoint p2, DelaunayTriangle t) { int i = this.EdgeIndex(p1, p2); if (i == -1) { throw new Exception("Error marking neighbors -- t doesn't contain edge p1-p2!"); } this.Neighbors[i] = t; }
public void SetDelaunayEdgeAcross(TriangulationPoint p, bool ce) { this.EdgeIsDelaunay[this.IndexOf(p)] = ce; }
public int IndexCWFrom(TriangulationPoint p) { return (this.IndexOf(p) + 2) % 3; }
public TextureCoords(OpenTK.Vector2 pos) { Position = pos; }
public DelaunayTriangle NeighborAcrossFrom(TriangulationPoint point) { return this.Neighbors[this.Points.IndexOf(point)]; }
public bool Contains(TriangulationPoint p) { return this.Points.Contains(p); }
public void Update(player pl) { Direction = new OpenTK.Vector2(0, 0); AI(pl); base.Update(); }
/// <param name="t">Opposite triangle</param> /// <param name="p">The point in t that isn't shared between the triangles</param> public TriangulationPoint OppositePoint(DelaunayTriangle t, TriangulationPoint p) { Debug.Assert(t != this, "self-pointer error"); return this.PointCWFrom(t.PointCWFrom(p)); }
public TriangulationPoint PointCWFrom(TriangulationPoint point) { return this.Points[(this.IndexOf(point) + 2) % 3]; }
public void SetConstrainedEdgeAcross(TriangulationPoint p, bool ce) { this.EdgeIsConstrained[this.IndexOf(p)] = ce; }
public void SetConstrainedEdgeCW(TriangulationPoint p, bool ce) { this.EdgeIsConstrained[(this.IndexOf(p) + 1) % 3] = ce; }
public DelaunayTriangle(TriangulationPoint p1, TriangulationPoint p2, TriangulationPoint p3) { this.Points[0] = p1; this.Points[1] = p2; this.Points[2] = p3; }
public TextureCoords(float x, float y) { Position = new OpenTK.Vector2(x, y); }
/// <summary> /// Mark edge as constrained /// </summary> public void MarkConstrainedEdge(TriangulationPoint p, TriangulationPoint q) { int i = this.EdgeIndex(p, q); if (i != -1) { this.EdgeIsConstrained[i] = true; } }
/// <summary> /// Legalize triangle by rotating clockwise around oPoint /// </summary> /// <param name="oPoint">The origin point to rotate around</param> /// <param name="nPoint">???</param> public void Legalize(TriangulationPoint oPoint, TriangulationPoint nPoint) { this.RotateCW(); this.Points[this.IndexCCWFrom(oPoint)] = nPoint; }
void spawnEnemy() { float angle = (float)r.NextDouble() * 360.0f; OpenTK.Vector2 position = new OpenTK.Vector2(-(float)Math.Sin(angle), (float)Math.Cos(angle)) * 200.0f; OpenTK.Vector2 velocity = new OpenTK.Vector2(-(float)Math.Sin(angle), (float)Math.Cos(angle)) * -0.1f; Enemy e = new Enemy(position, velocity); e.fireRate = waves[currentWave].enemyFireRate; lock (theEnemies) theEnemies.Add(e); lastEnemySpawn = DateTime.Now; }
public DelaunayTriangle NeighborCWFrom(TriangulationPoint point) { return this.Neighbors[(this.Points.IndexOf(point) + 1) % 3]; }
public void SetDelaunayEdgeCW(TriangulationPoint p, bool ce) { this.EdgeIsDelaunay[(this.IndexOf(p) + 1) % 3] = ce; }
private void AI(player pl) { //if ((pl.Position.X >= Centerpoint.X - 0.0500f && pl.Position.Y <= Centerpoint.Y + 0.0500f) // || (pl.Position.X <= Centerpoint.X + 0.0500f && pl.Position.Y <= Centerpoint.Y + 0.0500f) // || (pl.Position.X >= Centerpoint.X - 0.0500f && pl.Position.Y >= Centerpoint.Y - 0.0500f) // || (pl.Position.X <= Centerpoint.X + 0.0500f && pl.Position.Y >= Centerpoint.Y - 0.0500f)) //{ // if (pl.Position == Centerpoint) // { // Direction = new OpenTK.Vector2(0, 0); // } // if (pl.Position.X - Centerpoint.X > 0) // { // Direction = new OpenTK.Vector2(0.0005f, Direction.Y); // } // else if (pl.Position.X - Centerpoint.X <0) // { // Direction = new OpenTK.Vector2(-0.0005f, Direction.Y); // } // if (pl.Position.Y - Centerpoint.Y > 0) // { // Direction = new OpenTK.Vector2(Direction.X, 0.0005f); // } // else if (pl.Position.Y - Centerpoint.Y < 0) // { // Direction = new OpenTK.Vector2(Direction.X, -0.0005f); // } //} //else //{ if(counter == 1000) { a = rand.Next(0, 100); counter = 0; } if(a <= 25) { Direction = new OpenTK.Vector2(Direction.X, 50f); } else if(a > 25 && a < 50) { Direction = new OpenTK.Vector2(Direction.X, -50f); } else if(a > 50 && a < 75) { Direction = new OpenTK.Vector2(50f, Direction.Y); } else if(a > 75 && a < 100) { Direction = new OpenTK.Vector2(-50f, Direction.Y); } counter++; //} }
ObjModel CreateSphere(double R, double H, double K, double Z) { List<OpenTK.Vector3> Vertecies = new List<OpenTK.Vector3>(); List<OpenTK.Vector2> TextCoords = new List<OpenTK.Vector2>(); int n; double a; double b; n = 0; for (b = 0; b <= 90 - space; b += space) { for (a = 0; a <= 360 - space; a += space) { var v1 = new OpenTK.Vector3((float)(R * Math.Sin ((a) / 180 * Math.PI ) * Math.Sin ((b) / 180 * Math.PI) - H), (float)(R * Math.Cos ((a) / 180 * Math.PI ) * Math.Sin ((b) / 180 * Math.PI ) + K), (float)(R * Math.Cos ((b) / 180 * Math.PI ) - Z)); var t1 = new OpenTK.Vector2((float)((2 * b) / 360),(float)((a) / 360)); n++; var v2 = new OpenTK.Vector3((float)(R * Math.Sin ((a) / 180 * Math.PI ) * Math.Sin ((b + space) / 180 * Math.PI ) - H), (float)(R * Math.Cos ((a) / 180 * Math.PI ) * Math.Sin ((b + space) / 180 * Math.PI ) + K), (float)(R * Math.Cos ((b + space) / 180 * Math.PI ) - Z)); var t2 = new OpenTK.Vector2((float)((2 * (b + space)) / 360), (float)((a) / 360)); n++; var v3 = new OpenTK.Vector3((float)(R * Math.Sin ((a + space) / 180 * Math.PI ) * Math.Sin ((b) / 180 * Math.PI ) - H), (float)(R * Math.Cos ((a + space) / 180 * Math.PI ) * Math.Sin ((b) / 180 * Math.PI ) + K), (float)(R * Math.Cos ((b) / 180 * Math.PI ) - Z)); var t3 = new OpenTK.Vector2((float)((2 * b) / 360), (float)((a + space) / 360)); n++; var v4 = new OpenTK.Vector3((float)( R * Math.Sin ((a + space) / 180 * Math.PI ) * Math.Sin ((b + space) / 180 * Math.PI ) - H), (float)(R * Math.Cos ((a + space) / 180 * Math.PI ) * Math.Sin ((b + space) / 180 * Math.PI ) + K), (float)(R * Math.Cos ((b + space) / 180 * Math.PI ) - Z)); var t4 = new OpenTK.Vector2((float)((2 * (b + space)) / 360), (float)((a + space) / 360)); n++; Vertecies.Add(v1); Vertecies.Add(v2); Vertecies.Add(v3); Vertecies.Add(v4); TextCoords.Add(t1); TextCoords.Add(t2); TextCoords.Add(t3); TextCoords.Add(t4); } } return new ObjModel(){Verticies = Vertecies.ToArray(), TextureCoords = TextCoords.ToArray()}; }