public MelonLauncher(ItemManager itemManager, MasterRenderer renderer) : base(renderer, itemManager, ItemType.MelonLauncher) { ModelOffset = new Vector3(-3.15f, -4f, 0.5f); aimModelOffset = new Vector3(-0.75f, -2.35f, -6f); ThirdpersonScale = 0.7f; fovAnim = new FloatAnim(); modelAnim = new Vector3Anim(); LoadModel("Models/melon-launcher.aosm"); if (!GlobalNetwork.IsServer) { if (!itemManager.IsReplicated) { AudioBuffer throwAudioBuffer = AssetManager.LoadSound("Weapons/Grenade/throw.wav"); if (throwAudioBuffer != null) { throwAudioSource = new AudioSource(throwAudioBuffer); throwAudioSource.IsSourceRelative = true; throwAudioSource.Pitch = 1.5f; throwAudioSource.Gain = 0.2f; } } } }
public static void CleanUp() { shutdown = true; fixedthread.Join(); MasterRenderer.CleanUp(); Simulation.CleanUp(); }
public EntityRenderer(MasterRenderer master) : base(master) { entityBatch = new Batch <VoxelObject, BatchedEntity>(); rawBatch = new Batch <VoxelObject, Matrix4>(); rawBatchFront = new Batch <VoxelObject, Matrix4>(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // TODO: use this.Content to load your game content here mRenderTarget = new RenderTarget(mGraphics.GraphicsDevice, 1920, 1080, 2048); mMasterRenderer = new MasterRenderer(mGraphics.GraphicsDevice, Content); mTerrain = new Terrain(Content, "heightmap", "shitty-grass", mGraphics.GraphicsDevice); mScene.Add(mTerrain); mTreeModel = Content.Load <Model>("tree"); mTreeMesh = new Mesh(mTreeModel); Random random = new Random(); for (uint i = 0; i < 2000; i++) // number of trees { var randomNumberX = (float)random.NextDouble(); var randomNumberZ = (float)random.NextDouble(); var location = new Vector3(2.0f * randomNumberX - 1.0f, 0.0f, 2.0f * randomNumberZ - 1.0f) * 125.0f; location.Y = mTerrain.GetHeight(location); // so every tree is on right height var actor = new Actor(mTreeMesh); actor.mModelMatrix = Matrix.CreateTranslation(location); mScene.Add(actor); } }
/// <summary> /// Closes the pipe and the MasterRenderer. /// </summary> /// <param name="e"></param> protected override void OnClosing(CancelEventArgs e) { IsClosing = true; MasterRenderer.Dispose(); controller.Dispose(); }
public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight) { var graphicsDevice = deviceManager.GraphicsDevice; // Create a new content manager so we can unload all its content afterwards mContentManager = new ContentManager(contentManager.ServiceProvider, contentManager.RootDirectory); mLevel = new Level(mContentManager, SoundManager, graphicsDevice, true); mRenderTarget = new RenderTarget(graphicsDevice, Options.ResolutionWidth, Options.ResolutionHeight, Options.ShadowResolution); mMasterRenderer = new MasterRenderer(graphicsDevice, mContentManager) { PrePass = false, DebugMode = false }; mCamera = new Camera() { mFarPlane = Options.ViewingDistance, mLocation = { Y = 20.0f } }; mCameraHandler = new CameraHandler(mCamera, 40.0f, 2.0f, .3f); mCamera.UpdatePerspective(); mCamera.mLocation = new Vector3(0.0f, 20.0f, -10.0f); mSelectMode = true; }
public ClientWorld(MasterRenderer renderer) { Renderer = renderer; debugRenderer = Renderer.GetRenderer3D <DebugRenderer>(); entRenderer = Renderer.GetRenderer3D <EntityRenderer>(); }
public override void Render(MasterRenderer renderer) { RenderableChunks = 0; CulledChunks = 0; int unfinished = 0; foreach (Chunk chunk in Chunks.Values) { if (chunk.State != ChunkState.Renderable) { unfinished++; } if ((chunk.State == ChunkState.Renderable || chunk.State > ChunkState.Unshaped) && !chunk.IsEmpty && CullingFrustum.Intersects(chunk.BoundingBox)) { RenderableChunks++; chunk.Culled = false; } else { CulledChunks++; chunk.Culled = true; } chunkRenderer.Batch(chunk); } UnfinishedChunks = unfinished; }
/// <summary> /// Signals that the window is now loaded, which means we can load our graphics now. /// </summary> protected override void OnLoad() { base.OnLoad(); MasterRenderer.Load(); if (Settings.UseSystemUIScaling) { if (TryGetCurrentMonitorDpi(out float hdpi, out _)) { Settings.UIScaling = hdpi / 100; } else { Log.WriteInfo("Failed to fetch system dpi scaling."); } } controller = new ImGuiController(ClientSize.X, ClientSize.Y); controller.SetScale(Settings.UIScaling); window = new ImGuiWindow(this, controller); var minimum = ClientRectangle.Min; ClientRectangle = new Box2i(minimum.X, minimum.Y, Settings.GraphWidth + minimum.X, Settings.GraphHeight + minimum.Y); IsLoaded = true; }
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); }
public IconRenderer() { renderer = MasterRenderer.Instance; sb = renderer.Sprites.SpriteBatch; IsDrawable = true; }
public virtual void Render() { if (!Visible) { return; } if (MatrixChanged) { var matrix = Matrix4.CreateTranslation(Position.X, Position.Y, Position.Z); if (Rotation != Vector3.Zero) { var r1 = Matrix4.CreateRotationX(Rotation.X); var r2 = Matrix4.CreateRotationY(Rotation.Y); var r3 = Matrix4.CreateRotationZ(Rotation.Z); matrix = r1 * r2 * r3 * matrix; } if (Scale != Vector3.Zero) { var s1 = Matrix4.CreateScale(Scale); matrix = s1 * matrix; } for (int i = 0; i < vertices.Length; i++) { calculated[i] = vertices[i].Apply(matrix, Color); } MatrixChanged = false; } MasterRenderer.AddToBatch(calculated); }
/// <summary> /// Render frame, which renders the whole window. /// </summary> protected override void OnRenderFrame(FrameEventArgs args) { watch.Start(); if (Camera.Changed) { cursorLocation = getCursorLocation(); } base.OnRenderFrame(args); MasterRenderer.RenderFrame(); window.ShowWindow(lastms, cursorLocation); // Without UI, since it isn't rendered yet if (screenshot && !Settings.ScreenshotUI) { takeScreenshot(); } controller.Render(); // With UI, since it is rendered now if (screenshot && Settings.ScreenshotUI) { takeScreenshot(); } SwapBuffers(); lastms = watch.ElapsedMilliseconds; watch.Reset(); }
public EditorScreen(MainWindow window, MasterRenderer renderer) { this.Window = window; this.renderer = renderer; this.entReneder = renderer.GetRenderer3D <EntityRenderer>(); UI = new EditorUI(renderer, this); debug = new DashCMDScreen("modeldebug", "", true, (s) => { s.WriteLine("Mouse POS {0} {1}", Input.ClampedCursorX, Input.ClampedCursorY); s.WriteLine("Camera POS {0}", Camera.Active.Position); s.WriteLine("VoxelEditorObject POS {0}", (Model != null ? Model.CenterPosition : Vector3.Zero)); s.WriteLine(""); s.WriteLine("Current File {0}", CurrentFile); s.WriteLine("Fog: {0}; Enabled? {1}", renderer.GFXSettings.FogQuality, renderer.FogEnabled); s.WriteLine("FXAA: {0}", renderer.GFXSettings.ApplyFXAA); s.WriteLine("Shadows: {0}", renderer.GFXSettings.RenderShadows); s.WriteLine("PCF Samples: {0}", renderer.GFXSettings.ShadowPCFSamples); s.WriteLine("Wireframe: {0}", renderer.GlobalWireframe); }) { SleepTime = 40, }; DashCMD.AddScreen(debug); DashCMD.ExecuteCommand("screen modeldebug"); Camera.Active.Speeds[0] = .5f; LoadNewModel(); }
public EditorWorld(EditorScreen screen) { this.screen = screen; terrainPhys = new TerrainPhysicsExtension(); renderer = MasterRenderer.Instance; debugRenderer = renderer.GetRenderer3D <DebugRenderer>(); }
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 Gun(ItemManager itemManager, MasterRenderer renderer) : base(renderer, itemManager, ItemType.Gun) { CurrentMag = GunConfig.MagazineSize; StoredAmmo = GunConfig.MagazineSize * GunConfig.MaxStoredMags; if (GlobalNetwork.IsClient && GlobalNetwork.IsConnected) { ServerMag = (ushort)CurrentMag; ServerStoredAmmo = (ushort)StoredAmmo; } fovAnim = new FloatAnim(); modelAnim = new Vector3Anim(); muzzleFlash = itemManager.GetMuzzleFlash(); if (!GlobalNetwork.IsServer) { if (itemManager.IsReplicated) { if (GunConfig.PrimaryFireAudio?.ReplicatedFilepath != null) { fireAudioSource = LoadAudioFromConfig(GunConfig.PrimaryFireAudio, replicated: true, far: false); } if (GunConfig.PrimaryFireAudio?.FarFilepath != null) { fireFarAudioSource = LoadAudioFromConfig(GunConfig.PrimaryFireAudio, replicated: true, far: true); } if (GunConfig.ReloadAudio?.ReplicatedFilepath != null) { reloadAudioSource = LoadAudioFromConfig(GunConfig.ReloadAudio, replicated: true); } } else { if (GunConfig.PrimaryFireAudio?.LocalFilepath != null) { fireAudioSource = LoadAudioFromConfig(GunConfig.PrimaryFireAudio); } if (GunConfig.ReloadAudio?.LocalFilepath != null) { reloadAudioSource = LoadAudioFromConfig(GunConfig.ReloadAudio); } AudioBuffer dryFireBuffer = AssetManager.LoadSound("Weapons/dry-fire.wav"); if (dryFireBuffer != null) { dryFireAudioSource = new AudioSource(dryFireBuffer); dryFireAudioSource.IsSourceRelative = true; dryFireAudioSource.Gain = 0.5f; } } } }
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 SMG(ItemManager itemManager, MasterRenderer renderer) : base(itemManager, renderer) { ModelOffset = new Vector3(-3.15f, -4.35f, -0.5f); AimModelOffset = new Vector3(-0.495f, -4.6f, -0.5f); ThirdpersonScale = 0.7f; MuzzleFlashOffset = new Vector3(0.5f, 3, 10.75f); LoadModel("Models/smg.aosm"); }
public Rifle(ItemManager itemManager, MasterRenderer renderer) : base(itemManager, renderer) { ModelOffset = new Vector3(-3.15f, -3.6f, -0.5f); AimModelOffset = new Vector3(-0.495f, -3.1f, -0.5f); ThirdpersonScale = 0.7f; MuzzleFlashOffset = new Vector3(0.5f, 2, 14); LoadModel("Models/rifle.aosm"); }
public Shotgun(ItemManager itemManager, MasterRenderer renderer) : base(itemManager, renderer) { ModelOffset = new Vector3(-3.15f, -3.6f, -0.5f); AimModelOffset = new Vector3(-0.495f, -3.8f, -0.5f); ThirdpersonScale = 0.7f; MuzzleFlashOffset = new Vector3(0.5f, 2.5f, 14.5f); LoadModel("Models/shotgun.aosm"); }
public StaticGui(MainWindow window, MasterRenderer renderer) { this.window = window; this.renderer = renderer; gsys = renderer.Sprites.GUISystem; area = new GUIArea(gsys); renderer.Sprites.Add(area); BMPFont smallFont = AssetManager.LoadFont("arial-bold-12"); BMPFont normalFont = AssetManager.LoadFont("arial-bold-14"); BMPFont bigFont = AssetManager.LoadFont("arial-bold-20"); BMPFont tinyFont = AssetManager.LoadFont("arial-bold-10"); GUITheme theme = AssetManager.CreateDefaultGameTheme(); theme.SetField("SmallFont", smallFont); theme.SetField("Font", normalFont); theme.SetField("TinyFont", tinyFont); controls = new ControlsWindow(gsys, theme); controls.ZIndex = 200; // Overlay fpsLabel = new GUILabel(UDim2.Zero, UDim2.Zero, "FPS: --", TextAlign.TopLeft, theme); timeLabel = new GUILabel(new UDim2(1f, 0, 0, 0), UDim2.Zero, "Time: --", TextAlign.TopRight, theme); versionLabel = new GUILabel(new UDim2(0, 0, 1f, 0), UDim2.Zero, GameVersion.Current.ToString(), TextAlign.BottomLeft, theme); fpsLabel.Font = smallFont; timeLabel.Font = smallFont; versionLabel.Font = bigFont; if (screenshots == null) { string[] mainMenuFiles = Directory.GetFiles("Content/Textures/MainMenu"); screenshots = new List <Texture>(); foreach (string file in mainMenuFiles) { // Skip thumbs.db if (file.EndsWith(".db")) { continue; } try { screenshots.Add(GLoader.LoadTexture(file, TextureMinFilter.Linear, TextureMagFilter.Linear, true)); } catch (Exception e) { DashCMD.WriteError("Failed to load main menu background '{1}'. \n{0}", e, file); } } } background = new GUIFrame(UDim2.Zero, new UDim2(1f, 0, 1f, 0), Image.Blank); background.ZIndex = -100; area.AddTopLevel(background, fpsLabel, timeLabel, versionLabel); gsys.Add(controls); }
public virtual void PushToBatchRenderer() { if (!Visible) { return; } MasterRenderer.AddToBatch(vertices); }
public DebugRenderer(MasterRenderer master) : base(master) { batchedAABBs = new HashSet <AxisAlignedBoundingBox>(); batchedRays = new HashSet <RenderableRay>(); bulletImpacts = new List <Impact>(); playerRollbacks = new List <Impact>(); aabbDebugBox = new DebugCube(Color4.White, 1); }
public CombatScreen(Game game) { this.game = game; dataMaster = new DataMaster(game); DataMaster = dataMaster; unitHandler = new UnitHandler(game, this); interfaceHandler = new InterfaceHandler(this); masterRenderer = new MasterRenderer(dataMaster); }
public EditorScreen(MainWindow window, MasterRenderer renderer) { this.Window = window; this.renderer = renderer; World = new EditorWorld(this); UI = new EditorUI(renderer, this); WorldEditor = new WorldEditor(this); //LoadWorld("Content/Worlds/rockyc.aosw"); }
public VoxelTranslationHandles(MasterRenderer renderer) { xAxisVo = new VoxelTranslationHandle(6, cubeSize, Color.Blue); xAxisVo.MeshRotation = new Vector3(0, 0, -90); yAxisVo = new VoxelTranslationHandle(6, cubeSize, Color.Red); zAxisVo = new VoxelTranslationHandle(6, cubeSize, Color.Green); zAxisVo.MeshRotation = new Vector3(90, 0, 0); entRenderer = renderer.GetRenderer3D <EntityRenderer>(); debugRenderer = renderer.GetRenderer3D <DebugRenderer>(); }
protected override void OnLoad(EventArgs e) { EssentialSetup(); MasterRenderer.Initialize(); Renderer.Initiliaze(MainCamera); GL.Enable(EnableCap.Texture2D); GL.Ortho(0, Width, Height, 0, 0, 1); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); OnGameInitialized(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // TODO: use this.Content to load your game content here mRenderTarget = new RenderTarget(mGraphics.GraphicsDevice, 1920, 1080, 4096); mMasterRenderer = new MasterRenderer(mGraphics.GraphicsDevice, Content); mTerrain = new Terrain(Content, "heightmap", "shitty-grass", mGraphics.GraphicsDevice); var terrainActor = new Actor(mTerrain.mMesh); mScene.Add(terrainActor); }
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; }
protected override void OnRenderFrame(FrameEventArgs e) { FrameRate.Update(); MasterRenderer.ClearScreen(); GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.Blend); Renderer.Render(SunLight, MainCamera); OnGameRendered(new GameRenderedEventArgs((float)e.Time)); SwapBuffers(); }