public void Construct(Vector3 center) { this._position = center; this._rotation = (float)Globals.random.NextDouble(); this.mesh = new Mesh(); this.mesh.Model = AssetLoader.mdl_weapon_depot; this.mesh.Transform = Matrix.CreateTranslation(_position); this.gunindex = -1; this.gunmesh = null; this.gunmeshReceipt = null; Globals.gameInstance.sceneGraph.Setup(this.mesh); Globals.gameInstance.sceneGraph.Add(this.mesh); this.light = new Light(); this.light.LightType = Light.Type.Point; this.light.Radius = 3; this.light.Intensity = 0.4f; this.light.Color = Color.White; this.light.Transform = Matrix.CreateTranslation(this._position + Vector3.Up * 2); this.light.Enabled = false; Globals.gameInstance.sceneGraph.Setup(this.light); Globals.gameInstance.sceneGraph.Add(this.light); }
public DropFragment() { this.mesh = new Mesh(); this.mesh.Model = AssetLoader.mdl_dropfragment; this.mesh.SetInstancingEnabled(true); this.mesh.SetCastShadows(false); }
public void SetGun(int index) { this.gunindex = index; this.light.Enabled = true; this.gunmesh = new Mesh(); this.gunmesh.Model = GetModelForIndex(gunindex); this.gunmesh.Transform = gunTransforms[gunindex] * Matrix.CreateTranslation(_position + Vector3.Up); Globals.gameInstance.sceneGraph.Setup(this.gunmesh); this.gunmeshReceipt = Globals.gameInstance.sceneGraph.Add(this.gunmesh); }
public BaseGun() { mesh = null; receipt = null; holdTransform = Matrix.Identity; emmitterVector = Vector3.Zero; emmitterPosition = Vector3.Zero; lastShot = DateTime.Now; coolDown = TimeSpan.Zero; animationCoolDown = TimeSpan.Zero; }
public static void BuildSection(int id, Vector3 corigin, int index) { System.Diagnostics.Debug.WriteLine("Building Section @ " + corigin.ToString()); Mesh mesh = new Mesh(); mesh.Model = AssetLoader.mdl_section[id]; mesh.Transform = Matrix.CreateTranslation(corigin + new Vector3(16, 0, 16)); Globals.gameInstance.sceneGraph.Setup(mesh); Globals.gameInstance.sceneGraph.Add(mesh); System.Diagnostics.Debug.WriteLine("Spawning Entities"); SpawnEntities(id, corigin, index); }
public Teleporter(Vector3 pos) { this._position = pos; this.padmesh = new Mesh(); this.padmesh.Model = AssetLoader.mdl_teleport_pad; this.padmesh.Transform = Matrix.CreateTranslation(pos + new Vector3(0,0.15f,0)); this.padmesh.SetCastShadows(false); Globals.gameInstance.sceneGraph.Setup(this.padmesh); Globals.gameInstance.sceneGraph.Add(this.padmesh); this.beamMesh = new Mesh(); this.beamMesh.Model = AssetLoader.mdl_teleport_beam; this.beamMesh.Transform = Matrix.CreateScale(1,1,1) * Matrix.CreateTranslation(pos); Globals.gameInstance.sceneGraph.Setup(this.beamMesh); Globals.gameInstance.sceneGraph.Add(this.beamMesh); this.inProgress = false; this.progress = 0; }
public Door(Vector3 position) { this.position = position; doorBaseMesh = new Mesh(); doorBaseMesh.Model = AssetLoader.mdl_doorBase; doorBaseMesh.Transform = FLIP90Y * Matrix.CreateTranslation(position); doorLeftMesh = new Mesh(); doorLeftMesh.Model = AssetLoader.mdl_doorPanel; doorLeftMesh.Transform = FLIP90Y * Matrix.CreateTranslation(position); doorRightMesh = new Mesh(); doorRightMesh.Model = AssetLoader.mdl_doorPanel; doorRightMesh.Transform = FLIP180X * FLIP90Y * Matrix.CreateTranslation(position + new Vector3(0, 2.5f, 0)); Globals.gameInstance.sceneGraph.Setup(doorBaseMesh); Globals.gameInstance.sceneGraph.Add(doorBaseMesh); Globals.gameInstance.sceneGraph.Setup(doorLeftMesh); Globals.gameInstance.sceneGraph.Add(doorLeftMesh); Globals.gameInstance.sceneGraph.Setup(doorRightMesh); Globals.gameInstance.sceneGraph.Add(doorRightMesh); lightLeft = new Light(); lightLeft.LightType = Light.Type.Point; lightLeft.Color = Color.Red; lightLeft.Radius = 2; lightLeft.Transform = Matrix.CreateTranslation(position + new Vector3(-0.6f, 1.5f, -1.4f)); lightRight = new Light(); lightRight.LightType = Light.Type.Point; lightRight.Color = Color.Red; lightRight.Radius = 2; lightRight.Transform = Matrix.CreateTranslation(position + new Vector3(-0.6f, 1.5f, 1.4f)); Globals.gameInstance.sceneGraph.Add(lightRight); Globals.gameInstance.sceneGraph.Add(lightLeft); state = DoorState.CLOSED; openPercent = MINOPEN; UpdatePanelPositions(); }
//construct public MenuBackground() { viewport = Globals.graphics.GraphicsDevice.Viewport; // Create the renderer, this renderer binds to the graphics device and with the given width and height, is used to // draw everything on each frame renderer = new Renderer(Globals.graphics.GraphicsDevice, Globals.content, viewport.Width, viewport.Height); // The light and mesh container is used to store mesh and light obejcts. This is just for RENDERING. Not for DRAWING lightAndMeshContainer = new SimpleSceneGraph(); lightAndMeshContainer.SetSubMeshDelegate(delegate(Mesh.SubMesh subMesh) { renderer.SetupSubMesh(subMesh); subMesh.RenderEffect.AmbientParameter.SetValue(Vector4.Zero); }); lightAndMeshContainer.SetLightDelegate(delegate(Light l) { }); camera = new Camera(); camera.Aspect = viewport.AspectRatio; camera.NearClip = 0.1f; camera.FarClip = 1000; camera.Viewport = viewport; camera.Transform = Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(170),-0.3f,0) * Matrix.CreateTranslation(2,5f,-4); Mesh m = new Mesh(); m.Model = AssetLoader.mdl_menuscene; m.Transform = Matrix.Identity; lightAndMeshContainer.AddMesh(m); Light mainlight = new Light(); mainlight.LightType = Light.Type.Spot; mainlight.Color = Color.AntiqueWhite; mainlight.Transform = Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(170),-0.7f,0) * Matrix.CreateTranslation(0, 5f, -4); mainlight.SpotAngle = 50; mainlight.SpotExponent = 1; mainlight.Radius = 13; mainlight.Intensity = 2f; lightAndMeshContainer.AddLight(mainlight); }
public void AddInstancedSubMesh(Mesh.SubMesh subMesh) { GetInstanceGroupForSubMesh(subMesh).AddSubMesh(subMesh); }
public void AddSubMesh(Mesh.SubMesh subMesh) { _subMeshes.Add(subMesh); }
/// <summary> /// Call this for every mesh you create, so it sets the GBuffer textures only once /// </summary> /// <param name="mesh"></param> public void SetupSubMesh(Mesh.SubMesh subMesh) { subMesh.RenderEffect.SetLightBuffer(_lightBuffer, _lightSpecularBuffer); subMesh.RenderEffect.SetLightBufferPixelSize(new Vector2(0.5f / _lightBuffer.Width, 0.5f / _lightBuffer.Height)); subMesh.RenderEffect.SetDepthBuffer(_depthBuffer); subMesh.RenderEffect.SetNormalBuffer(_normalBuffer); }
public SubMesh(Mesh parent) { _parent = parent; }
public static Light SpawnOverheadLight(Vector3 position) { Mesh m = new Mesh(); m.Model = AssetLoader.mdl_ceilinglight; m.Transform = Matrix.CreateTranslation(position + Vector3.Up * 4); Globals.gameInstance.sceneGraph.Add(m); Light l = new Light(); l.LightType = Light.Type.Point; l.Radius = 7; l.Intensity = 0.4f; l.Enabled = false; l.Transform = Matrix.CreateTranslation(position + Vector3.Up * 4); Globals.gameInstance.sceneGraph.Add(l); return l; }
public static void SpawnFilingCabinet(Vector3 center, Color[] data, int x, int y) { Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z, true); Color u = data[y * 96 + x+1]; Color d = data[(y + 2) * 96 + x+1]; Color l = data[(y+1) * 96 + x]; Color r = data[(y+1) * 96 + x + 2]; float angle_d = 0; if (u != Color.Red) { angle_d = 0; } else if (d != Color.Red) { angle_d = 180; } else if (l != Color.Red) { angle_d = 90; } else if (r != Color.Red) { angle_d = -90; } Mesh m = new Mesh(); m.Model = AssetLoader.mdl_filingcabinet; m.SetInstancingEnabled(true); m.Transform = Matrix.CreateRotationY(MathHelper.ToRadians(angle_d)) * Matrix.CreateTranslation(center); Globals.gameInstance.sceneGraph.Setup(m); Globals.gameInstance.sceneGraph.Add(m); }
public void SetModel(Model m) { mesh = new Mesh(); mesh.Model = m; }
private InstancingGroup GetInstanceGroupForSubMesh(Mesh.SubMesh subMesh) { for (int index = 0; index < _instancingGroups.Count; index++) { InstancingGroup instancingGroup = _instancingGroups[index]; ModelMeshPart firstMeshPart = instancingGroup.GetModelMeshPart(); if (firstMeshPart == subMesh._meshPart || firstMeshPart == null) return instancingGroup; } InstancingGroup newGroup = new InstancingGroup(); _instancingGroups.Add(newGroup); return newGroup; }
public static void SpawnEntities(int id, Vector3 corigin, int index) { CampaignSection csection = new CampaignSection(index, corigin); Texture2D t = AssetLoader.tex_section_ent[id]; Color[] colours = new Color[96*96]; t.GetData<Color>(colours); for (int y = 0; y < 32; y++) { for (int x = 0; x < 32; x++) { int pixelX = x * 3; int pixelY = y * 3; int pixelIndex = pixelY * 96 + pixelX; Color c = colours[pixelIndex]; Vector3 center = corigin + new Vector3(0.5f + x, 0, 0.5f + y); if (c == Color.Black || c == Color.Blue) { Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z, true); } else if (c == Color.Yellow) { csection.AddOverheadLight(SpawnOverheadLight(center)); } else if (c == Color.Red) { SpawnFilingCabinet(center, colours, pixelX, pixelY); } else if (c == PureGreen) { int pi2 = (pixelY+1) * 96 + pixelX+1; Color cc = colours[pi2]; if (cc == PureGreen) { csection.SetDoor(new Door(center)); } } else if (c == Color.DarkMagenta) { int pi2 = (pixelY + 2) * 96 + pixelX + 1; if (colours[pi2] != Color.DarkMagenta) { Mesh m = new Mesh(); m.Model = AssetLoader.mdl_desk; m.SetInstancingEnabled(true); m.Transform = Matrix.CreateRotationY(MathHelper.ToRadians(0)) * Matrix.CreateTranslation(center + new Vector3(0,0,0.5f)); Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z, true); Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z + 1, true); Globals.gameInstance.sceneGraph.Setup(m); Globals.gameInstance.sceneGraph.Add(m); } int pi3 = (pixelY + 1) * 96 + pixelX + 2; if (colours[pi3] != Color.DarkMagenta) { Mesh m = new Mesh(); m.Model = AssetLoader.mdl_desk; m.SetInstancingEnabled(true); m.Transform = Matrix.CreateRotationY(MathHelper.ToRadians(90)) * Matrix.CreateTranslation(center + new Vector3(0.5f, 0, 0)); Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z, true); Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z + 1, true); Globals.gameInstance.sceneGraph.Setup(m); Globals.gameInstance.sceneGraph.Add(m); } } else if (c == Color.Turquoise) { float a = GetAngleToAWall(colours, pixelX, pixelY); Mesh m = new Mesh(); m.Model = AssetLoader.mdl_pipe; m.SetInstancingEnabled(true); m.Transform = Matrix.CreateRotationY(MathHelper.ToRadians(a)) * Matrix.CreateTranslation(center); Globals.gameInstance.cellCollider.SetCollision(center.X, center.Z, true); Globals.gameInstance.sceneGraph.Setup(m); Globals.gameInstance.sceneGraph.Add(m); } else if (c == Color.Tan) { csection.SetWeaponDepot(new WeaponDepot(center, Globals.random.Next(3)+1)); } else if (c == Color.SteelBlue) { Globals.gameInstance.campaignManager.SetTeleport(new Teleporter(center)); } } } Globals.gameInstance.campaignManager.AddSection(csection); }