- Timestamp:
- 2016-06-04 11:33:00 (7 years ago)
- Location:
- 2015/koodauskerho/sieerinn/JypeliShaderTest/JypeliShaderTest
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/koodauskerho/sieerinn/JypeliShaderTest/JypeliShaderTest/JypeliShaderTest/JypeliShaderTest.cs
r7171 r7176 27 27 private SpriteBatch spriteBatch; 28 28 29 struct Shockwave 30 { 31 public Vector Center; 32 public double Time; 33 } 34 35 private const int MAX_WAVES = 8; 36 private readonly Shockwave[] waves = new Shockwave[MAX_WAVES]; 37 private int waveIndex = 0; 38 39 private void NewWave(Vector position) 40 { 41 waves[waveIndex].Time = 0f; 42 waves[waveIndex].Center = position; 43 waveIndex = ++waveIndex % MAX_WAVES; 44 } 45 29 46 public override void Begin() 30 47 { … … 33 50 GraphicsDevice.PresentationParameters.BackBufferHeight); 34 51 35 effect = Content.Load<Effect>(" TestShader");52 effect = Content.Load<Effect>("Shockwave"); 36 53 spriteBatch = new SpriteBatch(GraphicsDevice); 37 54 55 IsMouseVisible = true; 38 56 Gravity = new Vector(0, -1000); 39 57 40 58 LuoKentta(); 41 59 LisaaNappaimet(); 60 61 Mouse.Listen(MouseButton.Left, ButtonState.Pressed, () => NewWave(Mouse.PositionOnWorld), null); 42 62 43 63 Camera.Follow(pelaaja1); … … 58 78 effect.Parameters["MatrixTransform"].SetValue(halfPixelOffset * projection); 59 79 60 effect.Parameters["Resolution"].SetValue(new Vector2(GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight)); 61 effect.Parameters["Misalign"].SetValue(0.003f); 62 effect.Parameters["Time"].SetValue(100f * (float)gameTime.TotalGameTime.TotalSeconds); 80 // TestShader 81 //effect.Parameters["Resolution"].SetValue(new Vector2(GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight)); 82 //effect.Parameters["Misalign"].SetValue(0.003f); 83 //effect.Parameters["Time"].SetValue(100f * (float)gameTime.TotalGameTime.TotalSeconds); 84 85 // Shockwave 86 var waveArray = new Vector4[MAX_WAVES]; 87 for (int i = 0; i < MAX_WAVES; i++) 88 { 89 waves[i].Time += 0.5 * gameTime.ElapsedGameTime.TotalSeconds; 90 Vector resolution = new Vector(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); 91 Vector screenCoord = Camera.WorldToScreen(waves[i].Center); 92 screenCoord.Y = resolution.Y - screenCoord.Y; 93 screenCoord.X /= resolution.X; 94 screenCoord.Y /= resolution.Y; 95 screenCoord += new Vector(0.5f, -0.5f); 96 97 var v = new Vector4((float)screenCoord.X, (float)screenCoord.Y, (float)waves[i].Time, 1f); 98 waveArray[i] = v; 99 } 100 101 effect.Parameters["Waves"].SetValue(waveArray); 63 102 64 103 GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.Black); -
2015/koodauskerho/sieerinn/JypeliShaderTest/JypeliShaderTest/JypeliShaderTestContent/JypeliShaderTestContent.contentproj
r7171 r7176 74 74 </Compile> 75 75 </ItemGroup> 76 <ItemGroup> 77 <Compile Include="Shockwave.fx"> 78 <Name>Shockwave</Name> 79 <Importer>EffectImporter</Importer> 80 <Processor>EffectProcessor</Processor> 81 </Compile> 82 </ItemGroup> 76 83 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 77 84 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.