2013-04-28 2 views
-1

내 모델이 원 안에 움직 이도록 노력하고 있습니다. 루프 및 속도가 정의되지 않은 오류가 발생합니다. 코드가 여기에 있으며, 헤더 파일과 .cpp의 두 클래스 파일을 제공합니다. 파일.OpenGL 객체가 원형으로 움직입니다.

헤더 파일

#ifndef OBJECTLOADERGUILTYSPARK_H 
#define OBJECTLOADERGUILTYSPARK_H 

#include <iostream> 
#include <windows.h> 
#include <GL/gl.h> 
#include <GL/glu.h> 
#include "glut.h" 
#include <istream> 
#include <fstream> 
#include <string> 
#include <sstream> 
#include <vector> 
#include "StructHeader.h" 

using namespace std; 

class ObjectLoaderGuiltyspark 
{ 
private: 

string guiltyName; 
int numVert; 
int numNormals; 
int numcoords; 
int numFaces; 
int ammount; 
float speed; 
point3D loop; 
float radius; 
point3D v343[1718]; 
point3D vn343[964]; 
point3D vt343[521]; 
point3Di f343[5186][3]; 


public: 
ObjectLoaderGuiltyspark(string guiltyName); 
~ObjectLoaderGuiltyspark() {}; 

void objLoader343(string guiltyName); 
void draw343(int x, int y, int z, point3D loop[], int radius); 
void getCalcPlanetCircle(); 
circle getPlanetPos(); 
    }; 

    #endif 

클래스 파일

#include <windows.h> 
#include "ObjectLoaderGuiltyspark.h" 
#include <math.h> 



ObjectLoaderGuiltyspark::ObjectLoaderGuiltyspark(string gName) 
: guiltyName(gName) 
{ 
numVert = 0; 
numNormals = 0; 
numcoords = 0; 
numFaces = 0; 
ammount = 0; 
speed = 5; 
radius = 5; 
loop = new point3D[600]; 

} 

void ObjectLoaderGuiltyspark::objLoader343(string gfile) 
{ 

string test; 
ifstream inputFile; 
inputFile.open(gfile); 

if (!inputFile.good()) 
    cout << "Problem with Input File"; 
else 
{ 
    while(inputFile >> test) 
    { 

     if (test == "v") 
     { 
      inputFile >> v343[numVert].x; 
      inputFile >> v343[numVert].y; 
      inputFile >> v343[numVert].z; 
      numVert++; 
     } 

     else if(test == "vn") 
     { 
      inputFile >> vn343[numNormals].x; 
      inputFile >> vn343[numNormals].y; 
      inputFile >> vn343[numNormals].z; 
      numNormals++; 
     } 
     else if(test == "vt") 
     { 
      inputFile >> vt343[numcoords].x; 
      inputFile >> vt343[numcoords].y; 
      inputFile >> vt343[numcoords].z; 
      numcoords++; 
     } 
     else if(test == "f") 
     { 
      string temp; 
      for(int count = 0; count < 3; count++) 
      { 
       inputFile >> temp; 
       stringstream stream(temp); 

       getline(stream, temp, '/'); 
       f343[numFaces][count].x = atoi(temp.c_str()) - 1; 
       getline(stream, temp, '/'); 
       f343[numFaces][count].y = atoi(temp.c_str()) - 1; 
       getline(stream, temp, '/'); 
       f343[numFaces][count].z = atoi(temp.c_str()) - 1; 
      } 

      numFaces++; 
     } 


    } 
} 
} 

void getCalcPlanetCircle(point3D loop[], int radius) 
{ 

    for (int i = 0; i < 600 ; i++) 
     { 
      loop[i].x = radius * sin(i/100.0); 
      loop[i].y = 0; 
      loop[i].z = radius * cos(i/100.0); 
     } 
} 


circle getPlanetPos() 
{ 
    circle loopPos; 
    loopPos.xRot = loop[(int)(ceil (speed))].x; 
    loopPos.yRot = loop[(int)(ceil (speed))].y; 
    loopPos.zRot = loop[(int)(ceil (speed))].z; 
    return loopPos; 
} 

void ObjectLoaderGuiltyspark::draw343(int x, int y, int z, point3D loop[], int radius) 
{ 

glTranslated(loop[(int)(ceil (speed))].x, loop[(int)(ceil (speed))].y, loop[(int)   (ceil (speed))].z); 

for(int i = 0; i < 5186; i++)//reads coords for verts from global arrays. 
{ 

    glBegin(GL_TRIANGLES); 

    glColor3f(1.0, 1.0, 1.0); 
    int one = f343[i][0].x; 
    int two = f343[i][1].x; 
    int three = f343[i][2].x; 

    int tex_one = f343[i][0].z; 
    int tex_two = f343[i][1].z; 
    int tex_three = f343[i][2].z; 

    glVertex3fv(&(v343[one].x)); 
    glTexCoord2fv(&(vt343[tex_one].x)); 
    glVertex3fv(&(v343[two].x)); 
    glTexCoord2fv(&(vt343[tex_two].x)); 
    glVertex3fv(&(v343[three].x)); 
    glTexCoord2fv(&(vt343[tex_three].x)); 


    glEnd(); 
} 
} 
+0

으로 접두어를 붙이면됩니다. point3d의 정의가 포함 된 파일을 포함 시켰습니까? – 4pie0

+0

네, 지금 컴파일하기 전에 단지 그것을 렌더링 명확하게하기 위해 그것을 볼 수 있었고 그냥 지점 주위를 움직이게하고 싶었습니다 –

답변

1

getPlanetPos는 멤버 함수로 선언하지만, 무료 함수로 (구현) 정의된다. 그냥 ObjectLoaderGuiltyspark ::

+0

덕분에 지금 컴파일하지만 원래의 위치를 ​​0,0과 반경을 2로 설정했습니다. 렌더링되지 않거나 찾을 수 없습니다. –

관련 문제