Пример #1
0
void setupBounds()
{
    Vec3f topLeftFront = Vec3f(-WIDTH/2., HEIGHT/2.,DEPTH/2.);
    Vec3f topLeftBack = Vec3f(-WIDTH/2., HEIGHT/2.,-DEPTH/2.);
    Vec3f topRightFront = Vec3f(WIDTH/2., HEIGHT/2.,DEPTH/2.);
    Vec3f topRightBack = Vec3f(WIDTH/2., HEIGHT/2.,-DEPTH/2.);
    Vec3f botLeftFront = Vec3f(-WIDTH/2., -HEIGHT/2.,DEPTH/2.);
    Vec3f botLeftBack = Vec3f(-WIDTH/2., -HEIGHT/2.,-DEPTH/2.);
    Vec3f botRightFront = Vec3f(WIDTH/2., -HEIGHT/2.,DEPTH/2.);
    Vec3f botRightBack = Vec3f(WIDTH/2., -HEIGHT/2.,-DEPTH/2.);


    bounds.setColour(Vec3f(0,0,1));
    bounds.setFragmentShaderPath("Shaders/basic_fs.glsl");
    bounds.setVertexShaderPath("Shaders/basic_vs.glsl");
    bounds.setRenderMode(GL_LINES);
    std::vector<Vec3f> points;

    points.push_back(topLeftFront);
    points.push_back(topLeftBack);

    points.push_back(topLeftBack);
    points.push_back(topRightBack);

    points.push_back(topRightBack);
    points.push_back(topRightFront);

    points.push_back(topRightFront);
    points.push_back(topLeftFront);

    points.push_back(botLeftFront);
    points.push_back(botLeftBack);

    points.push_back(botLeftBack);
    points.push_back(botRightBack);

    points.push_back(botRightBack);
    points.push_back(botRightFront);

    points.push_back(botRightFront);
    points.push_back(botLeftFront);

    points.push_back(topLeftFront);
    points.push_back(botLeftFront);

    points.push_back(topRightFront);
    points.push_back(botRightFront);

    points.push_back(topLeftBack);
    points.push_back(botLeftBack);

    points.push_back(topRightBack);
    points.push_back(botRightBack);



    bounds.setVerts(points);
}
Пример #2
0
/* Loads a curve from a ".vert" file, which is constructed as such:
 * 2				//First line is the number of vec3f's to read (call this 'n')
 * 1.0 1.0 1.0		// Second line is always the colour to render the curve
 * -1.0 1.0 0.0		// The remaining n -1 lines are the vertices of the curve
 */
void FileHelper::loadCurveFromFile(const char* file, Renderable & curve){

	char buffer[50];
	FILE* fp;
	int numPoints;

	fp = fopen(file, "r");

	fgets(buffer, 50, fp);
	numPoints = atoi(buffer);

	std::vector<Vec3f> verts;
	for(int i = 0; i < numPoints; i++){
		float temp1, temp2, temp3;
		fgets(buffer, 50, fp);
		sscanf(buffer, "%f %f %f\n", &temp1, &temp2, &temp3);
		Vec3f vert(temp1, temp2, temp3);

		// First point is the colour
		if(i == 0)
		{
			curve.setColour(vert);
		}

		// Remaining points are the vertices
		else
		{
			verts.push_back(vert);
		}

	}

	curve.setVerts(verts);

	fclose(fp);
	printf("Loaded %s!\n", file);
}