Sorry I'm always worried about posting loads of code.
As far as I can see I have included the headers required
My full Enviroment header is
#pragma once#include <windows.h> // Header File For Windows#include <gl\gl.h> // Header File For The OpenGL32 Library#include <gl\glu.h> // Header File For The GLu32 Library#include "tgaload.h"#include "console.h"#include "Collision.h"#include "Boat_Pos.h"class Boat_Pos;class Enviroment{public: struct Wall{ float X1; float Z1; float X2; float Z2;}; //struct that holds walls normalsstruct NormalArray{ float X1; float Y1; float Z1; float X2; float Y2; float Z2;};struct NormalizedWall{ float X; float Y; float Z;}; //function prototype static Wall WallPos(float wallPosition[]); static NormalArray GetNormal(float xNormal1,float yNormal1,float zNormal1,float xNormal2,float yNormal2,float zNormal2); void drawWater(int StartXwater, int StartYwater, int StartZwater, int EndXwater, int EndYWater, int EndZWater, int waterPosition); static void drawWall(float wallPosition[],Boat_Pos playerBoat); static float * initArray(float wallArray[]); static void InitiliseEnviroment(float wallPosition[]); //static Enviroment::NormalizedWall InitiliseEnviroment(float wallPosition[]); GLuint water; GLuint wall;private:};
My full header for my Collsion is
#pragma once#include <windows.h> // Header File For Windows#include <gl\gl.h> // Header File For The OpenGL32 Library#include <gl\glu.h> // Header File For The GLu32 Library#include "console.h"#include "Boat_Pos.h"#include "Calculation.h"#include "Enviroment.h"class Boat_Pos;class Enviroment;static class Collision{public: Collision(){} ~Collision(){} void DrawSphere(int x1,int z2, int radius); static void DrawBox(int posX1, int PosX2, int posY1, int posY2, int posZ1, int posZ2);//draw bounding boxes static bool BoundingBox(float wall[],Boat_Pos playerBoat);//check bounding collision int boxPos(int posX1, int posX2,int posZ1,int posZ2);//calculate box position static double DotProduct(int Value1X, int Value2X,int Value1Y, int Value2Y, int Value1Z, int Value2Z); double CrossProduct(double U1, double V1, double U2, double V2, double U3, double V3); //were problem is static float * CalculateNormal(Enviroment::NormalArray wallToCalculate); static void NormaliseNormal(float normalArray[],float corner[]); static float PointToPlaneTest(Boat_Pos player,float pointOnPlane[],float normalValues[]); static float PlaneEquation(float point1[],float point2[], float point3[],float point[]); static bool BarryCentricEquation(float triA[],float triB[], float triC[],float point[]); double posX1; double posX2; double posY1; double posY2; double posZ1; double posZ2; bool collision; bool bccCollision; float dist; //static float normal[3]; private:};
This is where my error is occouring
I am actucally running it in my Enviroment class cpp file
#include "Enviroment.h"Enviroment::Wall Enviroment::WallPos(float wallPosition[]){ Wall wall; wall.X1 = wallPosition[0]; wall.Z1 = wallPosition[1]; wall.X2 = wallPosition[2]; wall.Z2 = wallPosition[3]; std::cout<<"this is my struct "<<wall.X1<<std::endl; std::cout<<"this is my struct "<<wall.Z1<<std::endl; std::cout<<"this is my struct "<<wall.X2<<std::endl; std::cout<<"this is my struct "<<wall.Z2<<std::endl; return wall;};Enviroment::NormalArray Enviroment::GetNormal(float xNormal1,float yNormal1,float zNormal1,float xNormal2,float yNormal2,float zNormal2){ NormalArray wallNormal; wallNormal.X1 = xNormal1; wallNormal.Y1 = yNormal1; wallNormal.Z1 = zNormal1; wallNormal.X2 = xNormal2; wallNormal.Y2 = yNormal2; wallNormal.Z2 = zNormal2; return wallNormal;}void Enviroment::drawWater(int StartXwater, int StartYwater, int StartZwater, int EndXwater, int EndYWater, int EndZWater, int waterPosition){ if(waterPosition == 0) { water = tgaLoadAndBind("waterr.tga", TGA_ALPHA); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT); glBindTexture(GL_TEXTURE_2D, water); glPushMatrix(); glBegin(GL_POLYGON); glTexCoord2f(0,0); glVertex3f(StartXwater, 0, StartZwater); glTexCoord2f(50,0);glVertex3f(EndXwater, 0, StartZwater); glTexCoord2f(50,100);glVertex3f(EndXwater, 0, EndZWater); glTexCoord2f(0,100);glVertex3f(StartXwater, 0, EndZWater); glEnd(); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glPopMatrix(); } if(waterPosition == 1) { water = tgaLoadAndBind("waterr.tga", TGA_ALPHA); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT); glBindTexture(GL_TEXTURE_2D, water); glPushMatrix(); glBegin(GL_POLYGON); glTexCoord2f(0,0); glVertex3f(StartXwater, 0, StartZwater); glTexCoord2f(0,300);glVertex3f(EndXwater, 0, StartZwater); glTexCoord2f(100,300);glVertex3f(EndXwater, 0, EndZWater); glTexCoord2f(100,0);glVertex3f(StartXwater, 0, EndZWater); glEnd(); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glPopMatrix(); }}void Enviroment::drawWall(float wallPosition[], Boat_Pos playerBoat){ glPushMatrix(); glBegin(GL_POLYGON); glColor3f(0.7,0.7,0.7); glTexCoord2f(0,0); glVertex3f(wallPosition[0], 0, wallPosition[1]); glTexCoord2f(1,0); glVertex3f(wallPosition[0], 3, wallPosition[1]); glTexCoord2f(1,1); glVertex3f(wallPosition[2], 3, wallPosition[3]); glTexCoord2f(0,1); glVertex3f(wallPosition[2], 0, wallPosition[3]);glEnd(); }void Enviroment::InitiliseEnviroment(float wallPosition[]){ Enviroment::Wall wallToNormalise = Enviroment::WallPos(wallPosition); std::cout<<"Wall Position 1 is "<<wallToNormalise.X1<<std::endl; std::cout<<"Wall Position 2 is "<<wallToNormalise.Z1<<std::endl; std::cout<<"Wall Position 3 is "<<wallToNormalise.X2<<std::endl; std::cout<<"Wall Position 4 is "<<wallToNormalise.Z2<<std::endl; Enviroment::NormalArray wallNormal; /*wallNormal.X1 = wallToNormalise.X1; wallNormal.Z1 = wallToNormalise.Z1; wallNormal.X2 = wallToNormalise.X2; wallNormal.Z2 = wallToNormalise.Z2;*/ //this is where I am using my collision Collision::CalculateNormal(wallNormal);}
If you would like any further code please let me know. I am only using the code in this section though. This is being called in the init() function in the main.