modelloader, colorprint

This commit is contained in:
seba 2008-04-14 23:37:15 +02:00
parent a853e102eb
commit 06b187e8a1
4 changed files with 18 additions and 9 deletions

View File

@ -22,6 +22,10 @@ SDL_Color GLColor::getSDLColor() {
return c; return c;
} }
void GLColor::print(std::string m) {
std::cout << m << " Color: " << r << ", " << g << ", " << b << std::endl;
}
void glColorGLC(GLColor c) { void glColorGLC(GLColor c) {
if(c.setalpha) { if(c.setalpha) {
glColor4f(c.r, c.g, c.b, c.a); glColor4f(c.r, c.g, c.b, c.a);

View File

@ -3,6 +3,8 @@
#include <SDL.h> #include <SDL.h>
#include <SDL_opengl.h> #include <SDL_opengl.h>
#include <iostream>
#include <string>
class GLColor { class GLColor {
public: public:
@ -15,6 +17,7 @@ class GLColor {
void set(float _r, float _g, float _b, float _a=1.0f); void set(float _r, float _g, float _b, float _a=1.0f);
SDL_Color getSDLColor(); SDL_Color getSDLColor();
void print(std::string m="");
}; };
void glColorGLC(GLColor c); void glColorGLC(GLColor c);

View File

@ -191,7 +191,7 @@ bool Load3ds::parse(Model *m) {
if(modelloaded) { if(modelloaded) {
modobj.calcNormales(); modobj.calcNormales();
modobj.mat = m->findMaterial(modobj.getName()); // modobj.mat = m->findMaterial(modobj.getName());
m->addObject(modobj); m->addObject(modobj);
} }
std::cout << "Ende Load" << std::endl; std::cout << "Ende Load" << std::endl;

View File

@ -28,15 +28,17 @@ void ModelObject::calcNormales() {
void ModelObject::render() { void ModelObject::render() {
// std::cout << "render " << name << " mit " << polygon.size()<< std::endl; // std::cout << "render " << name << " mit " << polygon.size()<< std::endl;
// std::cout << "Vertex: " << vertex.size() << std::endl; // std::cout << "Vertex: " << vertex.size() << std::endl;
glBegin(GL_TRIANGLES);
if(mat.name[0]=='g') {
std::cout << "Render NOT: " << name << std::endl;
return;
}
mat.diffuse.print(mat.name);
glBegin(GL_LINES);
for(unsigned int i=0; i<polygon.size(); i++) { for(unsigned int i=0; i<polygon.size(); i++) {
// std::cout << "whee nr " <<i << std::endl;
// polygon[i].print(); glColorGLC(mat.diffuse);
// std::cout << "Stat: " << polygon.size() << " " << vertex.size() << " " << mapcoord.size() << " " << normal.size() << std::endl;
// glNormal3f(normal.at( (unsigned short)polygon[i].x));
// glColor3f(mat.diffuse.r, mat.diffuse.g, mat.diffuse.b);
glColorGLC(mat.ambient);
// std::cout << mat.ambient.r << ", " << mat.ambient.g << ", " << mat.ambient.b << std::endl;
glNormal3f(normal.at(i)); glNormal3f(normal.at(i));