public StatefulParticleSystem( Renderer renderer, WrappedContentManager wrappedContent, GraphicsDevice device ) { this.renderer = renderer; this.emitters = new List <ParticleEmitter>(); this.nextParticleIndex = 0; this.device = device; this.remainingDt = 0.0; this.activeTexture = 0; this.positionTextures = null; this.velocityTextures = null; this.localCreateVertices = null; this.createVertexBuffer = null; this.createVertexDeclaration = null; this.particleCreateEffect = null; this.particleUpdateEffect = null; this.particleRenderingEffect = null; spriteBatch = new SpriteBatch(device); this.nextEmitterId = 0; this.freeEmitterIds = new List <int>(); LoadResources(renderer, wrappedContent, device); }
public Smoke( Renderer renderer, WrappedContentManager wrappedContent, GraphicsDevice device ) : base(renderer, wrappedContent, device) { }
public Flamethrower( Renderer renderer, WrappedContentManager wrappedContent, GraphicsDevice device ) : base(renderer, wrappedContent, device) { }
public IceExplosion( Renderer renderer, WrappedContentManager wrappedContent, GraphicsDevice device ) : base(renderer, wrappedContent, device) { }
/// <summary> /// /// </summary> /// <param name="device"></param> /// <param name="wrappedContent"></param> /// <param name="fontName"></param> /// <param name="userMail"></param> public CrashDebugger( GraphicsDevice device, WrappedContentManager wrappedContent, string fontName, string userMail ) { font = wrappedContent.Load <SpriteFont>(fontName); //testTexture = wrappedContent.Load<Texture2D>("Textures/custom_uv_diag"); spriteBatch = new SpriteBatch(device); this.userMail = userMail; }
public LavaExplosion( Renderer renderer, WrappedContentManager wrappedContent, GraphicsDevice device, float explosionSize, float explosionRgbMultiplier, float explosionDotMultiplier ) : base(renderer, wrappedContent, device) { this.explosionSize = explosionSize; this.explosionRgbMultiplier = explosionRgbMultiplier; this.explosionDotMultiplier = explosionDotMultiplier; }
public IceSpike( Renderer renderer, WrappedContentManager wrappedContent, GraphicsDevice device ) : base(renderer, wrappedContent, device) { Effect effect = LoadEffect(wrappedContent); int rowCount = effect.Parameters["IceSpikePositionArray"].Elements.Count; positionArray = new Vector3[rowCount]; directionArray = new Vector3[rowCount]; deadArray = new bool[rowCount]; gravityStartArray = new float[rowCount]; }
protected virtual void LoadResources( Renderer renderer, WrappedContentManager wrappedContent, GraphicsDevice device ) { // create texture maps activeTexture = 0; positionTextures = new RenderTarget2D[2]; positionTextures[0] = renderer.StatefulParticleResourceManager.AllocateStateTexture(GetSystemSize()); positionTextures[1] = renderer.StatefulParticleResourceManager.AllocateStateTexture(GetSystemSize()); velocityTextures = new RenderTarget2D[2]; velocityTextures[0] = renderer.StatefulParticleResourceManager.AllocateStateTexture(GetSystemSize()); velocityTextures[1] = renderer.StatefulParticleResourceManager.AllocateStateTexture(GetSystemSize()); // initialize the first two textures RenderTargetBinding[] currentRenderTargets = device.GetRenderTargets(); device.SetRenderTargets(positionTextures[0], velocityTextures[0]); device.Clear(ClearOptions.Target, new Vector4(0, 0, 0, 0), 0, 0); device.SetRenderTargets(currentRenderTargets); //positionTextures[0].GetTexture().Save("PositionMaps/initial.dds", ImageFileFormat.Dds); // create effect localCreateVertices = new CreateVertex[createVertexBufferSize]; createVertexDeclaration = new VertexDeclaration(CreateVertex.SizeInBytes, CreateVertex.VertexElements); createVertexBuffer = new DynamicVertexBuffer(device, createVertexDeclaration, CreateVertex.SizeInBytes * createVertexBufferSize, /*BufferUsage.Points |*/ BufferUsage.WriteOnly); // no more point sprites... :-( TODO: fix particleCreateEffect = LoadCreateEffect(wrappedContent).Clone(); particleCreateEffect.CurrentTechnique = particleCreateEffect.Techniques["CreateParticles"]; // update effect particleUpdateEffect = LoadUpdateEffect(wrappedContent).Clone(); particleUpdateEffect.CurrentTechnique = particleUpdateEffect.Techniques["UpdateParticles"]; // rendering effect particleRenderingEffect = LoadRenderEffect(wrappedContent).Clone(); particleRenderingEffect.CurrentTechnique = particleRenderingEffect.Techniques["RenderParticles"]; spriteTexture = LoadSprite(wrappedContent); }
public Snow( Renderer renderer, WrappedContentManager wrappedContent, GraphicsDevice device, float snowLifeTime, float snowMaxAlpha, float snowBaseSize, float snowRandomSizeModification, float snowMeltingStart, float snowMeltingEnd ) : base(renderer, wrappedContent, device) { this.snowLifeTime = snowLifeTime; this.snowMaxAlpha = snowMaxAlpha; this.snowBaseSize = snowBaseSize; this.snowRandomSizeModification = snowRandomSizeModification; this.snowMeltingStart = snowMeltingStart; this.snowMeltingEnd = snowMeltingEnd; }
public RendererUpdateQueue Initialize( WrappedContentManager wrappedContent, string simulationLevel, string rendererLevel, double startTime ) { try { simTime = new SimulationTime(startTime); StartOperation(); // needs a valid simTime! paused = false; currentUpdateQueue.AddUpdate(new Renderer.Renderer.ChangeLevelUpdate(rendererLevel)); SetPhase(SimulationPhase.Intro, "", null); // load level data levelData = wrappedContent.Load <LevelData>(simulationLevel); entityManager.Load(levelData); soundRegistry.Load(); LevelLoaded(); // start to play sounds MusicSettingsLoaded(); Game.Instance.AudioPlayer.Play(soundRegistry.CaveBackgroundLoop, true); Game.Instance.AudioPlayer.Play(soundRegistry.LavaBackgroundLoop, true); return(EndOperation()); } finally { currentUpdateQueue = null; } }
public Profiler(WrappedContentManager wrappedContent, string name) { rootSection = new Section(this, null, "root"); sectionStack = new List <Section>(100); frameNumber = 0; inBeginFrame = false; this.name = name; filterList = new List <string>(); filterList.Add("root"); filterList.Add("root.draw"); filterList.Add("root.draw.beginning_stuff"); filterList.Add("root.draw.rendering.*"); if (wrappedContent != null) { overlayBackground = new Texture2D(Game.Instance.GraphicsDevice, 32, 32); Color[] colorData = new Color[overlayBackground.Width * overlayBackground.Height]; for (int i = 0; i < overlayBackground.Width * overlayBackground.Height; ++i) { colorData[i] = Color.Black; } overlayBackground.SetData <Color>(colorData); overlayBackground2 = new Texture2D(Game.Instance.GraphicsDevice, 32, 32); for (int i = 0; i < overlayBackground2.Width * overlayBackground2.Height; ++i) { colorData[i] = Color.Yellow; } overlayBackground2.SetData <Color>(colorData); spriteBatch = new SpriteBatch(Game.Instance.GraphicsDevice); font = wrappedContent.Load <SpriteFont>("Fonts/kootenay20"); } }
protected abstract Effect LoadEffect(WrappedContentManager wrappedContent);
protected override Effect LoadRenderEffect(WrappedContentManager wrappedContent) { return(LoadEffect(wrappedContent)); }
private Effect LoadEffect(WrappedContentManager wrappedContent) { return(wrappedContent.Load <Effect>("Effects/Sfx/ParticleSystem/Stateful/Implementations/IceSpike")); }
protected override void LoadResources(Renderer renderer, WrappedContentManager wrappedContent, GraphicsDevice device) { base.LoadResources(renderer, wrappedContent, device); }
public Renderer( WrappedContentManager wrappedContent, GraphicsDevice device ) { EnablePostProcessing = true; renderTime = new RenderTime(Game.Instance.GlobalClock.ContinuousMilliseconds, Game.Instance.GlobalClock.PausableMilliseconds); entityManager = new RendererEntityManager(); this.device = device; updateRenderables = new List <Renderable>(); // shadowCaster = new List<Renderable>(); opaqueRenderables = new List <Renderable>(); transparentRenderablesTEST = new List <Renderable>(); transparentRenderables = new List <Renderable>(); overlays = new List <Renderable>(); shadowEffect = wrappedContent.Load <Effect>("Effects/ShadowEffect"); lightPosition = new Vector3(0, 10000, 0); // later: replace by orthographic light, not lookAt lightTarget = Vector3.Zero; lightProjection = Matrix.CreateOrthographic(1500, 1500, 0.0f, 10000.0f); // Set the light to look at the center of the scene. lightView = Matrix.CreateLookAt( lightPosition, lightTarget, new Vector3(0, 0, -1)); // later: replace by something like this: lightRenderTarget = new RenderTarget2D( device, shadowMapSize, shadowMapSize, false, SurfaceFormat.Single, DepthFormat.Depth24Stencil8 ); vectorCloudTexture = wrappedContent.Load <Texture2D>("Textures/Lava/vectorclouds"); Color[] vectorCloudTextureData = new Color[vectorCloudTexture.Width * vectorCloudTexture.Height]; vectorCloudTexture.GetData <Color>(vectorCloudTextureData); HalfVector4[] vectorCloudTexture4vsData = new HalfVector4[vectorCloudTexture.Width * vectorCloudTexture.Height]; for (int i = 0; i < vectorCloudTexture.Width * vectorCloudTexture.Height; ++i) { Color current = vectorCloudTextureData[i]; float r = (float)current.R / (float)Byte.MaxValue; float g = (float)current.G / (float)Byte.MaxValue; float b = (float)current.B / (float)Byte.MaxValue; vectorCloudTexture4vsData[i] = new HalfVector4(r, g, b, 1); } vectorCloudTextureForVertexShaders = new Texture2D(device, vectorCloudTexture.Width, vectorCloudTexture.Height, false, SurfaceFormat.HalfVector4); vectorCloudTextureForVertexShaders.SetData(vectorCloudTexture4vsData); // set up render targets PresentationParameters pp = Device.PresentationParameters; int width = pp.BackBufferWidth; int height = pp.BackBufferHeight; //SurfaceFormat format = SurfaceFormat.HalfVector4; //SurfaceFormat format = SurfaceFormat.Vector4; SurfaceFormat format = pp.BackBufferFormat; if (EnablePostProcessing) { //ResolveTarget = new ResolveTexture2D(Device, width, height, 1, format); targetOpaqueColorBuffer = new RenderTarget2D(Device, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); targetAlphaColorBuffer = new RenderTarget2D(Device, width, height, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); targetHDRColorBuffer = new RenderTarget2D(Device, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); targetHorizontalBlurredHDRColorBuffer = new RenderTarget2D(Device, width / 2, height / 2, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); targetBlurredHDRColorBuffer = new RenderTarget2D(Device, width / 2, height / 2, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); targetOpaqueRenderChannels = new RenderTarget2D(Device, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); targetAlphaRenderChannels = new RenderTarget2D(Device, width, height, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); targetRenderChannels = new RenderTarget2D(Device, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); targetHorizontalBlurredRenderChannels = new RenderTarget2D(Device, width / 2, height / 2, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); targetBlurredRenderChannels = new RenderTarget2D(Device, width / 2, height / 2, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); targetOpaqueDepth = new RenderTarget2D(Device, width, height, false, SurfaceFormat.Vector2, DepthFormat.Depth24Stencil8); targetAlphaDepth = new RenderTarget2D(Device, width, height, false, SurfaceFormat.Single, DepthFormat.Depth24Stencil8); targetDepth = new RenderTarget2D(Device, width, height, false, SurfaceFormat.Vector2, DepthFormat.Depth24Stencil8); restoreDepthBufferPass = new RestoreDepthBufferPass(this); combinePass = new CombinePass(this); combineDepthPass = new CombineDepthPass(this); glowPass = new GlowPass(this); hdrCombinePass = new HdrCombinePass(this); } statefulParticleResourceManager = new ProjectMagma.Renderer.ParticleSystem.Stateful.ResourceManager(wrappedContent, device); updateQueues = new List <RendererUpdateQueue>(); billboard = new Billboard(this, new Vector3(0, 200, 0), 250, 250, Vector4.One); }
public static Profiler CreateProfiler(WrappedContentManager wrappedContent, string name) { Console.WriteLine("profiling code using {0}!", name); return(new Profiler(wrappedContent, name)); }
protected override Effect LoadEffect(WrappedContentManager wrappedContent) { return(wrappedContent.Load <Effect>("Effects/Sfx/ParticleSystem/Stateful/Implementations/IceExplosion")); }
protected override Effect LoadRenderEffect(WrappedContentManager wrappedContent) { return(wrappedContent.Load <Effect>("Effects/ParticleSystem/Stateful/Implementations/Smoke")); }
protected virtual Texture2D LoadSprite(WrappedContentManager wrappedContent) { return(wrappedContent.Load <Texture2D>("Textures/xna_logo")); }
protected virtual Effect LoadRenderEffect(WrappedContentManager wrappedContent) { return(wrappedContent.Load <Effect>("Effects/ParticleSystem/Stateful/Default")); }
protected override Texture2D LoadSprite(WrappedContentManager wrappedContent) { return(wrappedContent.Load <Texture2D>("Textures/Sfx/IceExplosion")); }
public ResourceManager( WrappedContentManager wrappedContent, GraphicsDevice device ) { this.device = device; // create the vertex declaration for rendering renderingVertexDeclaration = new VertexDeclaration(RenderVertex.SizeInBytes, RenderVertex.VertexElements); // Create vertexbuffers. One for each particle map size renderingVertexBuffers = new VertexBuffer[(int)Size.SizeCount]; for (int i = 0; i < (int)Size.SizeCount; ++i) { Vector2 positionHalfPixel = new Vector2(1.0f / (2.0f * SizeMap[i]), 1.0f / (2.0f * SizeMap[i])); RenderVertex[] vertices = new RenderVertex[SizeMap[i] * SizeMap[i] * 6]; for (int x = 0; x < SizeMap[i]; ++x) { for (int y = 0; y < SizeMap[i]; ++y) { int particleIndex = y * SizeMap[i] + x; Vector2 particleCoordinate = new Vector2( positionHalfPixel.X + 2 * x * positionHalfPixel.X, positionHalfPixel.Y + 2 * y * positionHalfPixel.Y ); // corners are Short2[] corners = { new Short2(-1, -1), new Short2(1, -1), new Short2(1, 1), new Short2(-1, 1) }; int[] cornerIndices = { 0, 1, 2, 0, 2, 3 }; for (int j = 0; j < 6; ++j) { vertices[particleIndex * 6 + j].corner = corners[cornerIndices[j]]; vertices[particleIndex * 6 + j].particleCoordinate = particleCoordinate; } } } renderingVertexBuffers[i] = new VertexBuffer(device, renderingVertexDeclaration, RenderVertex.SizeInBytes * vertices.Length, BufferUsage.WriteOnly); renderingVertexBuffers[i].SetData <RenderVertex>(vertices); } // allocate the stateMapLists stateMapLists = new List <RenderTarget2D> [(int)Size.SizeCount]; for (int i = 0; i < (int)Size.SizeCount; ++i) { stateMapLists[i] = new List <RenderTarget2D>(); } this.createVertexArrays = new List <CreateVertexArray>(CreateVertexArrayMaxPoolSize); }