public void RenderAABB(Graphics.Camera camera) { if (_model != null) { _model.RenderAABBAt(_position, _facingAngle, camera); } }
public override void Draw(Cairo.Context ctx, Vector3 origin, Graphics.Camera camera) { // just draw a circle var pos = camera.Transform(this.position) - camera.Transform(origin); var cl = this.color; ctx.SetSourceRGB(cl.x, cl.y, cl.z); ctx.Arc(pos.x, pos.y, this.radius, 0, 2 * Math.PI); ctx.Fill(); }
public static void Update(Graphics.Camera camera) { for (int i = 0; i < _playingSounds.Count;) { if (_playingSounds[i].Instance.State == AudioEngine.SoundState.Stopped) { // the sound is stopped, so update the wait handle if (_playingSounds[i].Wait != null) { _playingSounds[i].Wait.Finished = true; } // remove sounds ready to die if (_playingSounds[i].Released) { _playingSounds[i].Dispose(); _playingSounds.RemoveAt(i); } else { i++; } } else { i++; } } if (camera != null) { Math.Vector3 position = camera.Position; Math.Vector3 forward = camera.Orientation * -Math.Vector3.Forward; Math.Vector3 up = camera.Orientation * Math.Vector3.Up; AL.Listener(ALListener3f.Position, position.X, position.Y, position.Z); _listenerOrientation[0] = forward.X; _listenerOrientation[1] = forward.Y; _listenerOrientation[2] = forward.Z; _listenerOrientation[3] = up.X; _listenerOrientation[4] = up.Y; _listenerOrientation[5] = up.Z; AL.Listener(ALListenerfv.Orientation, ref _listenerOrientation); } }
public GameLogic(Game.GameManager game, AI.AICore ai) { this.ai = ai; this.game = game; this.deadGuards = new List <GameNPC>(); this.respawnTimers = new List <Timer>(); actions = this.LoadActions("Settings\\AttackSpells.xml"); fireballInfo = new WiccanRede.AI.ActionInfo(); this.camera = Graphics.Camera.GetCameraInstance(); fireballInfo.startPosition = camera.GetVector3Position(); fireballInfo.targetPosition = camera.GetVector3Position(); fireballInfo.targetName = "NPC"; fireballInfo.npcName = "Hrac"; fireballInfo.action = actions[0]; }
/// <summary> /// Called when this component spawns. /// </summary> protected override void OnSpawn() { // get camera and copy starting direction Graphics.Camera camera = _GameObject.GetComponent <Graphics.Camera>(); camera.UpdateCameraView(); Direction = camera.Forward; // cancel lookat camera.LookAt = null; camera.LookAtTarget = null; // set starting rotation float yaw; float pitch; float roll; Core.Utils.ExtendedMath.ExtractYawPitchRoll(camera.View, out yaw, out pitch, out roll); _currRotation.X = yaw; _currRotation.Y = pitch; }
public CameraController(IState inputState, Graphics.Camera camera) { if (inputState == null) { throw new ArgumentNullException("inputState"); } if (camera == null) { throw new ArgumentNullException("camera"); } this.inputState = inputState; inputMoveForward = inputState.Register("moveForward"); inputMoveBackward = inputState.Register("moveBackward"); inputStrafeLeft = inputState.Register("strafeLeft"); inputStrafeRight = inputState.Register("strafeRight"); this.camera = camera; mouseSensitivity = 500.0f; }
public override void Draw(Cairo.Context ctx, Vector3 origin, Graphics.Camera camera) { Vector3[] vertices = new Vector3[] { ToExternalPosition(new Vector3((dimensions.x - line_width) / 2, (dimensions.y - line_width) / 2, (dimensions.z - line_width) / 2)), ToExternalPosition(new Vector3((dimensions.x - line_width) / 2, (dimensions.y - line_width) / 2, -(dimensions.z - line_width) / 2)), ToExternalPosition(new Vector3((dimensions.x - line_width) / 2, -(dimensions.y - line_width) / 2, (dimensions.z - line_width) / 2)), ToExternalPosition(new Vector3((dimensions.x - line_width) / 2, -(dimensions.y - line_width) / 2, -(dimensions.z - line_width) / 2)), ToExternalPosition(new Vector3(-(dimensions.x - line_width) / 2, (dimensions.y - line_width) / 2, (dimensions.z - line_width) / 2)), ToExternalPosition(new Vector3(-(dimensions.x - line_width) / 2, (dimensions.y - line_width) / 2, -(dimensions.z - line_width) / 2)), ToExternalPosition(new Vector3(-(dimensions.x - line_width) / 2, -(dimensions.y - line_width) / 2, (dimensions.z - line_width) / 2)), ToExternalPosition(new Vector3(-(dimensions.x - line_width) / 2, -(dimensions.y - line_width) / 2, -(dimensions.z - line_width) / 2)), }; // vertices adjacent to each (but not repeated) int[][] adjacency = new int[][] { new int[] { 1, 2, 4 }, new int[] { 3, 5 }, new int[] { 3, 6 }, new int[] { 7 }, new int[] { 5, 6 }, new int[] { 7 }, new int[] { 7 } }; var cl = this.color; ctx.SetSourceRGB(cl.x, cl.y, cl.z); ctx.LineWidth = this.line_width; for (int i = 0; i < 7; i++) { foreach (int j in adjacency[i]) { var p1 = camera.Transform(vertices[i]) - camera.Transform(origin); var p2 = camera.Transform(vertices[j]) - camera.Transform(origin); ctx.MoveTo(p1.x, p1.y); ctx.LineTo(p2.x, p2.y); ctx.Stroke(); } } }
public void Update(Graphics.Camera camera) { camera.SetPitchYaw(Utils.DegreesToRadians(PitchDegrees), Utils.DegreesToRadians(YawDegrees)); camera.Position = new Math.Vector3(X, Y, Z); }
public virtual void DrawEffectiveAttackRangeCircle(Graphics.Camera camera, float lookatDir, System.Drawing.Color color) { Program.Instance.DrawArc(Game.Instance.Scene.Camera, Matrix.Identity, MediatorOffsetedPosition, EffectiveRange, 12, lookatDir, EffectiveAngle, color); }
void UpdateLoop() { WaitHandle.WaitAll(new WaitHandle[] { RendererReady }); Physics.Resources.ResourceLoaders.Init(CoreResources, FileSystem); Physics.Resources.ResourceLoaders.Init(GameResources, FileSystem); DeferredRenderer = new Graphics.Deferred.DeferredRenderer(CoreResources, GraphicsBackend, GraphicsBackend.Width, GraphicsBackend.Height); PostEffectManager = new Graphics.Post.PostEffectManager(FileSystem, CoreResources, GraphicsBackend, GraphicsBackend.Width, GraphicsBackend.Height); AudioSystem = new Audio.AudioSystem(FileSystem); PhysicsWorld = new Triton.Physics.World(GraphicsBackend, GameResources); Stage = new Graphics.Stage(GameResources); Camera = new Graphics.Camera(new Vector2(GraphicsBackend.Width, GraphicsBackend.Height)); InputManager = new Input.InputManager(Window.Bounds); GameWorld = new World.GameObjectManager(Stage, InputManager, GameResources, PhysicsWorld, Camera); LoadCoreResources(); // Wait until all initial resources have been loaded while (!CoreResources.AllResourcesLoaded()) { Thread.Sleep(1); } Log.WriteLine("Core resources loaded"); LoadResources(); while (!GameResources.AllResourcesLoaded()) { Thread.Sleep(1); } var watch = new System.Diagnostics.Stopwatch(); watch.Start(); var accumulator = 0.0f; while (Running) { FrameCount++; watch.Restart(); ElapsedTime += FrameTime; if (Window.Focused) { InputManager.Update(); } accumulator += FrameTime; while (accumulator >= PhysicsStepSize) { PhysicsWorld.Update(PhysicsStepSize); accumulator -= PhysicsStepSize; } AudioSystem.Update(); GameWorld.Update(FrameTime); Update(FrameTime); RenderScene(FrameTime, watch); FrameTime = (float)watch.Elapsed.TotalSeconds; Thread.Sleep(1); } }
public abstract void Draw(Cairo.Context ctx, Vector3 origin, Graphics.Camera camera);
/// <summary> /// Called every frame in the Update() loop. /// Note: this is called only if GameObject is enabled. /// </summary> protected override void OnUpdate() { // get current speed factor float speed = Managers.TimeManager.TimeFactor * MovementSpeedFactor; // get camera component Graphics.Camera camera = _GameObject.GetComponent <Graphics.Camera>(); // move camera forward if (Managers.GameInput.IsKeyDown(Input.GameKeys.Forward)) { _GameObject.SceneNode.Position += Direction * speed; } // move camera backward if (Managers.GameInput.IsKeyDown(Input.GameKeys.Backward)) { _GameObject.SceneNode.Position += -Direction * speed; } // move camera left if (Managers.GameInput.IsKeyDown(Input.GameKeys.Left)) { _GameObject.SceneNode.Position += Core.Utils.ExtendedMath.GetLeftVector(Direction, true) * speed; } // move camera right if (Managers.GameInput.IsKeyDown(Input.GameKeys.Right)) { _GameObject.SceneNode.Position += Core.Utils.ExtendedMath.GetRightVector(Direction, true) * speed; } // rotate camera if (Managers.GameInput.IsKeyDown(RotationKey)) { // get rotation factor (note: rotation is based on mouse diff and angles, therefore we don't need to add time factor) Vector2 rotation = Managers.GameInput.MousePositionDiff * (RotationSpeedFactor / 250f); // if need to rotate.. if (rotation.X != 0 || rotation.Y != 0) { // invert if needed if (InvertY) { rotation.Y *= -1; } if (InvertX) { rotation.X *= -1; } // update rotation _currRotation += rotation; // prevent overflow on Y axis if (PreventOverflowY) { _currRotation.Y = MathHelper.Min(MathHelper.Pi / 2f - 0.001f, _currRotation.Y); _currRotation.Y = MathHelper.Max(-MathHelper.Pi / 2f + 0.001f, _currRotation.Y); } } } // set new direction Direction = Vector3.Transform(Vector3.Forward, Matrix.CreateFromYawPitchRoll(_currRotation.X, _currRotation.Y, 0f)); // update camera look-at direction camera.LookAt = _GameObject.SceneNode.WorldPosition + Direction; }