public KwadratMaterialnyPocisk(Wektor Wektor_polozenia,double kat) { vitality = 6; dlugoscScianyX = 5.0f; dlugoscScianyY = 6.0f; dlugoscScianyZ = 6.0f; polozenie = Wektor_polozenia; Random rand; rand = new Random(); double x = rand.NextDouble(); x -= 0.5; double y = rand.NextDouble(); y = 0; double z = rand.NextDouble(); z -= 0.5; Wektor temp; temp = new Wektor((float)x, (float)y, (float)z); temp = temp * 0.3f; predkosc = temp; grubosci = new Wektor(0.1f, 0.1f, 0.1f); kolor = new Wektor(0.1f, 0.1f, 0.1f); waga = 2f; angle = (double)rand.Next(360); }
// public SprawdzaczKolizji // public setUpGl() public bool CzyNieKoliduje(List<Wektor> ListaKolizji,float margines,Wektor KolidujacyWek) { margines *= 2; for(int i=0;i<ListaKolizji.Count;i++) { if(ListaKolizji.ElementAt(i).X - margines < KolidujacyWek.X && ListaKolizji.ElementAt(i).X + margines > KolidujacyWek.X) { // Debug.Write("jest w x"); if (ListaKolizji.ElementAt(i).Z - margines < KolidujacyWek.Z && ListaKolizji.ElementAt(i).Z + margines > KolidujacyWek.Z) { // Debug.Write("jest w X i Y"); Wektor temp = ListaKolizji.ElementAt(i); rysow.DrawCubo(ListaKolizji.ElementAt(i).X, ListaKolizji.ElementAt(i).Y, ListaKolizji.ElementAt(i).Z, 0.1f, 0.1f, 0.1f); rysow.DrawCubo(temp.X - margines, temp.Y, temp.Z, 0.1f, 0.1f, 0.1f); rysow.DrawCubo(temp.X + margines, temp.Y, temp.Z, 0.1f, 0.1f, 0.1f); rysow.DrawCubo(temp.X , temp.Y, temp.Z+ margines, 0.1f, 0.1f, 0.1f); rysow.DrawCubo(temp.X , temp.Y, temp.Z - margines, 0.1f, 0.1f, 0.1f); return true; } } } return false; }
public static Wektor operator -(Wektor b, Wektor c) { Wektor box = new Wektor(); box.X = b.X - c.X; box.Y = b.Y - c.Y; box.Z = b.Z - c.Z; return box; }
public static Wektor operator +(Wektor b, Wektor c) { Wektor box = new Wektor(); box.X = b.X + c.X; box.Y = b.Y + c.Y; box.Z = b.Z + c.Z; return box; }
public kwardratMaterialny() { polozenie = new Wektor(); predkosc = new Wektor(); grubosci = new Wektor(0.2f, 0.2f, 0.2f); kolor = new Wektor(0.5f, 0.5f, 0.5f); waga = 2f; angle = 0.0; }
public static Wektor operator *(Wektor b, Wektor c) { Wektor box = new Wektor(); box.X = b.X * c.X; box.Y = b.Y * c.Y; box.Z = b.Z * c.Z; return box; }
public kwardratMaterialny(Wektor Wektor_polozenia,Wektor Wektor_predkosci,Wektor wektor_grubosci,Wektor wektor_kolor,double kat) { polozenie = Wektor_polozenia; predkosc = Wektor_predkosci; grubosci = wektor_grubosci; kolor = wektor_kolor; waga = 2f; angle = kat; }
public KwadratMaterialnyPocisk(Wektor Wektor_polozenia, Wektor Wektor_predkosci, double kat, bool is_Player) { vitality = 6; dlugoscScianyX = 5.0f; dlugoscScianyY = 6.0f; dlugoscScianyZ = 6.0f; polozenie = Wektor_polozenia; predkosc = Wektor_predkosci; grubosci = new Wektor(0.1f, 0.1f, 0.1f); kolor = new Wektor(0.3f, 0.5f, 0.4f); waga = 2f; angle = kat; }
public KwadratBoss(bool czy_losowy) { Live = 28; counter = 0; if (czy_losowy) { Random rand; rand = new Random(); double x = rand.NextDouble(); x -= 0.5; double y = rand.NextDouble(); y = 0.0; double z = rand.NextDouble(); z -= 0.5; Wektor temp; temp = new Wektor((float)x, (float)y, (float)z); temp = temp * 10.0f; polozenie = temp; x = rand.NextDouble(); x -= 0.5; y = rand.NextDouble(); y = 0.0; z = rand.NextDouble(); z -= 0.5; // Wektor temp; temp = new Wektor((float)x, (float)y, (float)z); temp = temp * 0.1f; predkosc = temp; x = rand.NextDouble(); y = rand.NextDouble(); z = rand.NextDouble(); temp = new Wektor((float)x, (float)y, (float)z); temp = temp * 2.1f; grubosci = temp; x = rand.NextDouble(); kolor = new Wektor((float)x, (float)x, (float)x); waga = 2f; } else { polozenie = new Wektor(); predkosc = new Wektor(); grubosci = new Wektor(0.2f, 0.2f, 0.2f); kolor = new Wektor(0.5f, 0.5f, 0.5f); waga = 2f; } }
public bool CzyJestW(List<Wektor> ListaWektorow, float margin, Wektor Center) { // Debug.Write("dsada"); float Distance; //= sqrt(pow((pointvect[i].y - pointvect[i + 1].y), 2) + pow((pointvect[i].x - pointvect[i + 1].x), 2)); for (int i = 0; i < ListaWektorow.Count; i++) { // Debug.Write("fdfff"); Distance = (float)Math.Sqrt(Math.Pow((ListaWektorow.ElementAt(i).Z - Center.Z), 2) + (Math.Pow((ListaWektorow.ElementAt(i).X - Center.X), 2))); if(Distance < margin) { return true; } } return false; }
public bool CzyNieKoliduje(List<float> ListaKolizjiX,List<float> ListaKolizjiZ, float margines, Wektor KolidujacyWek) { Debug.WriteLine("wpadam?"); for (int i = 0; i < ListaKolizjiX.Count; i++) { Debug.Write("x"); if (ListaKolizjiX.ElementAt(i)- margines < KolidujacyWek.X && ListaKolizjiX.ElementAt(i) + margines > KolidujacyWek.X) { if (ListaKolizjiZ.ElementAt(i) - margines < KolidujacyWek.Z && ListaKolizjiZ.ElementAt(i) + margines > KolidujacyWek.Z) { return true; } } } return false; }
//soundtouch // // public void DrawCubo(float x1,float y1,float z1,float x2,float y2,float z2); public SharpGLForm() { KeyA=false; KeyS = false; KeyD = false; KeyW=false; KeySpace=false; WektorZero = new Wektor(0, 0, 0); PlayerWektorSpeed = new Wektor(0, 0, 0); PlayerLive = 7; YAxisCamera = 5; CursorWektor = new Wektor(0, 0, 0); CursorWektorAngled = new Wektor(0, 0, 0); Boss = new KwadratBoss(true); // new List<int>(); listaPociskow = new List<KwadratMaterialnyPocisk>(); listaPociskowPlayera = new List<KwadratMaterialnyPocisk>(); listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, new Wektor(0.1f, 0.0f, -0.13f), 22)); listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, new Wektor(0.09f, 0.0f, -0.03f), 22)); listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, new Wektor(-0.14f, 0.0f, -0.133f), 22)); for(int i=0 ; i<13 ; i++) { listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie,losowyWektorPredkosci(),20)); } cuboPlayer = new kwardratMaterialny(new Wektor(0.0f,0.0f,0.0f),new Wektor(0.0f,0.0f,0.0f),new Wektor(0.4f,0.4f,0.4f),new Wektor(0.2f,0.2f,0.2f),45); // Wektor temp,temp1; // temp = new Wektor(0.0f,0.0f,0.0f); // temp1 = new Wektor(0.2f,0.0f,-0.1f); bulletOne = new KwadratMaterialnyPocisk(new Wektor(0.0f, 0.0f, 0.0f),new Wektor(0.2f, 0.0f, 0.03f), 40); bulletOne = new KwadratMaterialnyPocisk(new Wektor(0.0f, 0.0f, 0.0f), 30); //bulletOne = new KwadratMaterialnyPocisk(temp, temp1, 30); // new KwadratMaterialnyPocisk() da = new Wektor(1.0f, 1.0f, 1.0f); // Wektor re; re = new Wektor(2.0f, 1.0f, 1.0f); InitializeComponent(); this.Controls.Add(openGLControl); // this. // openGLControl.KeyPress += openGLControl_KeyPress; this.openGLControl.KeyPress += new KeyPressEventHandler(keypressed); this.openGLControl.KeyDown += new KeyEventHandler(Form2_KeyDown); this.openGLControl.KeyUp += new KeyEventHandler(Form1_KeyUp); this.openGLControl.MouseClick += Control1_MouseClick; }
public kwardratMaterialny(bool czy_losowy) { if (czy_losowy) { Random rand; rand = new Random(); double x = rand.NextDouble(); x -= 0.5; double y = rand.NextDouble(); y = 0.0; double z = rand.NextDouble(); z -= 0.5; polozenie = new Wektor((float)x, (float)y, (float)z); x = rand.NextDouble(); x -= 0.5; y = rand.NextDouble(); y = 0.0; z = rand.NextDouble(); z -= 0.5; Wektor temp; temp = new Wektor((float)x, (float)y, (float)z); temp = temp * 0.1f; predkosc = temp; x = rand.NextDouble(); y = rand.NextDouble(); z = rand.NextDouble(); temp = new Wektor((float)x, (float)y, (float)z); temp = temp * 2.1f; grubosci = temp; x = rand.NextDouble(); kolor = new Wektor((float)x, (float)x, (float)x); waga = 2f; } else { polozenie = new Wektor(); predkosc = new Wektor(); grubosci = new Wektor(0.2f, 0.2f, 0.2f); kolor = new Wektor(0.5f, 0.5f, 0.5f); waga = 2f; } }
public void DrawMazyByListToSpeedUp(List<int> tempList, Wektor Center, float Weight_of_cell) { float weight; float weight_with_size; weight = Weight_of_cell; Wektor Cursor; Wektor DrawableCursor; //Cursor = Center; // weight_with_size = weight * tempList.Count; float Xx; float Yy; int InitialSize = (int)Math.Sqrt((double)tempList.Count); weight_with_size = weight * InitialSize; Cursor = new Wektor(Center.X - (weight_with_size / 2), Center.Y, Center.Z - (weight_with_size / 2)); // Debug.WriteLine(InitialSize); Xx = Center.X - (weight_with_size / 2); Yy = Center.Z - (weight_with_size / 2); DrawableCursor = Cursor; weight *= 2; gl.PushMatrix(); gl.Begin(OpenGL.GL_LINES); gl.Color(0.44f, 0.44f, 0.44f); int i = 0; // for (int i = 0; i < tempList.Count; i++ ) foreach (int prime in tempList) { //tempList.ElementAt(i) Cursor.X = Xx + ((weight) * (i / InitialSize)); Cursor.Z = Yy + ((weight) * (i % InitialSize)); // Debug.Write(prime); switch (tempList.ElementAt(i)) { case 11111: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y ,Cursor.Z + weight); // ListaPointowDoKolizji.Add(new Point(Cursor.X, Cursor.Z + weight)); drawVertex(Cursor); gl.Vertex(Cursor.X + weight, Center.Y, Cursor.Z); drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z - weight); drawVertex(Cursor); gl.Vertex(Cursor.X - weight, Center.Y, Cursor.Z); break; case 10111: drawVertex(Cursor); gl.Vertex(Cursor.X + weight, Center.Y, Cursor.Z); drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z - weight); drawVertex(Cursor); gl.Vertex(Cursor.X - weight, Center.Y, Cursor.Z); //Debug.Write("in 10111"); break; case 11011: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z + weight); drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z - weight); drawVertex(Cursor); gl.Vertex(Cursor.X - weight, Center.Y, Cursor.Z); // Debug.WriteLine(prime); break; case 11101: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z + weight); drawVertex(Cursor); gl.Vertex(Cursor.X + weight, Center.Y, Cursor.Z); drawVertex(Cursor); gl.Vertex(Cursor.X - weight, Center.Y, Cursor.Z); break; case 11110: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z + weight); drawVertex(Cursor); gl.Vertex(Cursor.X + weight, Center.Y, Cursor.Z); drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z - weight); break; case 10011: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z - weight); drawVertex(Cursor); gl.Vertex(Cursor.X - weight, Center.Y, Cursor.Z); break; case 11001: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z + weight); drawVertex(Cursor); gl.Vertex(Cursor.X - weight, Center.Y, Cursor.Z); break; case 11100: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z + weight); drawVertex(Cursor); gl.Vertex(Cursor.X + weight, Center.Y, Cursor.Z); break; case 10110: drawVertex(Cursor); gl.Vertex(Cursor.X + weight, Center.Y, Cursor.Z); drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z - weight); break; case 11010: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z + weight); drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z - weight); break; case 10101: drawVertex(Cursor); gl.Vertex(Cursor.X + weight, Center.Y, Cursor.Z); drawVertex(Cursor); gl.Vertex(Cursor.X - weight, Center.Y, Cursor.Z); break; case 10001: drawVertex(Cursor); gl.Vertex(Cursor.X - weight, Center.Y, Cursor.Z); break; case 10010: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z - weight); break; case 10100: drawVertex(Cursor); gl.Vertex(Cursor.X + weight, Center.Y, Cursor.Z); break; case 11000: drawVertex(Cursor); gl.Vertex(Cursor.X, Center.Y, Cursor.Z + weight); break; }//switch prime // gl.Vertex(DrawableCursor.X, Center.Y, DrawableCursor.Z); // Debug.WriteLine(DrawableCursor.X + " " + DrawableCursor.Y + " " + DrawableCursor.Z); // drawVertex(new Wektor(Center.Y, Center.Y, 0)); // Cursor.Y += 0.05f; // Debug.WriteLine(i / InitialSize); // Debug.WriteLine(Cursor.X + " " + Cursor.Z); // Debug.WriteLine(Xx + " "+ Yy); i++; } gl.End(); gl.PopMatrix(); /* for(int ii=0;ii<14;ii++) { Debug.WriteLine(" "); } */ }
private Wektor rotate_wektor(float centerX, float centerZ, float angle_in_degree, Wektor p) { float s = (float)Math.Sin(angle_in_degree); float c = (float)Math.Cos(angle_in_degree); // translate point back to origin: p.X-= centerX; p.Z -= centerZ; // rotate point float xnew = p.X * c - p.Z * s; float ynew = p.X * s + p.Z * c; // translate point back: p.X = xnew + centerX; p.Z = ynew + centerZ; return p; }
private Wektor RotateWektorOnZero(Wektor wek,float angle) { Wektor Pom; Pom = new Wektor(0, 0, 0); Pom.X = (float)(((wek.X ) * Math.Cos(ConvertToRadians(angle))) - (( wek.Z) * Math.Sin(ConvertToRadians(angle)))); Pom.Z = (float)((( wek.X) * Math.Sin(ConvertToRadians(angle))) + ((wek.Z ) * Math.Cos(ConvertToRadians(angle)))); return Pom; }
//soundtouch // // public void DrawCubo(float x1,float y1,float z1,float x2,float y2,float z2); public SharpGLForm() { Basic_Size = 17; MazeCellsIntTab= new int[Basic_Size][]; for (int j = 0; j < Basic_Size;j++ ) { MazeCellsIntTab[j] = new int[Basic_Size]; } ListaKolizji = new List<Wektor>(); ListaKolizjiX = new List<float>(); ListaKolizjiZ = new List<float>(); MazeCellType = new List<int>(); rysowM =new RysownikMaze(); StraightTrap = new TrapChecker(); // Sprawdzacz = new SprawdzaczKolizji(); MyMaze = rysowM.DrawMazeSkelethOfSize(25,true); MyMazeTwo = rysowM.DrawMazeSkelethOfSize(Basic_Size,false); first_time = false; tempMazeList = rysowM.ConvertMazeStructToListOfTypes(MyMazeTwo); for(int i=0;i<Basic_Size*Basic_Size;i++) { MazeCellsIntTab[i / Basic_Size][i % Basic_Size] = tempMazeList.ElementAt(i); } KeyA = false; KeyS = false; KeyD = false; KeyW=false; KeySpace=false; WektorZero = new Wektor(0, 0, 0); PlayerWektorSpeed = new Wektor(0, 0, 0); PlayerLive = 7; YAxisCamera = 5; CursorWektor = new Wektor(0, 0, 0); CursorWektorAngled = new Wektor(0, 0, 0); Debug.WriteLine("j"); Boss = new KwadratBoss(true); // new List<int>(); listaPociskow = new List<KwadratMaterialnyPocisk>(); listaPociskowPlayera = new List<KwadratMaterialnyPocisk>(); listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, new Wektor(0.1f, 0.0f, -0.13f), 22)); listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, new Wektor(0.09f, 0.0f, -0.03f), 22)); listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, new Wektor(-0.14f, 0.0f, -0.133f), 22)); for(int i=0 ; i<13 ; i++) { listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie,losowyWektorPredkosci(),20)); } cuboPlayer = new kwardratMaterialny(new Wektor(0.0f,0.0f,0.0f),new Wektor(0.0f,0.0f,0.0f),new Wektor(0.4f,0.4f,0.4f),new Wektor(0.2f,0.2f,0.2f),45); // Wektor temp,temp1; // temp = new Wektor(0.0f,0.0f,0.0f); // temp1 = new Wektor(0.2f,0.0f,-0.1f); bulletOne = new KwadratMaterialnyPocisk(new Wektor(0.0f, 0.0f, 0.0f),new Wektor(0.2f, 0.0f, 0.03f), 40); bulletOne = new KwadratMaterialnyPocisk(new Wektor(0.0f, 0.0f, 0.0f), 30); //bulletOne = new KwadratMaterialnyPocisk(temp, temp1, 30); // new KwadratMaterialnyPocisk() da = new Wektor(1.0f, 1.0f, 1.0f); // Wektor re; re = new Wektor(2.0f, 1.0f, 1.0f); InitializeComponent(); this.Controls.Add(openGLControl); // this. // openGLControl.KeyPress += openGLControl_KeyPress; this.openGLControl.KeyPress += new KeyPressEventHandler(keypressed); this.openGLControl.KeyDown += new KeyEventHandler(Form2_KeyDown); this.openGLControl.KeyUp += new KeyEventHandler(Form1_KeyUp); this.openGLControl.MouseClick += Control1_MouseClick; }
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { CursorWektor.X =-1 * ((float)Cursor.Position.X - 680) / 50; CursorWektor.Z = -1 * ((float)Cursor.Position.Y - 374) / 50; // double Angle = Math.Atan2(CursorWektor.Z, CursorWektor.X); double Angle = -45; CursorWektorAngled = rotate_wektor(0, 0, (float)Angle, CursorWektor); // CursorWektorAngled.X = CursorWektor.X * (float)Math.Sin(Angle -ConvertToRadians(90)); // CursorWektorAngled.Z = CursorWektor.Z * (float)Math.Cos(Angle -ConvertToRadians(90)); // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; rysow = new Rysownik(gl); rysowM.SetUpGl(gl); if (!first_time) { rysowM.DrawMazeFloor(tempMazeList, 1.0f, new Wektor(0, 0, 0)); if (rysowM.ListaPointowDoKolizji != null) { // Debug.Write("wwrsdsfsafasfa"); ListaKolizji = rysowM.ListaPointowDoKolizji; // ListaKolizjiX = rysowM.ListaXDoKolizji; // ListaKolizjiZ = rysowM.ListaZDoKolizji; } first_time = true; } Sprawdzacz = new SprawdzaczKolizji(rysow); // rysowM = new RysownikMaze(gl); // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // (x > 0 ? x : (2*PI + x)) * 360 / (2*PI) double AngleX; AngleX = CursorWektor.X; // if(CursorWektor.X<0){AngleX = (2*Math.PI + CursorWektor.X) * 360 / (2*Math.PI) ;} double AngleY; AngleY = CursorWektor.Z; // if (CursorWektor.Z < 0) { AngleY = (2 * Math.PI + CursorWektor.Z) * 360 / (2 * Math.PI); } Angle_between_wektor_X_Z(WektorZero, CursorWektor); // Load the identity matrix. gl.MatrixMode(OpenGL.GL_PROJECTION); // Load the identity. gl.LoadIdentity(); gl.Perspective(60.0f, 0, 0, 0); rysow.DrawLive(new Wektor(0.9f, -0.7f, 0), new Wektor(0.05f, 0.03f, 0f), PlayerLive); rysow.DrawLive(new Wektor(-0.9f, -0.7f, 0), new Wektor(0.05f, 0.04f, 0f), Boss.Live); // gl.DepthMask(0); // rysow.DrawCubo(0, 0, 0, 0.33f, 0.33f, 0.33f,0.0f,true,0.6f); // gl.DepthMask(1); gl.Enable(SharpGL.OpenGL.GL_SMOOTH); gl.Enable(SharpGL.OpenGL.GL_FLAT); // gl.Enable(SharpGL.OpenGL.GL_LINE_SMOOTH); // Create a perspective transformation. gl.Perspective(60.0f, (double)Width / (double)Height, 0.01, 100.0); // Use the 'look at' helper function to position and aim the camera. gl.LookAt(cuboPlayer.polozenie.X - 5, YAxisCamera, cuboPlayer.polozenie.Z - 5, cuboPlayer.polozenie.X, cuboPlayer.polozenie.Y, cuboPlayer.polozenie.Z, 0, 1, 0); // Rotate around the Y axis. float samesize= 2.3f; // =new Wektor(1.0, 1.0, 1.0); //Wektor re(1.0,1.0,1.0); /* for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskow[i].polozenie.X, listaPociskow[i].polozenie.Y, listaPociskow[i].polozenie.Z, listaPociskow[i].grubosci.X, listaPociskow[i].grubosci.Y, listaPociskow[i].grubosci.Z, (float)listaPociskow[i].angle + rotation, true,1.0f); } */ // list /* for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskowPlayera[i].polozenie.X, listaPociskowPlayera[i].polozenie.Y, listaPociskowPlayera[i].polozenie.Z, listaPociskowPlayera[i].grubosci.X, listaPociskowPlayera[i].grubosci.Y, listaPociskowPlayera[i].grubosci.Z, (float)listaPociskowPlayera[i].angle + rotation, true, 1.0f); } */ // rysow.DrawCubo(Boss.polozenie.X, Boss.polozenie.Y, Boss.polozenie.Z, // Boss.grubosci.X, Boss.grubosci.Y, Boss.grubosci.Z, 20,2); // rysow.draw_floor(); // rysowM.FinalDrawAllMazeByGl(MyMaze, new Wektor(0, 0, 0),(float)cuboPlayer.angle/15); // rysowM.FinalDrawAllMazeByGl(MyMazeTwo, new Wektor(-2, 0, -3), 0.5f); // rysowM.DrawMazyByListToSpeedUp(tempMazeList,new Wektor(2,0,0),0.02f); // rysowM.drawQuadFloor(new Wektor(1, 0, 1), 1f); // rysowM.drawQuadFloor(new Wektor(0,0,0),1.0f); rysowM.DrawMazeFloor(tempMazeList, 1.0f, new Wektor(0, 0, 0)); int Xo; int Yo; Coord tempCo = StraightTrap.in_what_coord(cuboPlayer.polozenie.X, cuboPlayer.polozenie.Z, 1.0f); Debug.Write(tempCo.x); Debug.Write(" y>"); Debug.WriteLine(tempCo.y); if( StraightTrap.is_three_cell_far(MazeCellsIntTab, tempCo.x, tempCo.y)) { Debug.WriteLine("buuummm"); } // + " y>" + cuboPlayer.polozenie.Z-1.0f); // gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY); // gl.VertexPointer(0,3,rysowM.ArrayVertex); // gl.VertexPointer() //glVertexPointer(3, GL_FLOAT, 0, vertices); // draw a cube // gl.DrawArrays(OpenGL.GL_LINES,0,rysowM.count/2); //glDrawArrays(GL_TRIANGLES, 0, 36); // deactivate vertex arrays after drawing //glDisableClientState(GL_VERTEX_ARRAY); // gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY); // gl.DrawArrays() // Debug.WriteLine(ListaKolizji.Count + " <out "); //mapka// rysowM.DrawMazyByListToSpeedUp(tempMazeList, cuboPlayer.polozenie, 0.22f); // Debug.Write(tempMazeList.Count.ToString() + " "); // rysowM.FinalDrawAllMazeByGl(MyMazeTwo, new Wektor(-5, 0, -5),1+(float)Math.Sin(rotation/10)); gl.Enable(SharpGL.OpenGL.GL_BLEND); gl.BlendFunc(SharpGL.OpenGL.GL_SRC_ALPHA,SharpGL.OpenGL.GL_ONE_MINUS_SRC_ALPHA); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); CursorWektor += cuboPlayer.polozenie; rysow.DrawCubo_with_alpha(CursorWektor.X, CursorWektor.Y, CursorWektor.Z, cuboPlayer.grubosci.X, cuboPlayer.grubosci.Y, cuboPlayer.grubosci.Z, rotation * 2,0.3f); CursorWektorAngled += cuboPlayer.polozenie; // rysow.DrawCubo_with_alpha(CursorWektorAngled.X, CursorWektorAngled.Y, CursorWektorAngled.Z, //// cuboPlayer.grubosci.X, // cuboPlayer.grubosci.Y * 3, cuboPlayer.grubosci.Z, (float)(1.5 * -1) * rotation, 0.3f); cuboPlayer.angle = -1f * Angle_between_wektor_X_Z(cuboPlayer.polozenie, CursorWektor); rysow.DrawPlayer(cuboPlayer.polozenie, cuboPlayer.grubosci, cuboPlayer.angle); // rysow.DrawCubo_with_alpha(CursorWektorAngled.X,CursorWektorAngled.Y,CursorWektorAngled.Z, // cuboPlayer.grubosci.X, // cuboPlayer.grubosci.Y*3, cuboPlayer.grubosci.Z, (float)(1.5 * -1) * rotation ,0.3f); Wektor AngleZeto; AngleZeto = new Wektor(120, 31200, 2130); // // trete //player config int hour_0_to_7; hour_0_to_7 = 900000; if (KeyW && !KeyA && !KeyD && !KeyS) { hour_0_to_7 = -1; } if (!KeyW && !KeyA && !KeyD && KeyS) { hour_0_to_7 = 4; } if (!KeyW && KeyA && !KeyD && !KeyS) { hour_0_to_7 = 6; } if (!KeyW && !KeyA && KeyD && !KeyS) { hour_0_to_7 = 2; } if (KeyA && KeyS && !KeyW) { hour_0_to_7 = 5; } if (KeyS && KeyD && !KeyW) { hour_0_to_7 = 3; } if (KeyD && KeyW) { hour_0_to_7 = 1; } if (KeyW && KeyA) { hour_0_to_7 = 7; } Wektor temp; temp = new Wektor(0.0f, 0.0f, 0.2f); if (Math.Abs(cuboPlayer.predkosc.X) < 0.2f && Math.Abs(cuboPlayer.predkosc.Z) < 0.2f) { switch (hour_0_to_7) { case -1: cuboPlayer.predkosc = RotateWektorOnZero(temp, 315); break; case 1: cuboPlayer.predkosc = temp; // cuboPlayer.predkosc.Z += 0.21f; // Debug.WriteLine(RotateWektorOnZero(temp, 45).X + " " + RotateWektorOnZero(temp, 45).Z); break; case 2: cuboPlayer.predkosc = RotateWektorOnZero(temp, 45); //cuboPlayer.predkosc.Z += RotateWektorOnZero(temp, 90).Z; // Debug.WriteLine(RotateWektorOnZero(temp, 90).X + " " + RotateWektorOnZero(temp, 90).Z); break; case 3: cuboPlayer.predkosc = RotateWektorOnZero(temp, 90); break; case 4: cuboPlayer.predkosc = RotateWektorOnZero(temp, 135); break; case 5: cuboPlayer.predkosc = RotateWektorOnZero(temp, 180); break; case 6: cuboPlayer.predkosc = RotateWektorOnZero(temp, 225); break; case 7: cuboPlayer.predkosc = RotateWektorOnZero(temp, 270); break; // default: // cuboPlayer.wycisz_predkosc_only_XZ_o(0.1f); } } cuboPlayer.wycisz_predkosc_only_XZ_o(0.01f); // if(Sprawdzacz.CzyNieKoliduje(ListaKolizji,1.0f,cuboPlayer.polozenie + cuboPlayer.predkosc)){ if (ListaKolizji != null) { // Debug.Write(ListaKolizji.Count); // Debug.Write("nie pusty"); if(Sprawdzacz.CzyNieKoliduje(ListaKolizji,0.5f,cuboPlayer.polozenie+cuboPlayer.predkosc)) { cuboPlayer.krok_naprzod(); } } //esle if (bulletOne != null) { bulletOne.krok_naprzod(); } Boss.krok_naprzod(); // foreach (KwadratMaterialnyPocisk prime in listaPociskow) // Loop through List with foreach. // { // prime.krok_naprzod(); // } for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { if (listaPociskow[i].vitality < 1) { listaPociskow.RemoveAt(i); } else { listaPociskow[i].krok_naprzod(); } } //foreach (KwadratMaterialnyPocisk prime in listaPociskowPlayera) // Loop through List with foreach. //{ // if (prime.vitality < 3) // { // listaPociskowPlayera.Remove(prime); // } // else // { // prime.krok_naprzod(); // } //} for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { if(czy_nachodza(listaPociskowPlayera[i].polozenie,Boss.polozenie,Boss.grubosci.X)) { Boss.Live--; // Debug.WriteLine("nachodza"); } if (listaPociskowPlayera[i].vitality < 3) { listaPociskowPlayera.RemoveAt(i); } else { listaPociskowPlayera[i].krok_naprzod(); } } if (cuboPlayer.polozenie.X < 2.0f * 16 * 3 && -5.5f + (2.0f * 16 * 3) < cuboPlayer.polozenie.Z && -5.5f + (2.0f * 16 * 3) < cuboPlayer.polozenie.X ) { ListaKolizji = new List<Wektor>(); ListaKolizjiX = new List<float>(); ListaKolizjiZ = new List<float>(); MazeCellType = new List<int>(); rysowM = new RysownikMaze(); // Sprawdzacz = new SprawdzaczKolizji(); MyMaze = rysowM.DrawMazeSkelethOfSize(25, true); MyMazeTwo = rysowM.DrawMazeSkelethOfSize(16, false); // tempMazeList = rysowM.ConvertMazeStructToListOfTypes(MyMazeTwo); cuboPlayer.polozenie = new Wektor(0, 0, 0); } if( cuboPlayer.polozenie.X > 2.0f * 16) { } if(Boss.counter%100 == 0) { Boss.Live--; if(Boss.Live==0) { cuboPlayer.polozenie = new Wektor(0, 0, 0); } listaPociskow = new List<KwadratMaterialnyPocisk>(); for (int i = 0; i < 13; i++) { listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, losowyWektorPredkosci(), 20)); } } // cuboOne.daj_kat_kwadrata(); // Nudge the rotation. rotation += 3.0f; Wektor inc; inc = new Wektor(0.01f, 0.0f, 0.0f); da += inc; re= re * 1.01f; if (bulletOne != null) { if (bulletOne.vitality < 0) { bulletOne = null; } } }
private Wektor losowyWektorPredkosci() { Wektor temp; lock (syncLock) { double x = random.NextDouble(); x -= 0.5; double y = random.NextDouble(); y = 0.0; double z = random.NextDouble(); z -= 0.5; temp = new Wektor((float)x, (float)y, (float)z); temp = temp * 0.5f; } return temp; }
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { CursorWektor.X =-1 * ((float)Cursor.Position.X - 680) / 50; CursorWektor.Z = -1 * ((float)Cursor.Position.Y - 374) / 50; // double Angle = Math.Atan2(CursorWektor.Z, CursorWektor.X); double Angle = -45; CursorWektorAngled = rotate_wektor(0, 0, (float)Angle, CursorWektor); // CursorWektorAngled.X = CursorWektor.X * (float)Math.Sin(Angle -ConvertToRadians(90)); // CursorWektorAngled.Z = CursorWektor.Z * (float)Math.Cos(Angle -ConvertToRadians(90)); // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; rysow = new Rysownik(gl); // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // (x > 0 ? x : (2*PI + x)) * 360 / (2*PI) double AngleX; AngleX = CursorWektor.X; // if(CursorWektor.X<0){AngleX = (2*Math.PI + CursorWektor.X) * 360 / (2*Math.PI) ;} double AngleY; AngleY = CursorWektor.Z; // if (CursorWektor.Z < 0) { AngleY = (2 * Math.PI + CursorWektor.Z) * 360 / (2 * Math.PI); } Angle_between_wektor_X_Z(WektorZero, CursorWektor); // Load the identity matrix. gl.MatrixMode(OpenGL.GL_PROJECTION); // Load the identity. gl.LoadIdentity(); gl.Perspective(60.0f, 0, 0, 0); rysow.DrawLive(new Wektor(0.9f, -0.7f, 0), new Wektor(0.05f, 0.03f, 0f), PlayerLive); rysow.DrawLive(new Wektor(-0.9f, -0.7f, 0), new Wektor(0.05f, 0.04f, 0f), Boss.Live); // gl.DepthMask(0); // rysow.DrawCubo(0, 0, 0, 0.33f, 0.33f, 0.33f,0.0f,true,0.6f); // gl.DepthMask(1); gl.Enable(SharpGL.OpenGL.GL_SMOOTH); gl.Enable(SharpGL.OpenGL.GL_FLAT); // gl.Enable(SharpGL.OpenGL.GL_LINE_SMOOTH); // Create a perspective transformation. gl.Perspective(60.0f, (double)Width / (double)Height, 0.01, 100.0); // Use the 'look at' helper function to position and aim the camera. gl.LookAt(cuboPlayer.polozenie.X - 5, YAxisCamera, cuboPlayer.polozenie.Z - 5, cuboPlayer.polozenie.X, cuboPlayer.polozenie.Y, cuboPlayer.polozenie.Z, 0, 1, 0); // Rotate around the Y axis. float samesize= 2.3f; // =new Wektor(1.0, 1.0, 1.0); //Wektor re(1.0,1.0,1.0); for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskow[i].polozenie.X, listaPociskow[i].polozenie.Y, listaPociskow[i].polozenie.Z, listaPociskow[i].grubosci.X, listaPociskow[i].grubosci.Y, listaPociskow[i].grubosci.Z, (float)listaPociskow[i].angle + rotation, true,1.0f); } // list for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskowPlayera[i].polozenie.X, listaPociskowPlayera[i].polozenie.Y, listaPociskowPlayera[i].polozenie.Z, listaPociskowPlayera[i].grubosci.X, listaPociskowPlayera[i].grubosci.Y, listaPociskowPlayera[i].grubosci.Z, (float)listaPociskowPlayera[i].angle + rotation, true, 1.0f); } rysow.DrawCubo(Boss.polozenie.X, Boss.polozenie.Y, Boss.polozenie.Z, Boss.grubosci.X, Boss.grubosci.Y, Boss.grubosci.Z, 20,2); rysow.draw_floor(); cuboPlayer.angle = -1f * Angle_between_wektor_X_Z(cuboPlayer.polozenie, CursorWektor); rysow.DrawPlayer(cuboPlayer.polozenie, cuboPlayer.grubosci, cuboPlayer.angle); gl.Enable(SharpGL.OpenGL.GL_BLEND); gl.BlendFunc(SharpGL.OpenGL.GL_SRC_ALPHA,SharpGL.OpenGL.GL_ONE_MINUS_SRC_ALPHA); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); rysow.DrawCubo_with_alpha(CursorWektor.X, CursorWektor.Y, CursorWektor.Z, cuboPlayer.grubosci.X, cuboPlayer.grubosci.Y, cuboPlayer.grubosci.Z, rotation * 2,0.3f); rysow.DrawCubo_with_alpha(CursorWektorAngled.X,CursorWektorAngled.Y,CursorWektorAngled.Z, cuboPlayer.grubosci.X, cuboPlayer.grubosci.Y*3, cuboPlayer.grubosci.Z, (float)(1.5 * -1) * rotation ,0.3f); //player config int hour_0_to_7; hour_0_to_7 = 900000; if (KeyW && !KeyA && !KeyD && !KeyS) { hour_0_to_7 = -1; } if (!KeyW && !KeyA && !KeyD && KeyS) { hour_0_to_7 = 4; } if (!KeyW && KeyA && !KeyD && !KeyS) { hour_0_to_7 = 6; } if (!KeyW && !KeyA && KeyD && !KeyS) { hour_0_to_7 = 2; } if (KeyA && KeyS && !KeyW) { hour_0_to_7 = 5; } if (KeyS && KeyD && !KeyW) { hour_0_to_7 = 3; } if (KeyD && KeyW) { hour_0_to_7 = 1; } if (KeyW && KeyA) { hour_0_to_7 = 7; } Wektor temp; temp = new Wektor(0.0f, 0.0f, 0.2f); if (Math.Abs(cuboPlayer.predkosc.X) < 0.2f && Math.Abs(cuboPlayer.predkosc.Z) < 0.2f) { switch (hour_0_to_7) { case -1: cuboPlayer.predkosc = RotateWektorOnZero(temp, 315); break; case 1: cuboPlayer.predkosc = temp; // cuboPlayer.predkosc.Z += 0.21f; Debug.WriteLine(RotateWektorOnZero(temp, 45).X + " " + RotateWektorOnZero(temp, 45).Z); break; case 2: cuboPlayer.predkosc = RotateWektorOnZero(temp, 45); //cuboPlayer.predkosc.Z += RotateWektorOnZero(temp, 90).Z; Debug.WriteLine(RotateWektorOnZero(temp, 90).X + " " + RotateWektorOnZero(temp, 90).Z); break; case 3: cuboPlayer.predkosc = RotateWektorOnZero(temp, 90); break; case 4: cuboPlayer.predkosc = RotateWektorOnZero(temp, 135); break; case 5: cuboPlayer.predkosc = RotateWektorOnZero(temp, 180); break; case 6: cuboPlayer.predkosc = RotateWektorOnZero(temp, 225); break; case 7: cuboPlayer.predkosc = RotateWektorOnZero(temp, 270); break; // default: // cuboPlayer.wycisz_predkosc_only_XZ_o(0.1f); } } cuboPlayer.wycisz_predkosc_only_XZ_o(0.01f); cuboPlayer.krok_naprzod(); if (bulletOne != null) { bulletOne.krok_naprzod(); } Boss.krok_naprzod(); // foreach (KwadratMaterialnyPocisk prime in listaPociskow) // Loop through List with foreach. // { // prime.krok_naprzod(); // } for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { if (listaPociskow[i].vitality < 1) { listaPociskow.RemoveAt(i); } else { listaPociskow[i].krok_naprzod(); } } //foreach (KwadratMaterialnyPocisk prime in listaPociskowPlayera) // Loop through List with foreach. //{ // if (prime.vitality < 3) // { // listaPociskowPlayera.Remove(prime); // } // else // { // prime.krok_naprzod(); // } //} for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { if(czy_nachodza(listaPociskowPlayera[i].polozenie,Boss.polozenie,Boss.grubosci.X)) { Boss.Live--; Debug.WriteLine("nachodza"); } if (listaPociskowPlayera[i].vitality < 3) { listaPociskowPlayera.RemoveAt(i); } else { listaPociskowPlayera[i].krok_naprzod(); } } if(Boss.counter%250 == 0) { listaPociskow = new List<KwadratMaterialnyPocisk>(); for (int i = 0; i < 13; i++) { listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, losowyWektorPredkosci(), 20)); } } // cuboOne.daj_kat_kwadrata(); // Nudge the rotation. rotation += 3.0f; Wektor inc; inc = new Wektor(0.01f, 0.0f, 0.0f); da += inc; re= re * 1.01f; if (bulletOne != null) { if (bulletOne.vitality < 0) { bulletOne = null; } } }
private void Control1_MouseClick(Object sender, MouseEventArgs e) { Wektor Temp; Temp = new Wektor(0.3f,0,0); float AngleTemp; AngleTemp = (float)Angle_between_wektor_X_Z(CursorWektor, cuboPlayer.polozenie); Temp = RotateWektorOnZero(Temp, AngleTemp); listaPociskowPlayera.Add(new KwadratMaterialnyPocisk(cuboPlayer.polozenie, Temp,cuboPlayer.angle,true)); }
public void DrawMazeFloorL(List<int> CellTypeList, float weight, Wektor Centrum) { int x; int y; int InitialSize = (int)Math.Sqrt((double)CellTypeList.Count); Wektor Cursor; Cursor = Centrum; // Cursor = new Wektor(Centrum.X - weight * 2 * InitialSize, Centrum.Y, Centrum.Z - weight * 2 * InitialSize); Wektor CursorMoved; CursorMoved = Cursor; for (int i = 0; i < CellTypeList.Count; i++) { CursorMoved = Cursor; drawQuadFloor(CursorMoved, weight); drawQuadFloorL(CursorMoved, weight); x = i / InitialSize; y = i % InitialSize; CursorMoved.X = x * 6 * weight; CursorMoved.Z = y * 6 * weight; Cursor.Y = 0.5f; switch (CellTypeList.ElementAt(i)) { case 11111: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; case 10111: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; case 11011: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; case 11101: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloor(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; case 11110: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); break; case 10011: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; case 11001: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; case 11100: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; case 11010: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); break; case 10110: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); break; case 10101: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloor(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; case 11000: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z + 2 * weight), weight); break; case 10100: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X + 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; case 10010: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X, CursorMoved.Y, CursorMoved.Z - 2 * weight), weight); break; case 10001: drawQuadFloor(CursorMoved, weight); drawQuadFloor(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); drawQuadFloorL(CursorMoved, weight); drawQuadFloorL(new Wektor(CursorMoved.X - 2 * weight, CursorMoved.Y, CursorMoved.Z), weight); break; } drawQuadFloor(CursorMoved, weight); drawQuadFloorL(CursorMoved, weight); } //drawQuadFloor(new Wektor(Cursor.X, Cursor.Y, Cursor.Z + weight * 2 ), weight); //drawQuadFloor(new Wektor(Cursor.X + weight * 2, Cursor.Y, Cursor.Z + weight * 2), weight); Is_list_fill = true; // Debug.WriteLine(ListaPointowDoKolizji.Count); }
public void drawQuadFloor(Wektor center,float weight) { // Wektor Cursor; gl.PushMatrix(); if (!Is_list_fill) { ListaPointowDoKolizji.Add(center); listaWectorow.Add(center); ListaPointowDoKolizji.Add(new Wektor(center.X + weight / 2,center.Y,center.Z)); ListaPointowDoKolizji.Add(new Wektor(center.X - weight / 2, center.Y, center.Z)); ListaPointowDoKolizji.Add(new Wektor(center.X, center.Y, center.Z + weight / 2)); ListaPointowDoKolizji.Add(new Wektor(center.X, center.Y, center.Z - weight / 2)); // ListaXDoKolizji.Add(center.X); // ListaZDoKolizji.Add(center.Z); } // gl.DepthMask(0); // gl.r gl.Begin(OpenGL.GL_LINES); float halfX; float halfY; float halfZ; // int count; count=0; halfX = weight/5; halfY = weight/5; halfZ = weight/5; Wektor kursor; kursor = new Wektor(center.X-weight, center.Y-0.5f, center.Z-weight); for (int i = 0; i < 10; i++) { if (i % 2 == 0) { gl.Color(0.6f, 0.6f, 0.6f, 0.5f); } else { gl.Color(0.4f, 0.4f, 0.4f, 0.5f); } gl.Vertex(kursor.X, kursor.Y, kursor.Z); // ArrayVertex[0]= kursor.X; gl.Vertex(kursor.X, kursor.Y, kursor.Z + weight*2); kursor.X += halfX; } gl.Vertex(kursor.X, kursor.Y, kursor.Z); gl.Vertex(kursor.X, kursor.Y, kursor.Z + weight*2); kursor = new Wektor(center.X-weight, center.Y-0.5f, center.Z-weight); for (int i = 0; i < 10; i++) { if (i % 2 == 0) { gl.Color(0.6f, 0.6f, 0.6f, 0.5f); } else { gl.Color(0.4f, 0.4f, 0.4f, 0.5f); } gl.Vertex(kursor.X, kursor.Y, kursor.Z); gl.Vertex(kursor.X + weight*2, kursor.Y, kursor.Z); kursor.Z += halfZ; } gl.Vertex(kursor.X, kursor.Y, kursor.Z); gl.Vertex(kursor.X + weight*2, kursor.Y, kursor.Z); // gl.DepthMask(0); gl.End(); gl.PopMatrix(); }
public void drawQuadFloor_withoutPut(Wektor center, float weight) { // Wektor Cursor; gl.PushMatrix(); gl.Begin(OpenGL.GL_LINES); float halfX; float halfY; float halfZ; halfX = weight / 5; halfY = weight / 5; halfZ = weight / 5; Wektor kursor; kursor = new Wektor(center.X - weight, center.Y - 0.5f, center.Z - weight); for (int i = 0; i < 10; i++) { if (i % 2 == 0) { gl.Color(0.6f, 0.6f, 0.6f, 0.5f); } else { gl.Color(0.4f, 0.4f, 0.4f, 0.5f); } gl.Vertex(kursor.X, kursor.Y, kursor.Z); // ArrayVertex[count++] = kursor.X; // ArrayVertex[count++] = kursor.Y; // ArrayVertex[count++] = kursor.Z; gl.Vertex(kursor.X, kursor.Y, kursor.Z + weight * 2); // ArrayVertex[count++] = kursor.X; // ArrayVertex[count++] = kursor.Y; // ArrayVertex[count++] = kursor.Z + weight * 2; kursor.X += halfX; } gl.Vertex(kursor.X, kursor.Y, kursor.Z); // ArrayVertex[count++] = kursor.X; // ArrayVertex[count++] = kursor.Y; // ArrayVertex[count++] = kursor.Z; gl.Vertex(kursor.X, kursor.Y, kursor.Z + weight * 2); // ArrayVertex[count++] = kursor.X; // ArrayVertex[count++] = kursor.Y; // ArrayVertex[count++] = kursor.Z + weight * 2; kursor = new Wektor(center.X - weight, center.Y - 0.5f, center.Z - weight); for (int i = 0; i < 10; i++) { if (i % 2 == 0) { gl.Color(0.6f, 0.6f, 0.6f, 0.5f); } else { gl.Color(0.4f, 0.4f, 0.4f, 0.5f); } gl.Vertex(kursor.X, kursor.Y, kursor.Z); // ArrayVertex[count++] = kursor.X; // ArrayVertex[count++] = kursor.Y; // ArrayVertex[count++] = kursor.Z; gl.Vertex(kursor.X + weight * 2, kursor.Y, kursor.Z); // ArrayVertex[count++] = kursor.X + weight * 2; // ArrayVertex[count++] = kursor.Y; // ArrayVertex[count++] = kursor.Z; kursor.Z += halfZ; } gl.Vertex(kursor.X, kursor.Y, kursor.Z); // ArrayVertex[count++] = kursor.X; // ArrayVertex[count++] = kursor.Y; // ArrayVertex[count++] = kursor.Z; gl.Vertex(kursor.X + weight * 2, kursor.Y, kursor.Z); // ArrayVertex[count++] = kursor.X + weight * 2; // ArrayVertex[count++] = kursor.Y; // ArrayVertex[count++] = kursor.Z; // gl.DepthMask(0); gl.End(); gl.PopMatrix(); }
public void krok_naprzod() { bool on_wall; on_wall = false; if (polozenie.X + predkosc.X > 5.0f) { predkosc.X = 0; on_wall = true; } if (polozenie.X + predkosc.X < -5.0f) { predkosc.X = 0; on_wall = true; } if (polozenie.Y + predkosc.Y > 6.0f) { predkosc.Y = 0; on_wall = true; } if (polozenie.Y + predkosc.Y < -6.0f) { predkosc.Y = 0; on_wall = true; } if (polozenie.Z + predkosc.Z > 6.0f) { predkosc.Z = 0; on_wall = true; } if (polozenie.Z + predkosc.Z < -6.0f) { predkosc.Z = 0; on_wall = true; } polozenie = polozenie + predkosc; if(counter % 30 == 0) { Random rand; rand = new Random(); double x = rand.NextDouble(); x -= 0.5; double y = rand.NextDouble(); y = 0.0; double z = rand.NextDouble(); z -= 0.5; Wektor temp; temp = new Wektor((float)x, (float)y, (float)z); temp = temp * 0.1f; predkosc = temp; } counter++; }
private bool czy_nachodza(Wektor first,Wektor secend,float margines) { if( secend.X < first.X + margines && secend.X > first.X - margines) { if( secend.Z < first.Z + margines && secend.Z > first.Z - margines) { return true; } } return false; }
public void draw_floor() { gl.PushMatrix(); // gl.DepthMask(0); // gl.r gl.Begin(OpenGL.GL_LINES); float halfX; float halfY; float halfZ; halfX = 0.25f; halfY = 0.25f; halfZ = 0.25f; Wektor kursor; kursor = new Wektor(-5.0f,-0.5f,-6.0f); for (int i = 0; i < 40; i++) { if (i % 2 == 0) { gl.Color(0.6f, 0.6f, 0.6f,0.5f); } else { gl.Color(0.4f, 0.4f, 0.4f,0.5f); } gl.Vertex(kursor.X, kursor.Y, kursor.Z); gl.Vertex(kursor.X, kursor.Y, kursor.Z + 12.0f); kursor.X += halfX; } gl.Vertex(kursor.X, kursor.Y, kursor.Z); gl.Vertex(kursor.X, kursor.Y, kursor.Z + 12.0f); kursor = new Wektor(-5.0f, -0.5f, -6.0f); for (int i = 0; i < 48; i++) { if (i % 2 == 0) { gl.Color(0.6f, 0.6f, 0.6f,0.5f); } else { gl.Color(0.4f, 0.4f, 0.4f,0.5f); } gl.Vertex(kursor.X, kursor.Y, kursor.Z); gl.Vertex(kursor.X+10.0f, kursor.Y, kursor.Z); kursor.Z += halfZ; } gl.Vertex(kursor.X, kursor.Y, kursor.Z); gl.Vertex(kursor.X + 10.0f, kursor.Y, kursor.Z); // gl.DepthMask(0); gl.End(); gl.PopMatrix(); }
public void drawVertex(Wektor temp) { gl.Vertex(temp.X, temp.Y, temp.Z); }
private double Angle_between_wektor_X_Z(Wektor first,Wektor secend) { //i x1 = 200, y1 = 150, x2 = 250, y2 = 170; //distance b/w them double X = first.X - secend.X; double Z = first.Z - secend.Z; // double X = Math.Pow((double)X, 2); // double Z = Math.Pow((double)Z, 2); // double d = Math.Abs(Math.Sqrt((double)X + (double)Z)); double angleInRadian = Math.Atan2((double)Z, (double)X); //angle in radian double angleInDegree = (angleInRadian * 180 / Math.PI); if (angleInDegree < 0) { angleInDegree += 360; } // Debug.WriteLine(angleInDegree); return angleInDegree; }
public void FinalDrawAllMazeByGl(MazeStruct MazeTemp,Wektor Center,float Weight_of_cell) { int x; int target_x; int target_y; float weight; float weight_with_size; weight = Weight_of_cell; int y; Wektor Cursor; Wektor DrawableCursor; //Cursor = Center; weight_with_size = weight * MazeTemp.SizeOfMaze; Cursor = new Wektor(Center.X - (weight_with_size / 2), Center.Y - (weight_with_size / 2), Center.Z - (weight_with_size / 2)); DrawableCursor = Cursor; int InitialSize = (int)Math.Sqrt( (double)MazeTemp.SizeOfMaze); gl.PushMatrix(); gl.Begin(OpenGL.GL_LINES); gl.Color(0.44f, 0.44f, 0.44f); for(int i = 0;i < MazeTemp.SizeOfMaze;i++) { x = i / InitialSize; y = i % InitialSize; DrawableCursor.X = Cursor.X+ ( x * weight); DrawableCursor.Z = Cursor.Z + (y * weight); var temp = MazeTemp.TableOfMazes.Find(r => (r.VertexNumber == i)); // Debug.Write(i); // Debug.WriteLine(temp.Neigboors.Count + " nawet raz nei jest pusty"); foreach (int vertex in temp.Neigboors) { // Debug.Write(" >>>" + vertex); target_x = vertex / InitialSize; //awesome schiz // target_y = vertex / InitialSize; target_y = vertex % InitialSize; // gl.Color(0.57f, 0.52f, 0.59f); // gl.Vertex(DrawableCursor.X, Center.Y, DrawableCursor.Z); // gl.Vertex(Cursor.X, Cursor.Y, Cursor.Z); // gl.Vertex(Cursor.X + (target_x * weight), 0 , Cursor.Z + (target_y * weight)); gl.Vertex(Center.X+ (target_x* weight ), Center.Y, Center.Z + (target_y * weight)); gl.Vertex(Center.X + (x * weight),Center.Y,Center.Z + (y * weight)); } // Debug.WriteLine(" "); // temp.Neigboors.Add(TempEdge.Dest()); } gl.End(); gl.PopMatrix(); }