Ok, then i have some problems with every obj loaders, if it's main or i download from internet i couldn't play it. This is the result of all of obj loader with opengl and (winapi or SDL) it's look: http://img151.images.../2458/asd2u.jpg
struct xyz{
float x;
float y;
float z;
};
struct abcd{
int a;
int b;
int c;
int d;
};
std::vector < xyz > wieszcholki;
std::vector < xyz > wieszcholki_normalne; //ma zawierać paramerty wieszchołka
std::vector < abcd > sciana ; //ma zawierac kolejnosc wysowaniania
void rys(void){
std::ifstream in( "diamond.obj" );
std::string buffer;
std::string tmp;
xyz v , vn;
abcd f;
std::string tbl[4];
while( !in.eof() )
{
std::getline( in, buffer );
std::istringstream line( buffer );
std::string ch = buffer.substr( 0, 2 );
if( ch == "v " ) // wczytanie parametrów wieszchołka
{
line >> tmp >> tbl[0] >> tbl[1] >> tbl[2];
v.x = atof( tbl[0].c_str() );
v.y = atof( tbl[1].c_str() );
v.z = atof( tbl[2].c_str() );
wieszcholki.push_back(v);
std::cout << "wierzcholki v1: " << v.x << " v2: " << v.y << " v3: " << v.z << std::endl;
}
else if( ch == "f " ) // wczytanie kolejnosci
{
char sc[128];
strncpy(sc, buffer.c_str(), 128);
line >> tmp >> tbl[0] >> tbl[1] >> tbl[2] >> tbl[3];
f.a = (int)atof( tbl[0].c_str() )-1;
f.b = (int)atof( tbl[1].c_str() )-1;
f.c = (int)atof( tbl[2].c_str() )-1;
f.d = (int)atof( tbl[3].c_str() )-1;
sciana.push_back(f);
std::cout << "kolejnosc f.a: " << f.a << " f.b: " << f.b << " f.c: " << f.c <<" f.d: " << f.d << std::endl;
}
else if( ch == "vn" )
{
line >> tmp >> tbl[0] >> tbl[1] >> tbl[2];
vn.x = atof( tbl[0].c_str() );
vn.y = atof( tbl[1].c_str() );
vn.z = atof( tbl[2].c_str() );
wieszcholki_normalne.push_back(vn);
std::cout << "normalne v1: " << vn.x << " v2: " << vn.y << " v3: " << vn.z << std::endl;
}
}
rysuj=true;
}
I check it in Visual studio and problem is the same, after comment the rysuj=true, everything is working, pls look at the code, maybe i lose something. rysuj=true makes that it is drawing:
if(rysuj){
glColor3f(0.0, 0.0 ,0.0);
for(int i=0 ; i< sciana.size(); i++){
glBegin(GL_QUAD_STRIP);
glNormal3f(wieszcholki_normalne[i].x , wieszcholki_normalne[i].y , wieszcholki_normalne[i].z);
glVertex3f(wieszcholki[sciana[i].a].x, wieszcholki[sciana[i].a].y,wieszcholki[sciana[i].a].z);
glNormal3f(wieszcholki_normalne[i].x , wieszcholki_normalne[i].y , wieszcholki_normalne[i].z);
glVertex3f(wieszcholki[sciana[i].b].x, wieszcholki[sciana[i].b].y,wieszcholki[sciana[i].b].z);
glNormal3f(wieszcholki_normalne[i].x , wieszcholki_normalne[i].y , wieszcholki_normalne[i].z);
glVertex3f(wieszcholki[sciana[i].c].x, wieszcholki[sciana[i].c].y,wieszcholki[sciana[i].c].z);
glNormal3f(wieszcholki_normalne[i].x , wieszcholki_normalne[i].y , wieszcholki_normalne[i].z);
glVertex3f(wieszcholki[sciana[i].d].x, wieszcholki[sciana[i].d].y,wieszcholki[sciana[i].d].z);
glEnd();
}
Edited by dargueta, 01 January 2012 - 08:04 PM.


Sign In
Create Account

Back to top









