Hi Experts,
I am completely new at Computer Graphics and has been exploring a lot in OpenGL, i am able to render basic primitives, translate and rotate them.
I am having trouble reading an input model file.
Object name = SQUARE
triangles = 2
Material count = 1
ambient color 0.694 0.580 0.459
diffuse color 0.992 0.941 0.863
specular color 1.000 1.000 1.000
material shine 0.250
– 3*[pos(x,y,z) normal(x,y,z) color_index] face_normal(x,y,z)
v0 -1.0 -1.0 -2.0 0.0 0.0 1.0 0
v1 1.0 -1.0 -2.0 0.0 0.0 1.0 0
v2 1.0 1.0 -2.0 0.0 0.0 1.0 0
face normal 0.0 0.0 1.0
v0 1.0 1.0 -2.0 0.0 0.0 1.0 0
v1 -1.0 1.0 -2.0 0.0 0.0 1.0 0
v2 -1.0 -1.0 -2.0 0.0 0.0 1.0 0
face normal 0.0 0.0 1.0
I tried this normal way using file operations
#include<GL/freeglut.h>
#include<GL/gl.h>
#include<math.h>
#include<fstream>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
char line[256];
int tri,mat;
vector<double> ambient,diffuse,specular;
float material_shine;
FILE* infile;
infile=fopen("/home/ameya/Documents/CG/square.in","r");
series of fscanf operations to read float and integer values.
return 0;
}
1)Am getting garbage values.
2)How should i store the vertices of the sqaure.
3)Should i define a vector class to store each vector something like that.
4) or just store vertices in a normal array.
Actually i am completely clueless, in need of some direction.
Kindly help.