Browse Source

modelloader, colorprint

seba 12 years ago
parent
commit
06b187e8a1
4 changed files with 18 additions and 9 deletions
  1. 4
    0
      glcolor.cpp
  2. 3
    0
      glcolor.h
  3. 1
    1
      models/load3ds.cpp
  4. 10
    8
      models/model.cpp

+ 4
- 0
glcolor.cpp View File

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

+ 3
- 0
glcolor.h View File

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

+ 1
- 1
models/load3ds.cpp View File

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

+ 10
- 8
models/model.cpp View File

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

Loading…
Cancel
Save