Changeset 3656 in orxonox.OLD for orxonox/trunk/src/lib/graphics/importer/model.cc
- Timestamp:
- Mar 26, 2005, 9:02:42 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/model.cc
r3590 r3656 797 797 void Model::cubeModel(void) 798 798 { 799 this->addVertex ( "-0.5 -0.5 0.5");800 this->addVertex ( "0.5 -0.5 0.5");801 this->addVertex ( "-0.5 0.5 0.5");802 this->addVertex ( "0.5 0.5 0.5");803 this->addVertex ( "-0.5 0.5 -0.5");804 this->addVertex ( "0.5 0.5 -0.5");805 this->addVertex ( "-0.5 -0.5 -0.5");806 this->addVertex ( "0.5 -0.5 -0.5");807 808 this->addVertexTexture ( "0.0 0.0");809 this->addVertexTexture ( "1.0 0.0");810 this->addVertexTexture ( "0.0 1.0");811 this->addVertexTexture ( "1.0 1.0");812 this->addVertexTexture ( "0.0 2.0");813 this->addVertexTexture ( "1.0 2.0");814 this->addVertexTexture ( "0.0 3.0");815 this->addVertexTexture ( "1.0 3.0");816 this->addVertexTexture ( "0.0 4.0");817 this->addVertexTexture ( "1.0 4.0");818 this->addVertexTexture ( "2.0 0.0");819 this->addVertexTexture ( "2.0 1.0");820 this->addVertexTexture ( "-1.0 0.0");821 this->addVertexTexture ( "-1.0 1.0");822 823 this->addVertexNormal ( "0.0 0.0 1.0");824 this->addVertexNormal ( "0.0 0.0 1.0");825 this->addVertexNormal ( "0.0 0.0 1.0");826 this->addVertexNormal ( "0.0 0.0 1.0");827 this->addVertexNormal ( "0.0 1.0 0.0");828 this->addVertexNormal ( "0.0 1.0 0.0");829 this->addVertexNormal ( "0.0 1.0 0.0");830 this->addVertexNormal ( "0.0 1.0 0.0");831 this->addVertexNormal ( "0.0 0.0 -1.0");832 this->addVertexNormal ( "0.0 0.0 -1.0");833 this->addVertexNormal ( "0.0 0.0 -1.0");834 this->addVertexNormal ( "0.0 0.0 -1.0");835 this->addVertexNormal ( "0.0 -1.0 0.0");836 this->addVertexNormal ( "0.0 -1.0 0.0");837 this->addVertexNormal ( "0.0 -1.0 0.0");838 this->addVertexNormal ( "0.0 -1.0 0.0");839 this->addVertexNormal ( "1.0 0.0 0.0");840 this->addVertexNormal ( "1.0 0.0 0.0");841 this->addVertexNormal ( "1.0 0.0 0.0");842 this->addVertexNormal ( "1.0 0.0 0.0");843 this->addVertexNormal ( "-1.0 0.0 0.0");844 this->addVertexNormal ( "-1.0 0.0 0.0");845 this->addVertexNormal ( "-1.0 0.0 0.0");846 this->addVertexNormal ( "-1.0 0.0 0.0");799 this->addVertex (-0.5, -0.5, 0.5); 800 this->addVertex (0.5, -0.5, 0.5); 801 this->addVertex (-0.5, 0.5, 0.5); 802 this->addVertex (0.5, 0.5, 0.5); 803 this->addVertex (-0.5, 0.5, -0.5); 804 this->addVertex (0.5, 0.5, -0.5); 805 this->addVertex (-0.5, -0.5, -0.5); 806 this->addVertex (0.5, -0.5, -0.5); 807 808 this->addVertexTexture (0.0, 0.0); 809 this->addVertexTexture (1.0, 0.0); 810 this->addVertexTexture (0.0, 1.0); 811 this->addVertexTexture (1.0, 1.0); 812 this->addVertexTexture (0.0, 2.0); 813 this->addVertexTexture (1.0, 2.0); 814 this->addVertexTexture (0.0, 3.0); 815 this->addVertexTexture (1.0, 3.0); 816 this->addVertexTexture (0.0, 4.0); 817 this->addVertexTexture (1.0, 4.0); 818 this->addVertexTexture (2.0, 0.0); 819 this->addVertexTexture (2.0, 1.0); 820 this->addVertexTexture (-1.0, 0.0); 821 this->addVertexTexture (-1.0, 1.0); 822 823 this->addVertexNormal (0.0, 0.0, 1.0); 824 this->addVertexNormal (0.0, 0.0, 1.0); 825 this->addVertexNormal (0.0, 0.0, 1.0); 826 this->addVertexNormal (0.0, 0.0, 1.0); 827 this->addVertexNormal (0.0, 1.0, 0.0); 828 this->addVertexNormal (0.0, 1.0, 0.0); 829 this->addVertexNormal (0.0, 1.0, 0.0); 830 this->addVertexNormal (0.0, 1.0, 0.0); 831 this->addVertexNormal (0.0, 0.0, -1.0); 832 this->addVertexNormal (0.0, 0.0, -1.0); 833 this->addVertexNormal (0.0, 0.0, -1.0); 834 this->addVertexNormal (0.0, 0.0, -1.0); 835 this->addVertexNormal (0.0, -1.0, 0.0); 836 this->addVertexNormal (0.0, -1.0, 0.0); 837 this->addVertexNormal (0.0, -1.0, 0.0); 838 this->addVertexNormal (0.0, -1.0, 0.0); 839 this->addVertexNormal (1.0, 0.0, 0.0); 840 this->addVertexNormal (1.0, 0.0, 0.0); 841 this->addVertexNormal (1.0, 0.0, 0.0); 842 this->addVertexNormal (1.0, 0.0, 0.0); 843 this->addVertexNormal (-1.0, 0.0, 0.0); 844 this->addVertexNormal (-1.0, 0.0, 0.0); 845 this->addVertexNormal (-1.0, 0.0, 0.0); 846 this->addVertexNormal (-1.0, 0.0, 0.0); 847 847 848 848 /* normaleLess-testingMode … … 855 855 */ 856 856 857 this->addFace ("1/1/1 2/2/2 4/4/3 3/3/4"); 858 this->addFace ("3/3/5 4/4/6 6/6/7 5/5/8"); 859 this->addFace ("5/5/9 6/6/10 8/8/11 7/7/12"); 860 this->addFace ("7/7/13 8/8/14 2/10/15 1/9/16"); 861 this->addFace ("2/2/17 8/11/18 6/12/19 4/4/20"); 862 this->addFace ("7/13/21 1/1/22 3/3/23 5/14/24"); 863 864 } 865 866 /** 867 \brief Builds a Sphere into the Model 868 */ 869 void Model::sphereModel() 870 { 871 int detail = 30; 872 if (detail <= 0) detail = 1; 857 this->addFace (4, 3, 1,1,1, 2,2,2, 4,4,3, 3,3,4); 858 this->addFace (4, 3, 3,3,5, 4,4,6, 6,6,7, 5,5,8); 859 this->addFace (4, 3, 5,5,9, 6,6,10, 8,8,11, 7,7,12); 860 this->addFace (4, 3, 7,7,13, 8,8,14, 2,10,15, 1,9,16); 861 this->addFace (4, 3, 2,2,17, 8,11,18, 6,12,19, 4,4,20); 862 this->addFace (4, 3, 7,13,21, 1,1,22, 3,3,23, 5,14,24); 863 864 } 865 866 /** 867 \brief Builds a Sphere into the Model. 868 \param size The radius of the Sphere. 869 \param detail The detail of the Sphere. 870 */ 871 void Model::sphereModel(float size, unsigned int detail) 872 { 873 int vertexCount = 0; 874 if (detail <= 0) 875 detail = 1; 876 // detail = 2; // make it even 873 877 float df = (float)detail; 874 for (float i = 0.0; i < df/2; i+=1.0) 875 { 876 for (float j = 0.0; j < df; j+=1.0) 877 { 878 float vz = i/df *2.0*PI - PI/2.0; 879 this->addVertex(cos(j/df*2.0*PI) * cos(vz) , 880 sin(j/df*2.0*PI) * cos(vz), 881 sin(vz)); 882 //if (j==0.0) 883 //printf ("%f %f\n", vz, sin (vz)); 884 if (i==0.0) 885 PRINTF(0)("%f, %f\n", j/df*2.0*PI, cos(j/df*PI)); 886 } 887 } 888 vertices->debug(); 889 for (int i = 0; i < detail/2; i++) 890 for (int j = 1; j < detail; j++) 891 { 892 unsigned int v1,v2,v3,v4; 893 v1 = i*detail +j; 894 895 /* if (j+1 == detail) 896 { 897 v2 = i*detail +1; 898 v3 = i*detail+detail + 1; 899 } 900 else*/ 901 { 902 v2 = i*detail +j+1; 903 v3 = i*detail+detail + j+1; 904 } 905 v4 = i*detail+detail + j; 906 //printf("%i %i %i %i\n", v1, v2, v3, v4); 907 this->addFace(4, 0, v1, v2, v3, v4); 908 } 909 } 910 878 879 // defining the Vertices 880 for (float i = 0; i < df *2.0; i+=1.0) 881 { 882 float vi = i/df *PI; 883 for (float j = -df / 2.0 +1.0; j < df / 2.0; j+=1.0 *df/(df+1.0)) 884 { 885 float vj = j/df *PI; 886 this->addVertex(size * cos(vi) * cos(vj), 887 size * sin(vj), 888 size * sin(vi) * cos(vj)); 889 this->addVertexTexture(i / (df *2.0), (j-1.0)/(df)+.5); 890 vertexCount++; 891 } 892 } 893 this->addVertex(0, -size, 0); 894 this->addVertex(0, size, 0); 895 896 // defining the binding Faces. 897 unsigned int v1, v2, v3, v4; 898 for (int i = 0; i <= detail * 2 -1; i++) 899 { 900 for (int j = 0; j <= detail; j++) 901 { 902 903 v1 = i*detail + j; 904 v4 = i*detail + (j+1); 905 906 if (i == detail*2 -1) 907 { 908 v2 = j; 909 v3 = j+1; 910 } 911 else 912 { 913 v2 = (i+1)*detail + j; 914 v3 = (i+1)*detail + (j+1); 915 } 916 917 if (j == 0) 918 { 919 v1 = vertexCount+1; 920 this->addFace(3, 2, v1, v1, v3, v3, v4, v4); 921 } 922 else if (j == detail) 923 { 924 v3 = vertexCount+2; 925 this->addFace(3, 2, v1, v1, v2, v2, v3, v3); 926 } 927 else 928 this->addFace(4, 2, v1, v1, v2, v2, v3, v3, v4, v4); 929 } 930 } 931 } 911 932 /** 912 933 \brief Creates a Cylinder. … … 955 976 956 977 } 978 979 980 void Model::coneModel(float size, unsigned int detail) 981 { 982 983 984 }
Note: See TracChangeset
for help on using the changeset viewer.