Skip to content
Permalink
Browse files

.

  • Loading branch information...
ri
ri committed Mar 9, 2018
1 parent 88eb245 commit 256eb90113b0e70c41d86b72ad43a72fb164d530
@@ -365,7 +365,7 @@ void SWindow::onStepChanged(int value) {

void SWindow::onTimeXChanged(int value) {
if (value < 1) value = 1;
timeX = 1000/value;
timeX = 1000.0 / (double)value;
onPlayClick();
}

@@ -37,6 +37,15 @@ Location::Location(void) {
color_zrv = 0xFF608080;
color_lines = 0x0000FFFF;
satWObject = 0;
lat = 0.0;
lon = 0.0;
_height = 0.0;
_zrlWidth = 0.0;
_zrlAzimuth = 0.0;
_zrlRange = 0.0;
r[0] = 0.0;
r[1] = 0.0;
r[2] = 0.0;
}

Location::~Location(void) {
@@ -1081,7 +1081,7 @@ void Sgp4Model::dspace() {
// the following integration works for negative time steps and periods
// the specific changes are unknown because the original code was so convoluted

ft = 0.0;
// ft = 0.0;
atime = 0.0;
if (irez != 0)
{
@@ -41,29 +41,29 @@ void GLObjMaterial::init() {
QImage img;
while (!file.eof()) {
file.getline(line, sizeof(line));
sscanf(line, "%s %s", type, name);
sscanf(line, "%64s %64s", type, name);
if (strcmp(type, "newmtl") == 0) {
addMaterial();
continue;
}
if ((strcmp(type, "Ka") == 0) && (material != 0)) {
sscanf(line, "%s %f %f %f %f", type, &material->ka()[0], &material->ka()[1], &material->ka()[2], &material->ka()[3]);
sscanf(line, "%*s %f %f %f %f", &material->ka()[0], &material->ka()[1], &material->ka()[2], &material->ka()[3]);
continue;
}
if ((strcmp(type, "Kd") == 0) && (material != 0)) {
sscanf(line, "%s %f %f %f %f", type, &material->kd()[0], &material->kd()[1], &material->kd()[2], &material->kd()[3]);
sscanf(line, "%*s %f %f %f %f", &material->kd()[0], &material->kd()[1], &material->kd()[2], &material->kd()[3]);
continue;
}
if ((strcmp(type, "Ks") == 0) && (material != 0)) {
sscanf(line, "%s %f %f %f %f", type, &material->ks()[0], &material->ks()[1], &material->ks()[2], &material->ks()[3]);
sscanf(line, "%*s %f %f %f %f", &material->ks()[0], &material->ks()[1], &material->ks()[2], &material->ks()[3]);
continue;
}
if ((strcmp(type, "Ke") == 0) && (material != 0)) {
sscanf(line, "%s %f %f %f %f", type, &material->ke()[0], &material->ke()[1], &material->ke()[2], &material->ke()[3]);
sscanf(line, "%*s %f %f %f %f", &material->ke()[0], &material->ke()[1], &material->ke()[2], &material->ke()[3]);
continue;
}
if ((strcmp(type, "Ns") == 0) && (material != 0)) {
sscanf(line, "%s %f", type, material->ns());
sscanf(line, "%*s %f", material->ns());
continue;
}
// if ((strcmp(type, "map_Ka") == 0) && (material != 0)) {
@@ -79,7 +79,7 @@ void GLObjMaterial::init() {
// }
if ((strcmp(type, "map_Kd") == 0) && (material != 0)) {
material->setMapKdOn(true);
sscanf(line, "%s %s", type, type);
sscanf(line, "%*s %64s", type);
string fullname = m_path;
fullname.append("/").append(type);
m_parent->makeCurrent();
@@ -26,7 +26,7 @@ GLObjecter::GLObjecter(QOpenGLWidget *parent, int index, char *path, char *fileN
m_parent->makeCurrent();

if (!initializeOpenGLFunctions()) {
qWarning("error: GLObjecter initializeOpenGLFunctions");
puts("error: GLObjecter initializeOpenGLFunctions");
exit(-1);
}
string fullname = path;
@@ -43,38 +43,40 @@ GLObjecter::GLObjecter(QOpenGLWidget *parent, int index, char *path, char *fileN
return;
}

iostream strm(&fbuf);
file = &strm;
// iostream strm(&fbuf);
file = new iostream(&fbuf);
mtlLib = 0;
setlocale(LC_NUMERIC, "C");
init();
clear();
}

void GLObjecter::clear() {
for (vector<float *>::iterator i = vertex.begin(); i != vertex.end(); i++) delete[] *i;
for (vector<float *>::iterator i = tex_vertex.begin(); i != tex_vertex.end(); i++) delete[] *i;
for (vector<float *>::iterator i = normals.begin(); i != normals.end(); i++) delete[] *i;
vertex.clear();
tex_vertex.clear();
normals.clear();
file->clear();
if (mtlLib != 0) delete mtlLib; //TODO add remove tex как бы там еще и текстуры надо бы удалять
for (vector<float *>::iterator i = vertex.begin(); i != vertex.end(); i++) delete[] *i;
for (vector<float *>::iterator i = tex_vertex.begin(); i != tex_vertex.end(); i++) delete[] *i;
for (vector<float *>::iterator i = normals.begin(); i != normals.end(); i++) delete[] *i;
vertex.clear();
tex_vertex.clear();
normals.clear();
file->clear();
if (mtlLib != 0) delete mtlLib; //TODO add remove tex как бы там еще и текстуры надо бы удалять
}

GLObjecter::~GLObjecter() {
clear();
delete file;
}

void GLObjecter::init() {
glNewList(m_index, GL_COMPILE);
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT);

while (!file->eof()) {
memset(type, 20, sizeof(type) - 1);
memset(type, 20, sizeof(type)); // TODO remove this two lines
type[BUF_SIZE - 1] = '\0';
// strset(type, 20);
file->getline(line, sizeof(line));
sscanf(line, "%s", type);
sscanf(line, "%64s", type);
if (strcmp(type, "v") == 0) {
addVertex();
continue;
@@ -92,7 +94,7 @@ void GLObjecter::init() {
continue;
}
if (strcmp(type, "mtllib") == 0) {
sscanf(line, "%s %s", type, type);
sscanf(line, "%*s %64s", type);
if (mtlLib != 0) {
delete mtlLib;
mtlLib = 0;
@@ -101,12 +103,12 @@ void GLObjecter::init() {
continue;
}
if (strcmp(type, "usemtl") == 0) {
sscanf(line, "%s %s", type, type);
sscanf(line, "%*s %64s", type);
if (mtlLib != 0) mtlLib->set(type);
continue;
}
if (strcmp(type, "g") == 0) {
sscanf(line, "%s %s", type, type);
sscanf(line, "%*s %64s", type);
cout << type << endl;
continue;
}
@@ -117,60 +119,60 @@ void GLObjecter::init() {
}

void GLObjecter::addVertex() {
float *v = new float[3];
sscanf(line, "%s %f %f %f", type, &v[0], &v[1], &v[2]);
vertex.push_back(v);
float *v = new float[3];
sscanf(line, "%*s %f %f %f", &v[0], &v[1], &v[2]);
vertex.push_back(v);
}

void GLObjecter::addTexVertex() {
float *v = new float[3];
sscanf(line, "%s %f %f %f", type, &v[0], &v[1], &v[2]);
tex_vertex.push_back(v);
float *v = new float[3];
sscanf(line, "%*s %f %f %f", &v[0], &v[1], &v[2]);
tex_vertex.push_back(v);
}

void GLObjecter::addNormal() {
float *v = new float[3];
sscanf(line, "%s %f %f %f", type, &v[0], &v[1], &v[2]);
normals.push_back(v);
float *v = new float[3];
sscanf(line, "%*s %f %f %f", &v[0], &v[1], &v[2]);
normals.push_back(v);
}

void GLObjecter::addFace() {
char *token = strtok(line, " ");
token = strtok(0, " ");
char test = 0;

glBegin(GL_POLYGON);
while (token != 0) {
// int *tmp = new int[3];
int tmp[3];
test = sscanf(token, "%d/%d/%d", &tmp[0], &tmp[1], &tmp[2]);
switch (test) {
default: case 0:
cout << (int)test << " bad face " << token << endl;
return;
break;
break;
case 1:
if (sscanf(token, "%d//%d", &tmp[0], &tmp[2]) == 2) {
glNormal3fv(normals.at(tmp[2] - 1));
glVertex3fv(vertex.at(tmp[0] - 1));
}
else glVertex3fv(vertex.at(tmp[0] - 1));
break;
case 2:
if (mtlLib->mapKdOn()) glTexCoord3fv(tex_vertex.at(tmp[1] - 1));
glVertex3fv(vertex.at(tmp[0] - 1));
break;
case 3:
glNormal3fv(normals.at(tmp[2] - 1));
if (mtlLib->mapKdOn()) glTexCoord3fv(tex_vertex.at(tmp[1] - 1));
glVertex3fv(vertex.at(tmp[0] - 1));
break;
}
token = strtok(0, " ");
}
char *token;
int tmp[3];
strtok(line, " ");
token = strtok(NULL, " ");
char test = 0;

glBegin(GL_POLYGON);
while (token != 0) {
test = sscanf(token, "%d/%d/%d", &tmp[0], &tmp[1], &tmp[2]);
switch (test) {
default:
case 0:
cout << (int)test << " bad face " << token << endl;
return;
case 1:
if (sscanf(token, "%d//%d", &tmp[0], &tmp[2]) == 2) {
glNormal3fv(normals.at(tmp[2] - 1));
glVertex3fv(vertex.at(tmp[0] - 1));
}
else glVertex3fv(vertex.at(tmp[0] - 1));
break;
case 2:
if (mtlLib->mapKdOn()) glTexCoord3fv(tex_vertex.at(tmp[1] - 1));
glVertex3fv(vertex.at(tmp[0] - 1));
break;
case 3:
glNormal3fv(normals.at(tmp[2] - 1));
if (mtlLib->mapKdOn()) glTexCoord3fv(tex_vertex.at(tmp[1] - 1));
glVertex3fv(vertex.at(tmp[0] - 1));
break;
}
token = strtok(NULL, " ");
}

glEnd();
glEnd();
}

void GLObjecter::exec() {
@@ -22,34 +22,34 @@ using namespace std;

class GLObjecter : protected QOpenGLFunctions_2_0 {
public:
GLObjecter(QOpenGLWidget *parent, int index, char *path, char *fileName);
virtual ~GLObjecter();
void move(float x, float y, float z);
void moveX(float value);
void moveY(float value);
void moveZ(float value);
void rotateX(float value);
void rotateY(float value);
void rotateZ(float value);
void exec();
GLObjecter(QOpenGLWidget *parent, int index, char *path, char *fileName);
virtual ~GLObjecter();
void move(float x, float y, float z);
void moveX(float value);
void moveY(float value);
void moveZ(float value);
void rotateX(float value);
void rotateY(float value);
void rotateZ(float value);
void exec();

private:
iostream *file;
std::string m_path;
float m_xyz[3];
float m_angle[3];
uint32_t m_index;
vector<float *> vertex, tex_vertex, normals;
char line[BUF_SIZE];
char type[BUF_SIZE];
GLObjMaterial *mtlLib;
QOpenGLWidget *m_parent;
void init();
void addVertex();
void addTexVertex();
void addNormal();
void addFace();
void clear();
iostream *file;
std::string m_path;
float m_xyz[3];
float m_angle[3];
uint32_t m_index;
vector<float *> vertex, tex_vertex, normals;
char line[BUF_SIZE];
char type[BUF_SIZE];
GLObjMaterial *mtlLib;
QOpenGLWidget *m_parent;
void init();
void addVertex();
void addTexVertex();
void addNormal();
void addFace();
void clear();
};

#endif /* GLOBJECTER_H_ */
@@ -12,6 +12,8 @@
GLSprite::GLSprite(QString fileName, QOpenGLWidget *parentWidget) : SatWidgetObject(fileName, parentWidget) {
widget = NULL;
texture = NULL;
m_x = 0.0;
m_y = 0.0;
m_list_index = 0;
load(fileName, parentWidget);
}
@@ -54,9 +56,9 @@ void GLSprite::load(QString fileName, QOpenGLWidget *parentWidget) {
delete texture;
}
texture = new QOpenGLTexture(image);
if (!texture) {
qWarning("error: GLSprite::load QOpenGLTexture");
}
// if (!texture) {
// qWarning("error: GLSprite::load QOpenGLTexture");
// }
}

if (glIsList(m_list_index)) {
Oops, something went wrong.

0 comments on commit 256eb90

Please sign in to comment.
You can’t perform that action at this time.