public override void initialization() { START_initialization(); float x = 0, y = 0, z = 0; if (!Projectile.jp.Loaded) { ShaderedScene.CalculateFromMaptoGraphical(Explosion.exp.ExplosionCenter, ref x, ref y, ref z); } else { x = Projectile.jp.AbsoluteEstimatedLocation().x; y = Projectile.jp.AbsoluteEstimatedLocation().y; z = Projectile.jp.AbsoluteEstimatedLocation().z; } ForEachTemporalList(this, TemporalList, x, y, z); //if (Projectile.jp.Loaded) // ForEachTemporalList(Projectile.jp.ProjectileParts); END_initialization(); base.LastCount = vertices.Count(); }
public static void ForEachTemporalList(DataForDraw_angled Data, List <CubicalMemory.Cube> Temper, float cx, float cy, float cz, bool ShowAlways = false) { float x = 0, y = 0, z = 0; //Так по поводу взрыва. Давай все мерить в TNT эквиваленте. float Me = (float)Projectile.settings.Me; //mass of the fragmenting casing float Mc = (float)Projectile.settings.Mc; //mass of the explosive charge float K = (float)Projectile.settings.K; //Geometrical Constant for cube float dE = (float)Projectile.settings.dE; // J/kg Heat of TNT Explosion double rightpart = (Mc / Me) / (1 + K * (Mc / Me)); float V = (float)Math.Sqrt(2 * dE * (rightpart)); ExplosionVelocity = V; foreach (var cube in Temper) { ShaderedScene.CalculateFromMaptoGraphical(cube, ref x, ref y, ref z); float Vx = x - cx, Vy = y - cy, Vz = z - cz; float Range = (float)Math.Sqrt((double)Vx * Vx + Vy * Vy + Vz * Vz); Vx *= V / (Range * Range); Vy *= V / (Range * Range); Vz *= V / (Range * Range); float Velocity = (float)Math.Sqrt((double)Vx * Vx + Vy * Vy + Vz * Vz); if (ShowAlways || Velocity > 10) { cube.IsTakenForExplosion = true; Data.Draw_Quad_Full_Sunsided_angled(x, y, z, Vx, Vy, Vz, localed_range, cube.color, 0, true); } } }
public void PlaceTheBombAt(CubicalMemory.Cube cube) { float x1 = 0, y1 = 0, z1 = 0; ShaderedScene.CalculateFromMaptoGraphical(cube, ref x1, ref y1, ref z1); Explosion.exp.SetBombLocation(x1, y1, z1); }
public override void initialization() { START_initialization(); //Ghost Cube if (StaticSettings.S.GhostCube_Add_in_Data_For_Draw) { bool thing = false; bool found = false; try { thing = Scene.SS.env.cub_mem.world.World_as_Whole [Scene.SS.env.player.coords.Player_chunk_lookforcube.x] [Scene.SS.env.player.coords.Player_chunk_lookforcube.z].cubes [Scene.SS.env.player.coords.Player_cubical_lookforcube.x] [Scene.SS.env.player.coords.Player_cubical_lookforcube.y] [Scene.SS.env.player.coords.Player_cubical_lookforcube.z].IsFilled; found = true; } catch (Exception) { found = false; } if (found) { System.Drawing.Color result = System.Drawing.Color.Gray; if (thing) { System.Drawing.Color colour = Scene.SS.env.cub_mem.world.World_as_Whole [Scene.SS.env.player.coords.Player_chunk_lookforcube.x] [Scene.SS.env.player.coords.Player_chunk_lookforcube.z].cubes [Scene.SS.env.player.coords.Player_cubical_lookforcube.x] [Scene.SS.env.player.coords.Player_cubical_lookforcube.y] [Scene.SS.env.player.coords.Player_cubical_lookforcube.z].color; result = System.Drawing.Color.FromArgb ( (int)((float)(GraphicalOverlap.GO_color.R + colour.R) / 2), (int)((float)(GraphicalOverlap.GO_color.G + colour.G) / 2), (int)((float)(GraphicalOverlap.GO_color.B + colour.B) / 2) ); } else { result = GraphicalOverlap.GO_color; } ShaderedScene.CalculateFromMaptoGraphical(Scene.SS.env.player.coords.Player_chunk_lookforcube, Scene.SS.env.player.coords.Player_cubical_lookforcube, ref x, ref y, ref z); Draw_Quad_Full_Sunsided_angled(x, y, z, 0.0f, 0.0f, 0.0f, localed_range, result, 0, true); } } END_initialization(); base.LastCount = vertices.Count(); }
public override void initialization() { START_initialization(); foreach (var cube in TemporalList) { ShaderedScene.CalculateFromMaptoGraphical(cube, ref x, ref y, ref z); Draw_Quad_Full_Sunsided_angled(x, y, z, cube.FallingStartingTime, cube.FallingFromHeight * (CubicalMemory.Cube.rangeOfTheEdge), 0.0f, localed_range, cube.color, 0, true); } END_initialization(); base.LastCount = vertices.Count(); }
public void SetHpos2() { if (hpos1 == null) { MessageBox.Show("Select Hpos1(K) before Hpos2(U)!"); return; } hpos2 = Cube_Selection.Decide_Position_To_Place_Cube(false); ShaderedScene.CalculateFromMaptoGraphical(hpos1, ref hposition1); ShaderedScene.CalculateFromMaptoGraphical(hpos2, ref hposition2); sd.Set_Center((hposition1 + hposition2) / 2); GatherCubes(); }
public override void initialization() { START_initialization(); int i = 0; int j = 0; int value = 0; if ((value = Scene.SS.env.player.coords.Player_chunk_position.x - StaticSettings.S.RangeOfView) > 0) { i = value + 1; } else { i = 0; } for (; i < Scene.SS.env.cub_mem.world.World_as_Whole.Count() && i < Scene.SS.env.player.coords.Player_chunk_position.x + StaticSettings.S.RangeOfView; i++) { if ((value = Scene.SS.env.player.coords.Player_chunk_position.z - StaticSettings.S.RangeOfView) > 0) { j = value + 1; } else { j = 0; } for (; j < Scene.SS.env.cub_mem.world.World_as_Whole[i].Count() && j < Scene.SS.env.player.coords.Player_chunk_position.z + StaticSettings.S.RangeOfView; j++) { var XYworld = Scene.SS.env.cub_mem.world.World_as_Whole[i][j]; if (Math.Abs(XYworld.xz.x - Scene.SS.env.player.coords.Player_chunk_position.x) < StaticSettings.S.RangeOfView && Math.Abs(XYworld.xz.z - Scene.SS.env.player.coords.Player_chunk_position.z) < StaticSettings.S.RangeOfView) { foreach (var Xcube in XYworld.cubes) { foreach (var XYcube in Xcube) { foreach (var XYZcube in XYcube) { if (XYZcube.IsFilled && !XYZcube.IsTakenForExplosion) { ShaderedScene.CalculateFromMaptoGraphical(XYZcube, ref x, ref y, ref z); //POINT OF VIEWER Scene.SS.env.player.NormalizedToXYWorld.x = Scene.SS.env.player.coords.Player_precise_stepback.x - x; Scene.SS.env.player.NormalizedToXYWorld.y = Scene.SS.env.player.coords.Player_precise_stepback.y - y; Scene.SS.env.player.NormalizedToXYWorld.z = Scene.SS.env.player.coords.Player_precise_stepback.z - z; float range = GeneralProgrammingStuff.vec3_range(Scene.SS.env.player.NormalizedToXYWorld); GeneralProgrammingStuff.vec3_normalize(ref Scene.SS.env.player.NormalizedToXYWorld, range); Scene.SS.env.player.coords.LookForCube(); float scalar = GeneralProgrammingStuff.vec3_scalar(Scene.SS.env.player.NormalizedToXYWorld, Scene.SS.env.player.coords.NormalizedLook); //POINT OF VIEWER if (!StaticSettings.S.RealoderCauseOfPointOfView || scalar > 0) { //if (!StaticSettings.S.RealoderCauseOfSunSided || // XYworld.xz.x == Scene.SS.env.player.coords.Player_chunk_position.x // && XYworld.xz.z == Scene.SS.env.player.coords.Player_chunk_position.z) // Draw_Quad_Full_Sunsided(x, y, z, localed_range, XYZcube.color, true); //Вроде обычный куб. //else if (!StaticSettings.S.PointOfView_Circled_Visible_Cubes || range < CubicalMemory.Cube.rangeOfTheEdge * CubicalMemory.Chunk.Width * (StaticSettings.S.RangeOfView)) { Draw_Quad_Full_Sunsided_not_angled(x, y, z, localed_range, XYZcube.color); } } } } } } } } } END_initialization(); }
//Создание шейдеров более in Old Fashioned Way чтобы использовать Geomtry Shader //https://www.codeproject.com/Articles/1167387/OpenGL-with-OpenTK-in-Csharp-Part-Compiling-Shader public void Initialise(OpenGL gl, float width, float height) { this.width = width; this.height = height; try { _gl = gl; SS = new ShaderedScene(gl); newThread_ghost = new Thread(Scene.DoWork_ghost); Console.WriteLine("Starting My"); newThread = new Thread(Scene.DoWork); newThread.Start(42); while (newThread.IsAlive) { } Console.WriteLine("Finished My"); SS.Main.CopyToReady(); // Set a blue clear colour. gl.ClearColor(0.4f, 0.6f, 0.9f, 0.0f); //gl.Hint(OpenGL.WGL_CONTEXT_DEBUG_BIT_ARB, OpenGL.GL_TRUE); // Create the shader program. var Header = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Header.vert"); var Cuter = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Cuter.vert"); var Sun = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Sun.vert"); var Rotator = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Rotator.vert"); var Translation = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Translation.vert"); var Sizer = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Sizer.vert"); var Explosion = ManifestResourceLoader.LoadTextFile(@"Shaders\VertexModules\Explosion.vert"); var Main = ManifestResourceLoader.LoadTextFile(@"Shaders\Main\Main.vert"); var Adv_main = ManifestResourceLoader.LoadTextFile(@"Shaders\Main\Adv_main.vert"); var Projectile_main = ManifestResourceLoader.LoadTextFile(@"Shaders\Main\Projectile_main.vert"); var vertexShaderSource = Header + Rotator + Cuter + Sun + Main; var FragmentalShader = ManifestResourceLoader.LoadTextFile(@"Shaders\OtherShaders\FragmentalShader.frag"); var GeometryShader = ManifestResourceLoader.LoadTextFile(@"Shaders\OtherShaders\GeometryShader.geom"); shaderProgram = new ModifiedShaderProgram(); shaderProgram.Create(gl, vertexShaderSource, FragmentalShader, GeometryShader, null); shaderProgram.BindAttributeLocation(gl, attributeIndexPosition, "in_Position"); shaderProgram.BindAttributeLocation(gl, attributeIndexColour, "in_Color"); shaderProgram.AssertValid(gl); var vertexShaderSource2 = Header + Rotator + Cuter + Sun + Translation + Sizer + Explosion + Adv_main; shaderProgram_secondary = new ModifiedShaderProgram(); shaderProgram_secondary.Create(gl, vertexShaderSource2, FragmentalShader, GeometryShader, null); shaderProgram_secondary.BindAttributeLocation(gl, attributeIndexPosition, "in_Position"); shaderProgram_secondary.BindAttributeLocation(gl, attributeIndexColour, "in_Color"); shaderProgram_secondary.BindAttributeLocation(gl, 2, "in_Center"); shaderProgram_secondary.BindAttributeLocation(gl, 3, "in_Angles"); shaderProgram_secondary.BindAttributeLocation(gl, 4, "in_Size"); shaderProgram_secondary.AssertValid(gl); var vertexShaderSource3 = Header + Rotator + Cuter + Sun + Translation + Sizer + Explosion + Projectile_main; shaderProgram_projectile = new ModifiedShaderProgram(); shaderProgram_projectile.Create(gl, vertexShaderSource3, FragmentalShader, GeometryShader, null); shaderProgram_projectile.BindAttributeLocation(gl, attributeIndexPosition, "in_Position"); shaderProgram_projectile.BindAttributeLocation(gl, attributeIndexColour, "in_Color"); shaderProgram_projectile.BindAttributeLocation(gl, 2, "in_Center"); shaderProgram_projectile.BindAttributeLocation(gl, 3, "in_Angles"); shaderProgram_projectile.BindAttributeLocation(gl, 4, "in_Size"); shaderProgram_projectile.AssertValid(gl); } catch (ShaderCompilationException ShadersMessageError) { ShadersInitializated = false; ShadersWereNotInitializatedMessage = ShadersMessageError.CompilerOutput; MessageBox.Show(ShadersWereNotInitializatedMessage); //Environment.Exit(123); } if (ShadersInitializated) { // Create a perspective projection matrix. // Create a model matrix to make the model a little bigger. modelMatrix = glm.scale(new mat4(1.0f), new vec3(Environment.SizeView)); // Now create the geometry for the square. SS.Main.scene_info.CreateVerticesForSquare_not_angled(); var handle = GetConsoleWindow(); if (!StaticSettings.S.ConsoleIsEnabled) { ShowWindow(handle, SW_HIDE); } Scene.SS.env.player.coords.Player_precise_position.TryLoad("PlayerPosition"); Scene.SS.env.player.coords.Player_rotational_view.TryLoad("PlayerRotationalView"); SaveAndLoad.Load("default"); Reloader_SunAndMoon(); gl.Enable(OpenGL.GL_BLEND); gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA); } if (StaticSettings.S.LoadProjectile) { Projectile.jp.LoadFromFile(); } }
public void Exploding_Rewriter() { if (ExplosionCenter != null) { Point2Int Bomb_chunk_position = new Point2Int(0, 0); Point3Int Bomb_cubical_position = new Point3Int(0, 0, 0); Scene.SS.env.player.coords.Reverse_presice_to_map_coords(Bomb_precise_position, ref Bomb_chunk_position, ref Bomb_cubical_position); int Range_of_chunk_explosion = (int)Projectile.settings.Explosion_radius; //DataForDraw_ExplodingList.TemporalList.Clear(); int i = 0; int j = 0; int value = 0; if ((value = Bomb_chunk_position.x - Range_of_chunk_explosion) > 0) { i = value; } else { i = 0; } for (; i < Scene.SS.env.cub_mem.world.World_as_Whole.Count() && i < Bomb_chunk_position.x + Range_of_chunk_explosion; i++) { if ((value = Bomb_chunk_position.z - Range_of_chunk_explosion) > 0) { j = value; } else { j = 0; } for (; j < Scene.SS.env.cub_mem.world.World_as_Whole[i].Count() && j < Bomb_chunk_position.z + Range_of_chunk_explosion; j++) { var XYworld = Scene.SS.env.cub_mem.world.World_as_Whole[i][j]; if (Math.Abs(XYworld.xz.x - Bomb_chunk_position.x) < Range_of_chunk_explosion && Math.Abs(XYworld.xz.z - Bomb_chunk_position.z) < Range_of_chunk_explosion) { foreach (var Xcube in XYworld.cubes) { foreach (var XYcube in Xcube) { foreach (var XYZcube in XYcube) { if (XYZcube.IsFilled && !XYZcube.IsTakenForExplosion) { ShaderedScene.CalculateFromMaptoGraphical(XYZcube, ref x, ref y, ref z); //POINT OF VIEWER vec3 range_to_cube = new vec3(0, 0, 0); range_to_cube.x = Bomb_precise_position.x - x; range_to_cube.y = Bomb_precise_position.y - y; range_to_cube.z = Bomb_precise_position.z - z; float range = GeneralProgrammingStuff.vec3_range(range_to_cube); if (range < CubicalMemory.Cube.rangeOfTheEdge * Projectile.settings.Explosion_radius) { XYZcube.FallingStartingTime = Explosion.exp.StartingTime; DataForDraw_ExplodingList.TemporalList.Add(XYZcube); //Draw_Quad_Full_Sunsided_not_angled(x, y, z, localed_range, XYZcube.color); } } } } } } } } ExplosionCenter.IsTakenForExplosion = true; } }
public void GatherCubes() { Loaded = true; if (ProjectileParts.Count() != 0) { foreach (var item in ProjectileParts) { item.IsTakenForExplosion = false; } } ProjectileParts.Clear(); sd.Set_Center((hposition1 + hposition2) / 2); vec3 pos_min = new vec3(Math.Min(hposition1.x, hposition2.x), Math.Min(hposition1.y, hposition2.y), Math.Min(hposition1.z, hposition2.z)); vec3 pos_max = new vec3(Math.Max(hposition1.x, hposition2.x), Math.Max(hposition1.y, hposition2.y), Math.Max(hposition1.z, hposition2.z)); half_height = hposition2.y - hposition1.y; vec3 cubeposition = new vec3(0, 0, 0); foreach (var XWorld in Scene.SS.env.cub_mem.world.World_as_Whole) { foreach (var XYWorld in XWorld) { foreach (var Xcube in XYWorld.cubes) { foreach (var XYcube in Xcube) { foreach (var XYZcube in XYcube) { ShaderedScene.CalculateFromMaptoGraphical(XYZcube, ref cubeposition); if (cubeposition.x >= pos_min.x && cubeposition.y >= pos_min.y && cubeposition.z >= pos_min.z && cubeposition.x <= pos_max.x && cubeposition.y <= pos_max.y && cubeposition.z <= pos_max.z ) { vec3 ranged = cubeposition - sd.Get_Center(); double range = Math.Sqrt(ranged.x * ranged.x + ranged.y * ranged.y + ranged.z * ranged.z); if (range < CenterCube_RangeMax) { CenterCube_RangeMax = range; CenterCube = XYZcube; } if (XYZcube.IsFilled) { XYZcube.IsTakenForExplosion = true; ProjectileParts.Add(XYZcube); } } } } } } } Scene.SS.ProjectileList.Reloader(); StaticSettings.S.RealoderCauseOfBuildingBlocks = true; }