Exemple #1
0
MojErr MojDbKindState::readIds(const MojChar* key, MojDbReq& req, MojObject& objOut, MojRefCountedPtr<MojDbStorageItem>& itemOut)
{
	MojErr err = readObj(key, objOut, m_kindEngine->indexIdDb(), req.txn(), itemOut);
	MojErrCheck(err);

	return MojErrNone;
}
Exemple #2
0
Mesh::Mesh(const string &file)
    : scale(1.)
{
    int i;
#define OUT { vertices.clear(); edges.clear(); return; }
    ifstream obj(file.c_str());
    
    if(!obj.is_open()) {
        Debugging::out() << "Error opening file " << file << endl;
        return;
    }
    
    Debugging::out() << "Reading " << file << endl;
    
    if(file.length() < 4) {
        Debugging::out() << "I don't know what kind of file it is" << endl;
        return;
    }
    
    if(string(file.end() - 4, file.end()) == string(".obj"))
        readObj(obj);
    else if(string(file.end() - 4, file.end()) == string(".ply"))
        readPly(obj);        
    else if(string(file.end() - 4, file.end()) == string(".off"))
        readOff(obj);        
    else if(string(file.end() - 4, file.end()) == string(".gts"))
        readGts(obj);
    else if(string(file.end() - 4, file.end()) == string(".stl"))
        readStl(obj);        
    else {
        Debugging::out() << "I don't know what kind of file it is" << endl;
        return;
    }
    
    //reconstruct the rest of the information
    int verts = vertices.size();
    
    if(verts == 0)
        return;
    
    for(i = 0; i < (int)edges.size(); ++i) { //make sure all vertex indices are valid
        if(edges[i].vertex < 0 || edges[i].vertex >= verts) {
            Debugging::out() << "Error: invalid vertex index " << edges[i].vertex << endl;
            OUT;
        }
    }
    
    fixDupFaces();
    
    computeTopology();
    
    if(integrityCheck())
        Debugging::out() << "Successfully read " << file << ": " << vertices.size() << " vertices, " << edges.size() << " edges" << endl;
    else
        Debugging::out() << "Somehow read " << file << ": " << vertices.size() << " vertices, " << edges.size() << " edges" << endl;
    
    computeVertexNormals();
}
Exemple #3
0
Model::Model(string filename)
{
	readObj(filename);

	orientPoints();
	computeBounds();
	normalize();
	findPointSizes();
}
Exemple #4
0
MojErr MojDbKindState::initTokens(MojDbReq& req, const StringSet& strings)
{
	// TODO: bug inside this function. (latest strace step)
	MojAssertMutexLocked(m_lock);

	// TODO: filing load tokens. Go inside readObj
	// load tokens
	MojErr err = readObj(TokensKey, m_tokensObj, m_kindEngine->kindDb(), req.txn(), m_oldTokensItem);
	MojErrCheck(err);

	// populate token vec
	MojUInt8 maxToken = 0;
	err = m_tokenVec.resize(m_tokensObj.size());
	MojErrCheck(err);
	for (MojObject::ConstIterator i = m_tokensObj.begin(); i != m_tokensObj.end(); ++i) {
		MojString key = i.key();
		MojInt64 value = i.value().intValue();
		MojSize idx = (MojSize) (value - MojObjectWriter::TokenStartMarker);
		if (value < MojObjectWriter::TokenStartMarker || value >= MojUInt8Max || idx >= m_tokenVec.size()) {
			MojErrThrow(MojErrDbInvalidToken);
		}
		if (value > maxToken) {
			maxToken = (MojUInt8) value;
		}
		err = m_tokenVec.setAt(idx, key);
		MojErrCheck(err);
	}
	if (maxToken > 0) {
		m_nextToken = (MojUInt8) (maxToken + 1);
	}

	// add strings
	bool updated = false;
	for (StringSet::ConstIterator i = strings.begin(); i != strings.end(); ++i) {
		if (!m_tokensObj.contains(*i)) {
			updated = true;
			MojUInt8 token = 0;
			TokenVec tokenVec;
			MojObject tokenObj;
			err = addPropImpl(*i, false, token, tokenVec, tokenObj);
			MojErrCheck(err);
		}
	}
	if (updated) {
		err = writeTokens(m_tokensObj);
		MojErrCheck(err);
	}
	return MojErrNone;
}
Exemple #5
0
Objecte::Objecte(int npoints, QString n) : numPoints(npoints)
{
    points = new point4[npoints];
    colors = new color4[npoints];
    vertexsTextura = new vec2[npoints];
    std::cout<<"Estic en el constructor parametritzat del objecte\n";

    xRot = 0;
    yRot = 0;
    zRot = 0;

    Index = 0;

    readObj(n);

    make();

}
Exemple #6
0
//<<<<<<<<<<<<<<<<<<<<<<<<<<<< readMesh >>>>>>>>>>>>>>>>>>>>>>>>
void Mesh::readMesh(string fname)
{
	int pch;
	if (strstr(fname.c_str(), ".obj") != 0){
		cout << "filename = " << fname << endl;
		readObj(fname);
	}
	else{
		fstream inStream;
		inStream.open(fname.c_str(), ios::in); //open needs a c-like string


		if (inStream.fail() || inStream.eof())
		{
			cout << "can't open file or eof: " << fname << endl;
			makeEmpty(); return;
		}
		inStream >> numVerts >> numNorms >> numFaces;
		// make arrays for vertices, normals, and faces
		pt = new Point3[numVerts];        assert(pt != NULL);
		norm = new Vector3[numNorms];     assert(norm != NULL);
		face = new Face[numFaces];        assert(face != NULL);
		for (int i = 0; i < numVerts; i++) 	// read in the vertices
			inStream >> pt[i].x >> pt[i].y >> pt[i].z;
		for (int ii = 0; ii < numNorms; ii++) 	// read in the normals
			inStream >> norm[ii].x >> norm[ii].y >> norm[ii].z;
		for (int f = 0; f < numFaces; f++)   // read in face data
		{
			inStream >> face[f].nVerts;


			int n = face[f].nVerts;
			face[f].vert = new VertexID[n]; assert(face[f].vert != NULL);
			for (int k = 0; k < n; k++) 		// read vertex indices for this face
				inStream >> face[f].vert[k].vertIndex;
			for (int kk = 0; kk < n; kk++) 		// read normal indices for this face
				inStream >> face[f].vert[kk].normIndex;
		}



		inStream.close();
	}
} // end of readMesh
Exemple #7
0
int
openObj (char *filename, objObj * obj)
{
	nameIndex *mtlIndex;
	nameIndex *texIndex;

	FILE *obj_fp = NULL;
	FILE *mtl_fp = NULL;

	mtlIndex = NULL;
	texIndex = NULL;

	obj->nbVertex = 0;
	obj->nbNormal = 0;
	obj->nbTexcoord = 0;
	obj->nbFace = 0;
	obj->nbMaterial = 0;

	obj->vertexList = NULL;
	obj->normalList = NULL;
	obj->texcoordList = NULL;
	obj->faceList = NULL;
	obj->materialList = NULL;



	if (initObj (filename, obj, &obj_fp, &mtl_fp, &mtlIndex, &texIndex))
		return cleanBeforeExit (1, obj, obj_fp, mtl_fp, mtlIndex,
					texIndex);

	if (readMtl (mtl_fp, *obj, mtlIndex, texIndex))
		return cleanBeforeExit (1, obj, obj_fp, mtl_fp, mtlIndex,
					texIndex);

	if (readObj (obj_fp, *obj, mtlIndex))
		return cleanBeforeExit (1, obj, obj_fp, mtl_fp, mtlIndex,
					texIndex);


	return cleanBeforeExit (0, obj, obj_fp, mtl_fp, mtlIndex, texIndex);
}
Exemple #8
0
int main( int argc, char *argv[] )
{
	if( argc != 4 )
	{
		printf("Expected 3 arguments, two input and one output filenames.\n");
		printf("Usage example '%s manny.3do updated.obj manny.3do'\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	//read in the .3do file
	MODL *m = read3do(argv[1]);
	if(m == NULL)
	{
		fprintf(stderr, "Failed to read in .3do file %s\n", argv[1]);
		exit(EXIT_FAILURE);
	}

	//read in the .obj file which will update the .3do
	OBJ *o = readObj(argv[2]);
	if(o == NULL)
	{
		fprintf(stderr, "Failed to read in .obj file %s\n", argv[2]);
		exit(EXIT_FAILURE);
	}

	//JOIN EM
	update3do(m, o);

	//write it out
	write3do(m, argv[3]);



	//free memory
	freeMODL(m);

	//no free functions for the obj end of things yet
	//not really needed 

	exit(EXIT_SUCCESS);
}
Exemple #9
0
Objecte::Objecte(int npoints, QString n, GLdouble tamanio, GLdouble x0, GLdouble y0, GLdouble z0, double girx, double giry, double girz) : numPoints(npoints)
{
    points = new point4[npoints];
    colors = new color4[npoints];
    tam = tamanio;
    xorig = x0;
    yorig = y0;
    zorig = z0;

    xRot = girx;
    yRot = giry;
    zRot = girz;


    nom = n;
    Index = 0;

    readObj(n);

    make();

}
Exemple #10
0
namespace scene
{
    // Primitives

    // Left Wall
    const Triangle leftWallA{{0, 0, 0}, {0, 100, 0}, {0, 0, 150}};
    const Triangle leftWallB{{0, 100, 150}, {0, 0, 150}, {0, 100, 0}};

    // Right Wall
    const Triangle rightWallA{{100, 0, 0}, {100, 0, 150}, {100, 100, 0}};
    const Triangle rightWallB{{100, 100, 150}, {100, 100, 0}, {100, 0, 150}};

    // Back wall
    const Triangle backWallA{{0, 0, 0}, {100, 0, 0}, {100, 100, 0}};
    const Triangle backWallB{{0, 0, 0}, {100, 100, 0}, {0, 100, 0}};

    // Bottom Floor
    const Triangle bottomWallA{{0, 0, 0}, {100, 0, 150}, {100, 0, 0}};
    const Triangle bottomWallB{{0, 0, 0}, {0, 0, 150}, {100, 0, 150}};

    // Top Ceiling
    const Triangle topWallA{{0, 100, 0}, {100, 100, 0}, {0, 100, 150}};
    const Triangle topWallB{{100, 100, 150}, {0, 100, 150}, {100, 100, 0}};

    const Sphere leftSphere{16.5, glm::vec3 {27, 16.5, 47}};
    const Sphere rightSphere{16.5, glm::vec3 {73, 16.5, 78}};

    const Box box{glm::vec3{30,0,30}, glm::vec3{70,40,70}};

    const MeshBoxes meshb = readObj(glm::vec3{50, 0, 50}, "../Beautiful Girl.obj");

    const glm::vec3 light{50, 70, 81.6};

    // Materials
    const Diffuse white{{.75, .75, .75}};
    const Diffuse red{{.75, .25, .25}};
    const Diffuse blue{{.25, .25, .75}};
    const Diffuse green{{.25, .75, .25}};

    const Glass glass{{1, 1, 1}};
    const Mirror mirror{{1, 1, 1}};


    // Objects
    // Note: this is a rather convoluted way of initialising a vector of unique_ptr ;)
    const std::vector<std::unique_ptr<Object>> objects = [] (){
        std::vector<std::unique_ptr<Object>> ret;
        ret.push_back(makeObject(backWallA, white));
        ret.push_back(makeObject(backWallB, white));
        ret.push_back(makeObject(topWallA, white));
        ret.push_back(makeObject(topWallB, white));
        ret.push_back(makeObject(bottomWallA, white));
        ret.push_back(makeObject(bottomWallB, white));
        ret.push_back(makeObject(rightWallA, blue));
        ret.push_back(makeObject(rightWallB, blue));
        ret.push_back(makeObject(leftWallA, red));
        ret.push_back(makeObject(leftWallB, red));
        ret.push_back(makeObject(meshb, green));
        //ret.push_back(makeObject(box, white));

        ret.push_back(makeObject(leftSphere, mirror));
        ret.push_back(makeObject(rightSphere, glass));

        return ret;
    }();
}
Exemple #11
0
MeshObject::MeshObject(const char* filename)
{
    readObj(filename);

}
Exemple #12
0
int main(int argc, char**argv){


  std::vector<double> vertices, BBmin, BBmax;
  std::vector<unsigned> triangles;

  if(!readObj(argv[1], vertices, triangles, BBmin, BBmax)){
    std::cout << "couldn't read OBJ" << std::endl;
    exit(1);
  }

  std::cout << "bbmin: " << BBmin[0] << " " << BBmin[1] << " " << BBmin[2] << std::endl;
  std::cout << "bbmax: " << BBmax[0] << " " << BBmax[1] << " " << BBmax[2] << std::endl;

  for(auto i : range(vertices.size()/3)){
    vertices[3*i + 1] += 5;
  }

  std::cout << "vertices size: " << vertices.size() << std::endl;

  
  std::set<Edge> edgesSet;

  for(auto i : range(triangles.size()/3)){

    auto t = 3*i;

    for( auto j : range(3)){
      auto e1 = triangles[t + j];
      auto e2 = triangles[t + ((j +1)%3)];

      if( e2 < e1){
	std::swap(e1, e2);
      }

      auto e = Edge(e1, e2, triangles[t + ((j + 2)%3)]);
      auto it = edgesSet.find(e);

      if(it == edgesSet.end()){
	edgesSet.insert(it, e);
      } else {
	e.t2 = it->t1;
	edgesSet.erase(it);
	edgesSet.insert(e);
	
      }

    }
  }





  std::vector<Edge> edges(edgesSet.begin(), edgesSet.end());

  //  for(const auto& e : edges){
  // std::cout << "e1: " << e.e1 << " e2: " << e.e2 << " t1 " << e.t1 << " t2 : " << e.t2 << " e length " << e.edgeLength << " d length : " << e.dihedralLength << std::endl;
  // }

  std::cout << "about to set edge lengths" << std::endl;

  for(auto& e : edges){
    e.edgeLength = l2Norm(vertices.begin() + 3*e.e1,
			  vertices.begin() + 3*e.e2);
    
    if(e.t1 < vertices.size() && e.t2 < vertices.size()){
      e.dihedralLength = l2Norm(vertices.begin() + 3*e.t1,
				vertices.begin() + 3*e.t2);
    }
  }

  //for(auto i : range (vertices.size()/3)){
  //  std::cout << "vertex: " << i << " " << vertices[i*3] << " " << vertices[i*3 + 1] << " " << vertices[i*3 + 2] << std::endl;
  // }

  //for(const auto& e : edges){
  // std::cout << "e1: " << e.e1 << " e2: " << e.e2 << " t1 " << e.t1 << " t2 : " << e.t2 << " e length " << e.edgeLength << " d length : " << e.dihedralLength << std::endl;
  //}


  std::cout << "computed edge rest lengths" << std::endl;

  if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
    std::cout << "couldn't init SDL" << std::endl;
    exit(1);
  }
  
  if((surface = SDL_CreateWindow("3.2", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,                
				 800, 600, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN)) == NULL){
    std::cout << "couldn't create SDL surface" << std::endl;
    exit(1);
  }

  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  auto* context = SDL_GL_CreateContext(surface);




  double dt = atof(argv[2]);
  
  std::cout << "about to loop" << std::endl;

  simulationLoop(vertices, edges, dt);
  

  return 0;
}
Exemple #13
0
StaticObj::StaticObj(const char* objFile)
{
  FILE *f = fopen(objFile, "r");
  if(f == NULL){
    std::cout<<"Error reading static object's main file";
    return;
  }
  char line[100];
  char filename[60];
  char textureFilename[60];
  
  while(fgets(line, 100, f)){
    if(line[0] != '#'){
      object comp;
      sscanf(line, "name=%s", comp.name);
      fgets(line, 100, f);
      sscanf(line, "filename=%s", filename);
      std::cout<<filename<<std::endl;
      fgets(line, 100, f);
      sscanf(line, "texture=%s", textureFilename);
      std::cout<<textureFilename<<std::endl;
      loadTexture(textureFilename, comp);
      readObj(filename, comp);
      fgets(line, 100, f);
      sscanf(line, "pozX=%f", &comp.location.x);
      fgets(line, 100, f);
      sscanf(line, "pozY=%f", &comp.location.y);
      fgets(line, 100, f);
      sscanf(line, "pozZ=%f", &comp.location.z);

      fgets(line, 100, f);
      sscanf(line, "angle=%f", &comp.angle);
      fgets(line, 100, f);
      sscanf(line, "rotX=%f", &comp.rotation.x);
      fgets(line, 100, f);
      sscanf(line, "rotY=%f", &comp.rotation.y);
      fgets(line, 100, f);
      sscanf(line, "rotZ=%f", &comp.rotation.z);

      fgets(line, 100, f);
      sscanf(line, "scaleX=%f", &comp.scaling.x);
      fgets(line, 100, f);
      sscanf(line, "scaleY=%f", &comp.scaling.y);
      fgets(line, 100, f);
      sscanf(line, "scaleZ=%f", &comp.scaling.z);
      fgets(line, 100, f);
      sscanf(line, "boundingbox=%s", filename);
      comp.setBoundingBox(filename);
      if(strcmp(comp.name, "sentinel") == 0){
        Vector3 aux_loc;
        aux_loc.x = 303.0f;
        aux_loc.y = -6.0f;
        aux_loc.z = -388.0f;
        comp.duplicates.push_back(aux_loc);
      }
      if(strcmp(comp.name, "grass") == 0){
        Vector3 aux_loc;

        for(int i = 0; i < 100; i++){
          aux_loc.x = (rand() % 1000) - 500;
          aux_loc.z = (rand() % 800) - 400;
          comp.duplicates.push_back(aux_loc);
        }
        
      }
      components.push_back(comp);
    }
    if(line[0] == '\n')
      break;
  }
  fclose(f);
}
Exemple #14
0
void storeData() {
	indicies = new GLuint[getIndiciesSize()];
	objData = new GLfloat[5000000];
	readObj();
	getFinalSize();
	//std::cout << getFinalSize() << std::endl;


	//isize = 34695; //boat
	//isize = 22338; //plane
	//isize = 2901; //monkey
	//isize = 36;

	//for (int i = 0; i < 100; i++) std::cout << indicies[i];

	for (int i = 0; i < isize; i++) {

		finalData[i * 8] = objData[(indicies[i]) * 3];
		finalData[i * 8 + 1] = objData[(indicies[i]) * 3 + 1]; //multiply shit by model matrix. stupid model matrix.
		finalData[i * 8 + 2] = objData[(indicies[i]) * 3 + 2];
	}
	for (int i = 0; i < vsize; i += 8) {
		finalData[i + 6] = textureCoords[tc++];
		finalData[i + 7] = textureCoords[tc++];

		if (i % 24 == 0) { //problem here, if last 2 triangles dont divide into 3 triangles, duh stupid.
			glm::vec3 v0 = glm::vec3(finalData[i], finalData[i + 1], finalData[i + 2]);
			glm::vec3 v1 = glm::vec3(finalData[i + 8], finalData[i + 9], finalData[i + 10]);
			glm::vec3 v2 = glm::vec3(finalData[i + 16], finalData[i + 17], finalData[i + 18]);
			//glm::vec3 normal = glm::cross((v0 - v1), (v0 - v2));
			glm::vec3 normal = glm::cross((v1 - v0), (v2 - v0));

			//glm::vec3 normal = glm::cross((v0 - v2), (v0 - v1));

			finalData[i + 3] = normal.x;
			finalData[i + 4] = normal.y;
			finalData[i + 5] = normal.z;

			finalData[i + 11] = normal.x;
			finalData[i + 12] = normal.y;
			finalData[i + 13] = normal.z;

			finalData[i + 19] = normal.x;
			finalData[i + 20] = normal.y;
			finalData[i + 21] = normal.z;


			normal = glm::normalize(normal) * 1.0f;
			GLfloat avgX = (v0.x + v1.x + v2.x) / 3;
			GLfloat avgY = (v0.y + v1.y + v2.y) / 3;
			GLfloat avgZ = (v0.z + v1.z + v2.z) / 3;

			normals[nindex] = avgX;
			normals[nindex + 1] = avgY;
			normals[nindex + 2] = avgZ;
			normals[nindex + 3] = normal.x + avgX;
			normals[nindex + 4] = normal.y + avgY;
			normals[nindex + 5] = normal.z + avgZ;
			nindex += 6;

		}
	}


	glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);

	glGenBuffers(1, &buffer);
	glBindBuffer(GL_ARRAY_BUFFER, buffer);
	glBufferData(GL_ARRAY_BUFFER, vsize * sizeof(GLfloat), finalData, GL_STATIC_DRAW);

	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid*)0);
	glEnableVertexAttribArray(0);


	glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
	glEnableVertexAttribArray(2);

	glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid*)(6 * sizeof(GLfloat)));
	glEnableVertexAttribArray(3);
	
	
	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_2D, texture);
	int width, height;
	unsigned char* image = SOIL_load_image("C:\\Users\\Sanjiv\\Desktop\\charizard-pokemon-go-obj (1)\\lizardon_0_0.png", &width, &height, 0, SOIL_LOAD_RGB);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
	glGenerateMipmap(GL_TEXTURE_2D);
	SOIL_free_image_data(image);

	readShaders();
	initShaders();


}
Exemple #15
0
void storeData() {
	indicies = new GLuint[getIndiciesSize()];
	objData = new GLfloat[500000];
	readObj();
	getFinalSize();
	std::cout << getFinalSize() << std::endl;


	//isize = 34695; //boat
	//isize = 22338; //plane
	//isize = 2901; //monkey
	//isize = 36;

	//for (int i = 0; i < 100; i++) std::cout << indicies[i];

	for (int i = 0; i < isize; i++) {

		finalData[i * 6] = objData[(indicies[i]) * 3];
		finalData[i * 6 + 1] = objData[(indicies[i]) * 3 + 1]; //multiply shit by model matrix. stupid model matrix.
		finalData[i * 6 + 2] = objData[(indicies[i]) * 3 + 2];
	}
	for (int i = 0; i < vsize; i += 6) {
		if (i % 18 == 0) { //problem here, if last 2 triangles dont divide into 3 triangles, duh stupid.
			glm::vec3 v0 = glm::vec3(finalData[i], finalData[i + 1], finalData[i + 2]);
			glm::vec3 v1 = glm::vec3(finalData[i + 6], finalData[i + 7], finalData[i + 8]);
			glm::vec3 v2 = glm::vec3(finalData[i + 12], finalData[i + 13], finalData[i + 14]);
			//glm::vec3 normal = glm::cross((v0 - v1), (v0 - v2));
			glm::vec3 normal = glm::cross((v1 - v0), (v2 - v0));

			//glm::vec3 normal = glm::cross((v0 - v2), (v0 - v1));

			finalData[i + 3] = normal.x;
			finalData[i + 4] = normal.y;
			finalData[i + 5] = normal.z;

			finalData[i + 9] = normal.x;
			finalData[i + 10] = normal.y;
			finalData[i + 11] = normal.z;

			finalData[i + 15] = normal.x;
			finalData[i + 16] = normal.y;
			finalData[i + 17] = normal.z;


			normal = glm::normalize(normal) * 1.0f;
			GLfloat avgX = (v0.x + v1.x + v2.x) / 3;
			GLfloat avgY = (v0.y + v1.y + v2.y) / 3;
			GLfloat avgZ = (v0.z + v1.z + v2.z) / 3;

			normals[nindex] = avgX;
			normals[nindex + 1] = avgY;
			normals[nindex + 2] = avgZ;
			normals[nindex + 3] = normal.x + avgX;
			normals[nindex + 4] = normal.y + avgY;
			normals[nindex + 5] = normal.z + avgZ;
			nindex += 6;

		}
	}


	glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);

	glGenBuffers(1, &buffer);
	glBindBuffer(GL_ARRAY_BUFFER, buffer);
	glBufferData(GL_ARRAY_BUFFER, vsize * sizeof(GLfloat), finalData, GL_STATIC_DRAW);

	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)0);
	glEnableVertexAttribArray(0);


	glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
	glEnableVertexAttribArray(2);

	readShaders();
	initShaders();


}