Changeset 3081 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Dec 4, 2004, 11:05:15 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/importer/object.cc
r3080 r3081 777 777 bool Object::buildVertexNormals () 778 778 { 779 779 780 if (verbose >=2) 780 781 printf("Normals are being calculated.\n"); … … 783 784 for (int i=0; i<vertices->getCount()/3;i++) 784 785 normArray[i] = Vector(.0,.0,.0); 785 786 786 787 int firstTouch; 787 788 int secondTouch; … … 801 802 FaceElement* prevElem = firstElem; 802 803 FaceElement* curElem = prevElem->next; 804 FaceElement* lastElem; 805 // close the Chain. !! IMPORTANT:the last Element of the Chain must point to NULL, or it will resolv into an infinity-loop. 806 while (curElem) 807 { 808 prevElem = curElem; 809 curElem = curElem->next; 810 } 811 lastElem = prevElem; 812 prevElem->next = firstElem; 803 813 804 for (int j=1; j<tmpFace->vertexCount-1; j++) 814 curElem = firstElem; 815 for (int j=0; j<tmpFace->vertexCount; j++) 805 816 { 806 817 curElem->normalNumber = curElem->vertexNumber; … … 809 820 prevV = Vector (vertices->getArray()[prevElem->vertexNumber*3], vertices->getArray()[prevElem->vertexNumber*3+1], vertices->getArray()[prevElem->vertexNumber*3+2]) - curV; 810 821 nextV = Vector (vertices->getArray()[curElem->next->vertexNumber*3], vertices->getArray()[curElem->next->vertexNumber*3+1], vertices->getArray()[curElem->next->vertexNumber*3+2]) - curV; 811 normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + *(nextV.cross(prevV).getNormalized());812 813 // prevV.x, nextV.cross(prevV).x);814 822 normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV); 823 824 if (curElem == firstElem ) 825 printf ("schnitt, %d\n", j); 815 826 prevElem = curElem; 816 827 curElem = curElem->next; 817 828 } 818 firstElem->normalNumber = firstElem->vertexNumber; 819 820 curV = Vector (vertices->getArray()[firstElem->vertexNumber*3], vertices->getArray()[firstElem->vertexNumber*3+1], vertices->getArray()[firstElem->vertexNumber*3+2]); 821 prevV = Vector (vertices->getArray()[prevElem->vertexNumber*3], vertices->getArray()[prevElem->vertexNumber*3+1], vertices->getArray()[prevElem->vertexNumber*3+2]) - curV; 822 nextV = Vector (vertices->getArray()[firstElem->next->vertexNumber*3], vertices->getArray()[firstElem->next->vertexNumber*3+1], vertices->getArray()[firstElem->next->vertexNumber*3+2]) - curV; 823 normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + *(nextV.cross(prevV).getNormalized()); 824 829 // reopening the Chain again. 830 lastElem->next = NULL; 825 831 } 826 832 tmpFace = tmpFace->next; … … 839 845 } 840 846 delete []normArray; 847 841 848 } 842 849 … … 871 878 readVertexTexture ("-1.000000 0.000000"); 872 879 readVertexTexture ("-1.000000 1.000000"); 873 880 881 /* 874 882 readVertexNormal ("0.000000 0.000000 1.000000"); 875 883 readVertexNormal ("0.000000 0.000000 1.000000"); … … 896 904 readVertexNormal ("-1.000000 0.000000 0.000000"); 897 905 readVertexNormal ("-1.000000 0.000000 0.000000"); 898 906 */ 907 908 readFace ("1 2 4 3"); 909 readFace ("3 4 6 5"); 910 readFace ("5 6 8 7"); 911 readFace ("7 8 2 1"); 912 readFace ("2 8 6 4"); 913 readFace ("7 1 3 5"); 914 915 /* 899 916 readFace ("1/1/1 2/2/2 4/4/3 3/3/4"); 900 917 readFace ("3/3/5 4/4/6 6/6/7 5/5/8"); … … 903 920 readFace ("2/2/17 8/11/18 6/12/19 4/4/20"); 904 921 readFace ("7/13/21 1/1/22 3/3/23 5/14/24"); 905 } 922 */ 923 }
Note: See TracChangeset
for help on using the changeset viewer.