public Player(MasterRenderer renderer, World world, SimpleCamera camera, Vector3 position, Team team) : base(position, 11, 5, 2.5f) { this.masterRenderer = renderer; this.World = world; this.camera = camera; Team = team; if (!GlobalNetwork.IsServer) { debugRenderer = renderer.GetRenderer3D <DebugRenderer>(); entRenderer = renderer.GetRenderer3D <EntityRenderer>(); base.Renderer.VoxelObject = new DebugVOCube(world.GetTeamColor(team).ToColor4(), 1); flashlight = new Light(Vector3.Zero, LightType.Spot, 2, Color.White, new Vector3(1, 0, 0.002f)) { Radius = MathHelper.ToRadians(45), Visible = false }; renderer.Lights.Add(flashlight); } HitFeedbackPositions = new List <Vector3>(); Viewbob = GlobalNetwork.IsClient ? new ItemViewbob(this) : null; ItemManager = new ItemManager(renderer, this, world, Viewbob); }
/// <inheritdoc /> public override void Initialize() { Camera = new SimpleCamera(GraphicsDevice.Viewport.AspectRatio, new Vector3(-400f, 1000f, 2000f), 400, 1.0f, 1, 6000); base.Initialize(); }
protected Matrix4 CalculateWorldMatrix(ItemViewbob viewbob) { SimpleCamera camera = OwnerPlayer.GetCamera(); if (OwnerPlayer.IsRenderingThirdperson) { return(Matrix4.CreateScale(ThirdpersonScale) * Matrix4.CreateTranslation(0, 1.5f, -0.25f) * Matrix4.CreateRotationX(MathHelper.ToRadians(ModelRotation.X)) * Matrix4.CreateRotationY(MathHelper.ToRadians(ModelRotation.Y)) * Matrix4.CreateRotationZ(MathHelper.ToRadians(viewbob.CurrentTilt + ModelRotation.Z)) * Matrix4.CreateTranslation(ModelOffset + viewbob.CurrentViewBob + new Vector3(-1.35f, 0, -viewbob.CurrentKickback + -2)) * Matrix4.CreateRotationX(MathHelper.ToRadians(camera.Pitch)) * Matrix4.CreateRotationY(MathHelper.ToRadians(-camera.Yaw) + MathHelper.Pi) * Matrix4.CreateTranslation(OwnerPlayer.Transform.Position + new Vector3(0, OwnerPlayer.Size.Y / 2f - 1.5f, 0))); } else { return(Matrix4.CreateRotationX(MathHelper.ToRadians(ModelRotation.X + viewbob.CurrentSway.X)) * Matrix4.CreateRotationY(MathHelper.ToRadians(ModelRotation.Y + viewbob.CurrentSway.Y)) * Matrix4.CreateRotationZ(MathHelper.ToRadians(viewbob.CurrentTilt + ModelRotation.Z + viewbob.CurrentSway.Y * 0.5f)) * Matrix4.CreateTranslation(ModelOffset + viewbob.CurrentViewBob + new Vector3(0, 0, -viewbob.CurrentKickback)) * Matrix4.CreateRotationX(MathHelper.ToRadians(camera.Pitch)) * Matrix4.CreateRotationY(MathHelper.ToRadians(-camera.Yaw) + MathHelper.Pi) * Matrix4.CreateTranslation(camera.OffsetPosition)); } }
public BumperView(DrivableVehicle car) { _car = car; _camera = new SimpleCamera(); _camera.FieldOfView = GameConfig.FOV; _camera.FarPlaneDistance = GameConfig.DrawDistance; }
public void SimpleCameraTest() { // Ray cast for screen coordinate 0,0 { var camera = new SimpleCamera(new Tuple4(0.0, 0.0, -4.0, TupleFlavour.Point), 6.0, 600, 800); var ray = camera.GetRay(0, 0); var expectedRay = new Ray( new Tuple4(0.0, 0.0, -4.0, TupleFlavour.Point), Tuple4.Normalize(new Tuple4(-3.0, 3.0, 1.0, TupleFlavour.Vector))); Assert.Equal(expectedRay.origin, ray.origin); Assert.Equal(expectedRay.dir, ray.dir); var t = Tuple4.Add(ray.origin, Tuple4.Scale(ray.dir, 4.35890)); Assert.Equal(new Tuple4(-3.0, 3.0, -3.0, TupleFlavour.Point), t); } // Ray cast for screen coordinate width,height { var camera = new SimpleCamera(new Tuple4(0.0, 0.0, -4.0, TupleFlavour.Point), 6.0, 600, 800); var ray = camera.GetRay(600, 800); var expectedRay = new Ray( new Tuple4(0.0, 0.0, -4.0, TupleFlavour.Point), Tuple4.Normalize(new Tuple4(3.0, -3.0, 1.0, TupleFlavour.Vector))); Assert.Equal(expectedRay.origin, ray.origin); Assert.Equal(expectedRay.dir, ray.dir); } { var camera = new SimpleCamera(new Tuple4(0, 0, -1.0, TupleFlavour.Point), 2.0, 600, 600); var ray = camera.GetRay(0, 0); var t = Tuple4.Add(ray.origin, Tuple4.Scale(ray.dir, 1.73205)); Assert.Equal(new Tuple4(-1.0, 1.0, 0.0, TupleFlavour.Point), t); } }
public MPPlayer(MasterRenderer renderer, World world, SimpleCamera camera, Vector3 position, Team team) : base(renderer, world, camera, position, team) { if (!DashCMD.IsCVarDefined("log_mpplayer")) { DashCMD.SetCVar("log_mpplayer", false); } }
public DropCameraView(DrivableVehicle car) { _car = car; _camera = new SimpleCamera(); _camera.FieldOfView = GameConfig.FOV; _camera.FarPlaneDistance = GameConfig.DrawDistance; PositionCameraAtNode(car.Track.RoadNodes[10]); }
public ClientMPPlayer(MasterRenderer renderer, World world, Camera camera, Vector3 position, Team team) : base(renderer, world, camera, position, team) { this.camera = camera; camfx = new CameraFX(this, camera); // Setup ClientInput Snapshot AOSClient client = AOSClient.Instance; SnapshotNetComponent snc = client.GetComponent <SnapshotNetComponent>(); SnapshotSystem ss = snc.SnapshotSystem; ClientSnapshot = new ClientPlayerSnapshot(ss, client.ServerConnection); Camera.Active.FOV = Camera.Active.DefaultFOV; Camera.Active.FPSMouseSensitivity = Camera.Active.DefaultFPSMouseSensitivity; Camera.Active.ArcBallMouseSensitivity = Camera.Active.DefaultArcBallMouseSensitivity; CreateStarterBackpack(); AudioBuffer hitAudioBuffer = AssetManager.LoadSound("Impacts/hit-player-local.wav"); if (hitAudioBuffer != null) { hitAudioSource = new AudioSource(hitAudioBuffer); hitAudioSource.IsSourceRelative = true; hitAudioSource.Gain = 0.2f; } AudioBuffer flashlightAudioBuffer = AssetManager.LoadSound("Player/flashlight.wav"); if (flashlightAudioBuffer != null) { flashlightAudioSource = new AudioSource(flashlightAudioBuffer); flashlightAudioSource.IsSourceRelative = true; flashlightAudioSource.Gain = 0.2f; } AudioBuffer jumpAudioBuffer = AssetManager.LoadSound("Player/jump.wav"); if (jumpAudioBuffer != null) { jumpAudioSource = new AudioSource(jumpAudioBuffer); jumpAudioSource.IsSourceRelative = true; jumpAudioSource.Gain = 0.2f; } AudioBuffer landAudioBuffer = AssetManager.LoadSound("Player/land.wav"); if (landAudioBuffer != null) { landAudioSource = new AudioSource(landAudioBuffer); landAudioSource.IsSourceRelative = true; landAudioSource.Gain = 0.2f; } walkingAudioSource = new CyclicAudioSource("Player/footstep.wav", 8, 0f); runningAudioSource = new CyclicAudioSource("Player/run.wav", 12, 0f); }
public PlayUI(Data data, Screen parant) : base(data, parant) { StandardFont = ContentExt.Content.Load <SpriteFont>("Font\\Noto"); UISkin = new UiSkinComponent(); UISkin.AddSkin(new MKC_UISkin(UISkin)); Status = new StatusScreen(data, this); Item = new ItemScreen(data, this); UICamera = new SimpleCamera(); }
protected override void Initialize() { SimpleCamera cameraService = new SimpleCamera(this); Components.Add(cameraService); Services.AddService(typeof(ICameraService), cameraService); Components.Add(new ModelComponent(this, "Ship")); Components.Add(new BoundingBoxComponent(this, "Ship")); base.Initialize(); }
public DashboardView(DrivableVehicle car) { _car = car; _camera = new SimpleCamera(); _camera.FieldOfView = GameConfig.FOV; _camera.FarPlaneDistance = GameConfig.DrawDistance; var dashfile = Path.GetFileNameWithoutExtension(car.Descriptor.ModelFile) + "dh.fsh"; var dashDescription = DashboardDescription.Descriptions.Find(a => a.Filename == dashfile); _dashboard = new Dashboard(car, dashDescription); }
private void Awake() { if (instance != null) { Destroy(gameObject); } else { instance = this; } virtualCamera = GetComponent <CinemachineVirtualCamera>(); }
public SelectCarScreen(BaseMenuScreen parent) : base(parent) { _titleFont = GameEngine.ContentManager.Load <SpriteFont>("LucidaConsole"); SimpleCamera cam = GameEngine.Camera as SimpleCamera; cam.DrawDistance = 999999; _inAnimation = new AnimationPlayer(LoadAnimation("chcrcome.fli")); _inAnimation.Play(false); _outAnimation = new AnimationPlayer(LoadAnimation("chcraway.fli")); _effect = new BasicEffect2(); //_effect.LightingEnabled = false; _effect.PreferPerPixelLighting = true; //_effect.TexCoordsMultiplier = 1; _effect.TextureEnabled = true; GameEngine.Camera.Position = new Vector3(-1.5f, 3.5f, 10); GameEngine.Camera.Orientation = new Vector3(0, -0.28f, -1); GameEngine.Camera.Update(); _effect.View = GameEngine.Camera.View; _effect.Projection = GameEngine.Camera.Projection; _opponents = OpponentsFile.Instance.Opponents; if (GameVars.Emulation != EmulationMode.Demo && GameVars.Emulation != EmulationMode.SplatPackDemo) { // If we're not in demo mode, add car files in directory that havent been added to opponent.txt List <string> carFiles = new List <string>(Directory.GetFiles(GameVars.BasePath + "cars")); carFiles.RemoveAll(a => !a.ToUpper().EndsWith(".TXT")); carFiles.Sort(); carFiles.Reverse(); foreach (string file in carFiles) { string filename = Path.GetFileName(file); if (!_opponents.Exists(a => a.FileName.Equals(filename, StringComparison.InvariantCultureIgnoreCase))) { _opponents.Add(new OpponentInfo { FileName = filename, Name = Path.GetFileNameWithoutExtension(filename), StrengthRating = 1 }); } } } foreach (var opponent in _opponents) { _options.Add(new CarModelMenuOption(_effect, opponent)); } }
public ClientMuzzleFlash(MasterRenderer renderer, Player ownerPlayer) { this.renderer = renderer; this.ownerPlayer = ownerPlayer; camera = ownerPlayer.GetCamera(); light = new Light(Vector3.Zero, LightType.Point, 0f, Color.White, new Vector3(1, 0, 0.1f)); light.Visible = false; renderer.Lights.Add(light); flashCube = new DebugCube(Color4.Yellow, 0.7f); flashCube.ApplyNoLighting = true; }
/// <summary> /// Load camera /// </summary> /// <param name="cameraData">All the data needed for the camera to load</param> private void LoadCamera(Tuple <SimpleCamera, string> cameraData) { SimpleCamera camera = cameraData.Item1; string uniqueName = cameraData.Item2; SubscribedCamera subscribedCamera = subscribedCameras.Find(x => x.UniqueName == uniqueName); subscribedCamera.Camera = camera; Grid grid = subscribedCamera.Camera.Content as Grid; Image cameraImage = grid.Children[0] as Image; cameraImage.Name = subscribedCamera.UniqueName + "_image"; }
public void SwitchCamera(bool camera3d) { if (camera3d) { //cam2d.cam.enabled = false; //cam3d.cam.enabled = true; acvtive = cam3d; } else { //cam2d.cam.enabled = true; //cam3d.cam.enabled = false; acvtive = cam2d; } }
public ServerMPPlayer(World world, Vector3 position, Team team) : base(null, world, new SimpleCamera(), position, team) { camera = GetCamera(); playerTransforms = new List <PlayerTransform>(); bulletsToFire = new Queue <NetworkBullet>(); movementAnim = new Vector3Anim(); // Let client's handle movement. // - We don't need to bother with terrain collision, only entity collision. // - Gravity shouldn't be bother with either. CharacterController.CanCollideWithTerrain = false; CharacterController.IsAffectedByGravity = false; CharacterController.OnCollision += CharacterController_OnCollision; CreateStarterBackpack(); }
private void InitNewScene() { _scene = new Scene(); var screen = new raytracer.core.Screen(1024, 768); _film = new MyFilm(screen, NSamples); Camera camera = new SimpleCamera(screen, Transformation.Translation((float)PositionX.Value, (float)PositionY.Value, (float)PositionZ.Value) * Transformation.RotateX((float)(RotationX.Value % 360)) * Transformation.RotateY((float)(RotationY.Value % 360)) * Transformation.RotateZ((float)(RotationZ.Value % 360))); _renderer = new Renderer(_scene, new GridSampler(screen), camera, _film, new WhittedIntegrator()); _scene.Lights.Add(new PointLight(Transformation.Translation(100, 650, -500), SampledSpectrum.White() * 2000000)); _scene.Lights.Add(new PointLight(Transformation.Translation(0, 0, -1000), SampledSpectrum.Random() * 200000)); SimpleObjParser(_scene, _file); }
/// <summary> /// This function will load the whole grid from the file saved on disk /// </summary> /// <param name="gridName">Name of the grid that should be loaded</param> void reloadGrid(string gridName) { currentGrid = gridName; if (!File.Exists(@"layouts/" + gridName + ".xaml")) { controlCanvas.Children.Clear(); return; } StreamReader sR = new StreamReader(@"layouts/" + gridName + ".xaml"); string text = sR.ReadToEnd(); sR.Close(); StringReader stringReader = new StringReader(text); XmlReader xmlReader = XmlReader.Create(stringReader); Grid grid = (Grid)XamlReader.Load(xmlReader); controlCanvas.Children.Clear(); foreach (FrameworkElement child in grid.Children) { if (child.GetType().ToString() == "HomeControler.Controls.SimpleLabel") { SimpleLabel label = CloneFrameworkElement(child) as SimpleLabel; LoadLabel(label); } else if (child.GetType().ToString() == "HomeControler.Controls.SimpleSwitch") { SimpleSwitch simpleSwitch = CloneFrameworkElement(child) as SimpleSwitch; LoadSwitch(simpleSwitch); } else if (child.GetType().ToString() == "HomeControler.Controls.SimpleCamera") { SimpleCamera simpleCamera = CloneFrameworkElement(child) as SimpleCamera; LoadCamera(simpleCamera); } } Messenger.Default.Send("reload", "getSubscribedDevices"); Messenger.Default.Send("subscribe", "subscribeToTopics"); }
public ReplicatedPlayer(MasterRenderer renderer, World world, SimpleCamera camera, Vector3 position, Team team) : base(renderer, world, camera, position, team) { this.camera = camera; interpPos = new Vector3Anim(); interpPos.SnapTo(position); yawAnim = new FloatAnim(); pitchAnim = new FloatAnim(); // This is fully server controlled ItemManager.DontUpdateItems = true; ItemManager.IsReplicated = true; CharacterController.IsEnabled = false; CreateStarterBackpack(); AudioBuffer jumpAudioBuffer = AssetManager.LoadSound("Player/jump.wav"); if (jumpAudioBuffer != null) { jumpAudioSource = new AudioSource(jumpAudioBuffer); jumpAudioSource.Gain = 0.2f; jumpAudioSource.MaxDistance = 100f; } AudioBuffer landAudioBuffer = AssetManager.LoadSound("Player/land.wav"); if (landAudioBuffer != null) { landAudioSource = new AudioSource(landAudioBuffer); landAudioSource.Gain = 0.2f; landAudioSource.MaxDistance = 120f; } walkingAudioSource = new CyclicAudioSource("Player/footstep.wav", 1, 0f, relative: false, maxDistance: 100f); runningAudioSource = new CyclicAudioSource("Player/run.wav", 1, 0f, relative: false, maxDistance: 200f); }
/// <summary> /// This function will load camera object when the app is opened with already configured layout /// </summary> /// <param name="simpleCamera">Camera element that should be loaded</param> void LoadCamera(SimpleCamera simpleCamera) { SimpleCamera cameraControl = new SimpleCamera(); cameraControl.Margin = new Thickness(simpleCamera.Margin.Left, simpleCamera.Margin.Top, simpleCamera.Margin.Right, simpleCamera.Margin.Bottom); cameraControl.Name = simpleCamera.Name; Tuple <SimpleCamera, string> cameraData = new Tuple <SimpleCamera, string>(cameraControl, cameraControl.Name); Messenger.Default.Send(cameraData, "loadCamera"); cameraControl.MouseDoubleClick += object_MouseDoubleClick; cameraControl.VerticalAlignment = VerticalAlignment.Center; cameraControl.HorizontalAlignment = HorizontalAlignment.Center; controlCanvas.Children.Add(cameraControl); }
/// <summary> /// This function will take care of adding the new camera element /// </summary> /// <param name="sender"></param> private void AddCamera(object sender) { SimpleCamera simpleCamera = new SimpleCamera(); Random RNG = new Random(); int length = 16; var rString = ""; for (var i = 0; i < length; i++) { rString += ((char)(RNG.Next(1, 26) + 64)).ToString().ToLower(); } SubscribedCamera subscribedCamera = new SubscribedCamera { Id = Guid.NewGuid(), UniqueName = rString, Camera = simpleCamera, Topic = "" }; simpleCamera.Name = subscribedCamera.UniqueName; Grid grid = subscribedCamera.Camera.Content as Grid; Image camera = grid.Children[0] as Image; camera.Name = subscribedCamera.UniqueName + "_image"; subscribedCameras.Add(subscribedCamera); simpleCamera.MouseDoubleClick += object_MouseDoubleClick; simpleCamera.VerticalAlignment = VerticalAlignment.Center; simpleCamera.HorizontalAlignment = HorizontalAlignment.Center; simpleCamera.Margin = new Thickness(0, 0, 0, 0); controlCanvas.Children.Add(simpleCamera); Messenger.Default.Send(subscribedCamera, "cameraAdd"); }
protected override void Draw() { if (Holder == null) { renderer.WorldMatrix = Transform.Matrix; } else { SimpleCamera holderCam = Holder.GetCamera(); Matrix4 matrix = Matrix4.CreateTranslation( -PhysicsBody.Size.X / 2f + 0.25f, 0, -(Holder.Size.Z / 2f + PhysicsBody.Size.Z - 0.25f)) * Matrix4.CreateRotationY(MathHelper.ToRadians(-holderCam.Yaw) + MathHelper.Pi) * Matrix4.CreateTranslation(Holder.Transform.Position); renderer.WorldMatrix = matrix; } base.Draw(); }
public CockpitView(Vehicle vehicle, string cockpitFile) { _vehicle = vehicle; if (GameVars.Emulation == EmulationMode.Demo) { cockpitFile = Path.GetDirectoryName(cockpitFile) + "\\blkeagle.txt"; } else if (GameVars.Emulation == EmulationMode.SplatPackDemo) { cockpitFile = Path.GetDirectoryName(cockpitFile) + "\\neweagle.txt"; } else if (!File.Exists(cockpitFile)) { cockpitFile = Path.GetDirectoryName(cockpitFile) + "\\blkeagle.txt"; } if (File.Exists(cockpitFile)) { _cockpitFile = new CockpitFile(cockpitFile); ActFile actFile = new ActFile(vehicle.Config.BonnetActorFile); if (!actFile.Exists) { actFile = new ActFile("EBONNET.ACT"); } _actors = actFile.Hierarchy; DatFile modelsFile = new DatFile(_actors.Root.ModelName); _actors.AttachModels(modelsFile.Models); _actors.ResolveTransforms(false, null); //move head back _vehicle.Config.DriverHeadPosition.Z += 0.11f; } _camera = new SimpleCamera(); _camera.FieldOfView = MathHelper.ToRadians(55.55f); }
public static bool SelectUiSprite(SimpleCamera camera, Sprite sprite) { return(InputExt.OnePressed(MouseButtons.Left) && sprite.Bounds.Contains(camera.ScreenToWorldMouse())); }
/// <inheritdoc /> protected override void LoadContent() { Random = new Random(5); SpriteFont = Game.Content.Load <SpriteFont>(ContentFolderSpriteFonts + "Arial"); //The buffer pool is a source of raw memory blobs for the engine to use. BufferPool = new BufferPool(); Radii = new List <float>(); Camera = new SimpleCamera(GraphicsDevice.Viewport.AspectRatio, new Vector3(40, 60, 150), 55, 0.4f); var boxTexture = Game.Content.Load <Texture2D>(ContentFolderTextures + "wood/caja-madera-3"); Box = new BoxPrimitive(GraphicsDevice, Vector3.One * 10, boxTexture); Sphere = new SpherePrimitive(GraphicsDevice); SphereHandles = new List <BodyHandle>(); BoxHandles = new List <BodyHandle>(); var targetThreadCount = Math.Max(1, Environment.ProcessorCount > 4 ? Environment.ProcessorCount - 2 : Environment.ProcessorCount - 1); ThreadDispatcher = new SimpleThreadDispatcher(targetThreadCount); // This are meshes/model/primitives collections to render // The PositionFirstTimestepper is the simplest timestepping mode, but since it integrates velocity into position at the start of the frame, directly modified velocities outside of the timestep // will be integrated before collision detection or the solver has a chance to intervene. That's fine in this demo. Other built-in options include the PositionLastTimestepper and the SubsteppingTimestepper. // Note that the timestepper also has callbacks that you can use for executing logic between processing stages, like BeforeCollisionDetection. Simulation = Simulation.Create(BufferPool, new NarrowPhaseCallbacks(), new PoseIntegratorCallbacks(new NumericVector3(0, -100, 0)), new PositionFirstTimestepper()); // Creates a floor var floorTexture = Game.Content.Load <Texture2D>(ContentFolderTextures + "floor/adoquin-2"); //Floor = new QuadPrimitive(GraphicsDevice); TilingEffect = Game.Content.Load <Effect>(ContentFolderEffects + "TextureTiling"); TilingEffect.Parameters["Texture"].SetValue(floorTexture); TilingEffect.Parameters["Tiling"].SetValue(Vector2.One * 50f); FloorWorld = Matrix.CreateScale(400f) * Matrix.CreateTranslation(new Vector3(75, 0, -150)); Simulation.Statics.Add(new StaticDescription(new NumericVector3(0, -0.5f, 0), new CollidableDescription(Simulation.Shapes.Add(new Box(2000, 1, 2000)), 0.1f))); BoxesWorld = new List <Matrix>(); SpheresWorld = new List <Matrix>(); // Single Box var radius = 10; for (var j = 0; j < 5; j++) { for (var i = 0; i < 20; i++) { var boxShape = new Box(radius, radius, radius); boxShape.ComputeInertia(0.4f, out var boxInertia); var boxIndex = Simulation.Shapes.Add(boxShape); var position = new NumericVector3(-30 + i * 10 + 1, j * 10 + 1, -40); var bodyDescription = BodyDescription.CreateDynamic(position, boxInertia, new CollidableDescription(boxIndex, 0.1f), new BodyActivityDescription(0.01f)); var bodyHandle = Simulation.Bodies.Add(bodyDescription); BoxHandles.Add(bodyHandle); } } base.LoadContent(); }
public ClientPlayer(MasterRenderer renderer, World world, SimpleCamera camera, Vector3 position, Team team) : base(renderer, world, camera, position, team) { }
private void Start() { _simpleCamera = Camera.main.GetComponent <SimpleCamera>(); }
/// <inheritdoc /> public override void Initialize() { Camera = new SimpleCamera(GraphicsDevice.Viewport.AspectRatio, Vector3.UnitZ * 55, 15, 0.5f); base.Initialize(); }
public LineBatch() { camera = null; this.position = Vector3.Zero; this.rotation = Matrix.Identity; }