diff Renderer/Engine/Collada.cc @ 1392:555d2a31cf0c draft

collada moved
author e095732 <e095732@ie.u-ryukyu.ac.jp>
date Mon, 30 Jan 2012 16:12:20 +0900
parents 1ea6e4eb2b0a
children ad841dcdbe67
line wrap: on
line diff
--- a/Renderer/Engine/Collada.cc	Fri Jan 27 18:23:56 2012 +0900
+++ b/Renderer/Engine/Collada.cc	Mon Jan 30 16:12:20 2012 +0900
@@ -296,7 +296,7 @@
      * s->vcsum と s->vertex_float->countの値が違うので大きい方をとりあえず使っておく
      */
 
-    /* p separate vertex position and nomal position. */
+    /*
     if (s->texcoord_offset == 2){
         for (int i=0,j=0; i < s->limit; i+=3,j++) {
 	    normal_table[j] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
@@ -312,46 +312,145 @@
 	    normal_table[j+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3+2];
 	}
     }
+    */
 
+    /* p separate vertex position and nomal position. */
     /* make triangle */
-    int k=0,l=0,size=0;
-    for (int i=0;i<s->vmember;i++) {
-        if (s->vcount[i] == 4) {
-	    vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3];
-            vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1];
-            vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2];
-            vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+0];
-            vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+1];
-            vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+2];
-            vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+0];
-            vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1];
-            vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2];
+    int k=0,size=0;
+    if (s->texcoord_offset == 2){
+        for (int i=0;i<s->vmember;i++) {
+	    if (s->vcount[i] == 4) {
+	        vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3];
+		vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1];
+		vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2];
+		vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+3]*3];
+		vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1];
+		vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2];
+		vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+6]*3];
+		vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1];
+		vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2];
+		vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[i+6]*3];
+		vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1];
+		vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2];
+		vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[i+9]*3];
+		vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[i+9]*3+1];
+		vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[i+9]*3+2];
+		vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[i]*3];
+		vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[i]*3+1];
+		vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[i]*3+2];
+
+		normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+		normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1];
+		normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2];
+		normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+4]*3];
+		normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+4]*3+1];
+		normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+4]*3+2];
+		normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[i+10]*3];
+		normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[i+10]*3];
+		normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[i+10]*3];
+		normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+		normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+		normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+		k+=18;
+		size +=2;
+	    } else if (s->vcount[i]==3) {
+	        vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3];
+		vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1];
+		vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2];
+		vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+3]*3];
+		vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1];
+		vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2];
+		vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+6]*3];
+		vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1];
+		vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2];
+
+		normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+		normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1];
+		normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2];
+		normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+4]*3];
+		normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+4]*3+1];
+		normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+4]*3+2];
+		normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
 
-            vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[i]*3];
-            vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[i]*3+1];
-            vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[i]*3+2];
-            vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+0];
-            vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1];
-            vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2];
-            vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+0];
-            vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1];
-            vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2];
-	    k+=18;
-            l+=4;
-	    size +=2;
-        } else if (s->vcount[i]==3) {
-	    vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3];
-            vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1];
-            vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2];
-            vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+0];
-            vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+1];
-            vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+2];
-            vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+0];
-            vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1];
-            vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2];
-	    k+=9;
-	    size++;
-        }
+		k+=9;
+		size++;
+	    }
+	}
+    }else{
+        for (int i=0;i<s->vmember;i++) {
+	    if (s->vcount[i] == 4) {
+	        vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3];
+		vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1];
+		vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2];
+		vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+2]*3];
+		vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1];
+		vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2];
+		vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+4]*3];
+		vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+1];
+		vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+2];
+		vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[i+4]*3];
+		vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+1];
+		vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+2];
+		vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[i+6]*3];
+		vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1];
+		vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2];
+		vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[i]*3];
+		vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[i]*3+1];
+		vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[i]*3+2];
+
+		normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+		normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1];
+		normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2];
+		normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+3]*3];
+		normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+3]*3+1];
+		normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+3]*3+2];
+		normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+5]*3];
+		normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+5]*3];
+		normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+5]*3];
+		normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[i+5]*3];
+		normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[i+5]*3];
+		normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[i+5]*3];
+		normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[i+7]*3];
+		normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+		normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+		normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+
+		k+=18;
+		size +=2;
+	    } else if (s->vcount[i]==3) {
+	        vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3];
+		vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1];
+		vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2];
+		vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+2]*3];
+		vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1];
+		vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2];
+		vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+4]*3];
+		vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+1];
+		vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+2];
+
+		normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
+		normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1];
+		normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2];
+		normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+3]*3];
+		normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+3]*3+1];
+		normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+3]*3+2];
+		normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+5]*3];
+		normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+5]*3];
+		normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+5]*3];
+		k+=9;
+		size++;
+	    }
+	}
     }
 
    /**