[Remove] Removed objimport*
This commit is contained in:
parent
4d475bdf9b
commit
a96eb78d34
@ -3,7 +3,7 @@ SUBDIRS = sbre/
|
||||
|
||||
bin_PROGRAMS = Lephisto3D
|
||||
Lephisto3D_SOURCES = main.cpp gui_button.cpp gui.cpp gui_fixed.cpp gui_screen.cpp gui_label.cpp glfreetype.cpp \
|
||||
objimport.cpp body.cpp space.cpp ship.cpp player.cpp gui_toggle_button.cpp gui_radio_button.cpp \
|
||||
body.cpp space.cpp ship.cpp player.cpp gui_toggle_button.cpp gui_radio_button.cpp \
|
||||
gui_radio_group.cpp dynamic_body.cpp planet.cpp star.cpp frame.cpp gui_image_button.cpp gui_image.cpp \
|
||||
gui_image_radio_button.cpp gui_multi_state_image_button.cpp ship_cpanel.cpp gui_widget.cpp sector_view.cpp \
|
||||
mtrand.cpp world_view.cpp system_view.cpp star_system.cpp sector.cpp system_info_view.cpp generic_system_view.cpp \
|
||||
@ -13,7 +13,7 @@ Lephisto3D_LDADD = sbre/libsbre.a
|
||||
|
||||
include_HEADERS = body.h frame.h generic_system_view.h glfreetype.h gui_button.h gui_container.h gui_events.h gui_fixed.h \
|
||||
gui.h gui_image_button.h gui_image.h gui_image_radio_button.h gui_label.h gui_multi_state_image_button.h gui_radio_button.h \
|
||||
gui_radio_group.h gui_screen.h gui_toggle_button.h gui_widget.h libs.h matrix4x4.h mtrand.h objimport.h l3d.h \
|
||||
gui_radio_group.h gui_screen.h gui_toggle_button.h gui_widget.h libs.h matrix4x4.h mtrand.h l3d.h \
|
||||
planet.h player.h dynamic_body.h sector.h sector_view.h ship_cpanel.h ship.h space.h star.h star_system.h system_info_view.h \
|
||||
system_view.h vector3.h view.h world_view.h date.h space_station.h space_station_view.h model_body.h gui_iselectable.h \
|
||||
ship_type.h object.h info_view.h model_coll_mesh_data.h object_viewer_view.h fixed.h custom_starsystems.h
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "libs.h"
|
||||
#include "dynamic_body.h"
|
||||
#include "space.h"
|
||||
#include "objimport.h"
|
||||
#include "frame.h"
|
||||
|
||||
DynamicBody::DynamicBody(void) : ModelBody() {
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "l3d.h"
|
||||
#include "gui.h"
|
||||
#include "glfreetype.h"
|
||||
#include "objimport.h"
|
||||
#include "player.h"
|
||||
#include "space.h"
|
||||
#include "planet.h"
|
||||
|
@ -1,73 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <GL/gl.h>
|
||||
#include "libs.h"
|
||||
#include "objimport.h"
|
||||
|
||||
ObjMesh* import_obj_mesh(const char *filename) {
|
||||
char buf[1024];
|
||||
FILE* f = fopen(filename, "r");
|
||||
if(!f) {
|
||||
fprintf(stderr, "Failed to load mesh %s\n", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ObjMesh* m = new ObjMesh;
|
||||
float vsum[3];
|
||||
memset(vsum, 0, sizeof(float)*3);
|
||||
|
||||
while(fgets(buf, sizeof(buf), f)) {
|
||||
if(buf[0] == '#') continue;
|
||||
ObjVertex v;
|
||||
if(sscanf(buf, "v %f %f %f", &v.p.x, &v.p.y, &v.p.z) == 3) {
|
||||
m->vertices.push_back(v);
|
||||
vsum[0] += v.p.x;
|
||||
vsum[1] += v.p.y;
|
||||
vsum[2] += v.p.z;
|
||||
continue;
|
||||
}
|
||||
ObjTriangle t;
|
||||
if(sscanf(buf, "f %d/%*d/ %d/%*d/ %d/%*d/", &t.v[0], &t.v[1], &t.v[2]) == 3) {
|
||||
t.v[0]--;
|
||||
t.v[1]--;
|
||||
t.v[2]--;
|
||||
m->triangles.push_back(t);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
vsum[0] /= m->vertices.size();
|
||||
vsum[1] /= m->vertices.size();
|
||||
vsum[2] /= m->vertices.size();
|
||||
|
||||
/* Locate the model roughly at 0,0,0. */
|
||||
for(unsigned int i = 0; i < m->vertices.size(); i++) {
|
||||
m->vertices[i].p.x -= vsum[0];
|
||||
m->vertices[i].p.y -= vsum[1];
|
||||
m->vertices[i].p.z -= vsum[2];
|
||||
}
|
||||
|
||||
printf("%zd vertices\n", m->vertices.size());
|
||||
printf("%zd triangles\n", m->triangles.size());
|
||||
return m;
|
||||
}
|
||||
|
||||
/* Why not make a display list.. */
|
||||
void ObjMesh::Render(void) {
|
||||
glBegin(GL_TRIANGLES);
|
||||
for(unsigned int i = 0; i < triangles.size(); i++) {
|
||||
ObjTriangle& t = triangles[i];
|
||||
|
||||
vector3f p0 = vertices[t.v[0]].p;
|
||||
vector3f p1 = vertices[t.v[1]].p;
|
||||
vector3f p2 = vertices[t.v[2]].p;
|
||||
|
||||
vector3f n = -vector3f::Normalize(vector3f::Cross(p0-p2, p0-p1));
|
||||
|
||||
glNormal3fv(&n[0]);
|
||||
glVertex3fv(&vertices[t.v[0]].p[0]);
|
||||
glVertex3fv(&vertices[t.v[1]].p[0]);
|
||||
glVertex3fv(&vertices[t.v[2]].p[0]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "vector3.h"
|
||||
|
||||
struct ObjVertex {
|
||||
vector3f p;
|
||||
};
|
||||
|
||||
struct ObjTriangle {
|
||||
int v[3];
|
||||
};
|
||||
|
||||
struct ObjMesh {
|
||||
std::vector<ObjVertex> vertices;
|
||||
std::vector<ObjTriangle> triangles;
|
||||
void Render(void);
|
||||
};
|
||||
|
||||
ObjMesh* import_obj_mesh(const char* filename);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "ship.h"
|
||||
#include "objimport.h"
|
||||
#include "frame.h"
|
||||
#include "l3d.h"
|
||||
#include "world_view.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "space_station.h"
|
||||
#include "ship.h"
|
||||
#include "objimport.h"
|
||||
#include "model_coll_mesh_data.h"
|
||||
|
||||
#define STATION_SBRE_MODEL 65
|
||||
|
Loading…
Reference in New Issue
Block a user