@@ -31,46 +31,57 @@ NodePath create_cube(const std::string& name)
3131 GeomVertexWriter normal (vdata, InternalName::get_normal ());
3232 GeomVertexWriter texcoord (vdata, InternalName::get_texcoord ());
3333
34- vertex.add_data3f (-0 .5f , -0 .5f , -0 .5f ); normal.add_data3f (0 .0f , 0 .0f , -1 .0f ); texcoord.add_data2f (0 .25f , 1 /3 .0f ); // 0
35- vertex.add_data3f (-0 .5f , -0 .5f , -0 .5f ); normal.add_data3f (0 .0f , -1 .0f , 0 .0f ); texcoord.add_data2f (0 .25f , 1 /3 .0f ); // 1
36- vertex.add_data3f (-0 .5f , -0 .5f , -0 .5f ); normal.add_data3f (-1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .25f , 1 /3 .0f ); // 2
37- vertex.add_data3f (+0 .5f , -0 .5f , -0 .5f ); normal.add_data3f (0 .0f , 0 .0f , -1 .0f ); texcoord.add_data2f (0 .5f , 1 /3 .0f ); // 3
38- vertex.add_data3f (+0 .5f , -0 .5f , -0 .5f ); normal.add_data3f (0 .0f , -1 .0f , 0 .0f ); texcoord.add_data2f (0 .5f , 1 /3 .0f ); // 4
39- vertex.add_data3f (+0 .5f , -0 .5f , -0 .5f ); normal.add_data3f (1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .5f , 1 /3 .0f ); // 5
40- vertex.add_data3f (+0 .5f , +0 .5f , -0 .5f ); normal.add_data3f (0 .0f , 0 .0f , -1 .0f ); texcoord.add_data2f (0 .5f , 0 .0f ); // 6
41- vertex.add_data3f (+0 .5f , +0 .5f , -0 .5f ); normal.add_data3f (0 .0f , 1 .0f , 0 .0f ); texcoord.add_data2f (0 .75f , 1 /3 .0f ); // 7
42- vertex.add_data3f (+0 .5f , +0 .5f , -0 .5f ); normal.add_data3f (1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .75f , 1 /3 .0f ); // 8
43- vertex.add_data3f (-0 .5f , +0 .5f , -0 .5f ); normal.add_data3f (0 .0f , 0 .0f , -1 .0f ); texcoord.add_data2f (0 .25f , 0 .0f ); // 9
44- vertex.add_data3f (-0 .5f , +0 .5f , -0 .5f ); normal.add_data3f (0 .0f , 1 .0f , 0 .0f ); texcoord.add_data2f (1 .0f , 1 /3 .0f ); // 10
45- vertex.add_data3f (-0 .5f , +0 .5f , -0 .5f ); normal.add_data3f (-1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .0f , 1 /3 .0f ); // 11
46- vertex.add_data3f (-0 .5f , -0 .5f , +0 .5f ); normal.add_data3f (0 .0f , 0 .0f , 1 .0f ); texcoord.add_data2f (0 .25f , 2 /3 .0f ); // 12
47- vertex.add_data3f (-0 .5f , -0 .5f , +0 .5f ); normal.add_data3f (0 .0f , -1 .0f , 0 .0f ); texcoord.add_data2f (0 .25f , 2 /3 .0f ); // 13
48- vertex.add_data3f (-0 .5f , -0 .5f , +0 .5f ); normal.add_data3f (-1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .25f , 2 /3 .0f ); // 14
49- vertex.add_data3f (+0 .5f , -0 .5f , +0 .5f ); normal.add_data3f (0 .0f , 0 .0f , 1 .0f ); texcoord.add_data2f (0 .5f , 2 /3 .0f ); // 15
50- vertex.add_data3f (+0 .5f , -0 .5f , +0 .5f ); normal.add_data3f (0 .0f , -1 .0f , 0 .0f ); texcoord.add_data2f (0 .5f , 2 /3 .0f ); // 16
51- vertex.add_data3f (+0 .5f , -0 .5f , +0 .5f ); normal.add_data3f (1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .5f , 2 /3 .0f ); // 17
52- vertex.add_data3f (+0 .5f , +0 .5f , +0 .5f ); normal.add_data3f (0 .0f , 0 .0f , 1 .0f ); texcoord.add_data2f (0 .5f , 1 .0f ); // 18
53- vertex.add_data3f (+0 .5f , +0 .5f , +0 .5f ); normal.add_data3f (0 .0f , 1 .0f , 0 .0f ); texcoord.add_data2f (0 .75f , 2 /3 .0f ); // 19
54- vertex.add_data3f (+0 .5f , +0 .5f , +0 .5f ); normal.add_data3f (1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .75f , 2 /3 .0f ); // 20
55- vertex.add_data3f (-0 .5f , +0 .5f , +0 .5f ); normal.add_data3f (0 .0f , 0 .0f , 1 .0f ); texcoord.add_data2f (0 .25f , 1 .0f ); // 21
56- vertex.add_data3f (-0 .5f , +0 .5f , +0 .5f ); normal.add_data3f (0 .0f , 1 .0f , 0 .0f ); texcoord.add_data2f (1 .0f , 2 /3 .0f ); // 22
57- vertex.add_data3f (-0 .5f , +0 .5f , +0 .5f ); normal.add_data3f (-1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .0f , 2 /3 .0f ); // 23
34+ // top
35+ vertex.add_data3f (+0 .5f , +0 .5f , +0 .5f ); normal.add_data3f ( 0 .0f , 0 .0f , 1 .0f ); texcoord.add_data2f (0 .5f , 1 .0f ); // 0
36+ vertex.add_data3f (-0 .5f , +0 .5f , +0 .5f ); normal.add_data3f ( 0 .0f , 0 .0f , 1 .0f ); texcoord.add_data2f (0 .25f , 1 .0f ); // 1
37+ vertex.add_data3f (+0 .5f , -0 .5f , +0 .5f ); normal.add_data3f ( 0 .0f , 0 .0f , 1 .0f ); texcoord.add_data2f (0 .5f , 2 /3 .0f ); // 2
38+ vertex.add_data3f (-0 .5f , -0 .5f , +0 .5f ); normal.add_data3f ( 0 .0f , 0 .0f , 1 .0f ); texcoord.add_data2f (0 .25f , 2 /3 .0f ); // 3
39+
40+ // right
41+ vertex.add_data3f (+0 .5f , +0 .5f , -0 .5f ); normal.add_data3f ( 1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .75f , 1 /3 .0f ); // 4
42+ vertex.add_data3f (+0 .5f , +0 .5f , +0 .5f ); normal.add_data3f ( 1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .75f , 2 /3 .0f ); // 5
43+ vertex.add_data3f (+0 .5f , -0 .5f , -0 .5f ); normal.add_data3f ( 1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .5f , 1 /3 .0f ); // 6
44+ vertex.add_data3f (+0 .5f , -0 .5f , +0 .5f ); normal.add_data3f ( 1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .5f , 2 /3 .0f ); // 7
45+
46+ // back
47+ vertex.add_data3f (-0 .5f , +0 .5f , -0 .5f ); normal.add_data3f ( 0 .0f , 1 .0f , 0 .0f ); texcoord.add_data2f (1 .0f , 1 /3 .0f ); // 8
48+ vertex.add_data3f (-0 .5f , +0 .5f , +0 .5f ); normal.add_data3f ( 0 .0f , 1 .0f , 0 .0f ); texcoord.add_data2f (1 .0f , 2 /3 .0f ); // 9
49+ vertex.add_data3f (+0 .5f , +0 .5f , +0 .5f ); normal.add_data3f ( 0 .0f , 1 .0f , 0 .0f ); texcoord.add_data2f (0 .75f , 2 /3 .0f ); // 10
50+ vertex.add_data3f (+0 .5f , +0 .5f , -0 .5f ); normal.add_data3f ( 0 .0f , 1 .0f , 0 .0f ); texcoord.add_data2f (0 .75f , 1 /3 .0f ); // 11
51+
52+ // bottom
53+ vertex.add_data3f (-0 .5f , -0 .5f , -0 .5f ); normal.add_data3f ( 0 .0f , 0 .0f , -1 .0f ); texcoord.add_data2f (0 .25f , 1 /3 .0f ); // 12
54+ vertex.add_data3f (-0 .5f , +0 .5f , -0 .5f ); normal.add_data3f ( 0 .0f , 0 .0f , -1 .0f ); texcoord.add_data2f (0 .25f , 0 .0f ); // 13
55+ vertex.add_data3f (+0 .5f , -0 .5f , -0 .5f ); normal.add_data3f ( 0 .0f , 0 .0f , -1 .0f ); texcoord.add_data2f (0 .5f , 1 /3 .0f ); // 14
56+ vertex.add_data3f (+0 .5f , +0 .5f , -0 .5f ); normal.add_data3f ( 0 .0f , 0 .0f , -1 .0f ); texcoord.add_data2f (0 .5f , 0 .0f ); // 15
57+
58+ // front
59+ vertex.add_data3f (-0 .5f , -0 .5f , -0 .5f ); normal.add_data3f ( 0 .0f , -1 .0f , 0 .0f ); texcoord.add_data2f (0 .25f , 1 /3 .0f ); // 16
60+ vertex.add_data3f (+0 .5f , -0 .5f , -0 .5f ); normal.add_data3f ( 0 .0f , -1 .0f , 0 .0f ); texcoord.add_data2f (0 .5f , 1 /3 .0f ); // 17
61+ vertex.add_data3f (-0 .5f , -0 .5f , +0 .5f ); normal.add_data3f ( 0 .0f , -1 .0f , 0 .0f ); texcoord.add_data2f (0 .25f , 2 /3 .0f ); // 18
62+ vertex.add_data3f (+0 .5f , -0 .5f , +0 .5f ); normal.add_data3f ( 0 .0f , -1 .0f , 0 .0f ); texcoord.add_data2f (0 .5f , 2 /3 .0f ); // 19
63+
64+ // left
65+ vertex.add_data3f (-0 .5f , -0 .5f , -0 .5f ); normal.add_data3f (-1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .25f , 1 /3 .0f ); // 20
66+ vertex.add_data3f (-0 .5f , -0 .5f , +0 .5f ); normal.add_data3f (-1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .25f , 2 /3 .0f ); // 21
67+ vertex.add_data3f (-0 .5f , +0 .5f , -0 .5f ); normal.add_data3f (-1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .0f , 1 /3 .0f ); // 22
68+ vertex.add_data3f (-0 .5f , +0 .5f , +0 .5f ); normal.add_data3f (-1 .0f , 0 .0f , 0 .0f ); texcoord.add_data2f (0 .0f , 2 /3 .0f ); // 23
5869
5970 // create indices
6071 PT (GeomTriangles) prim = new GeomTriangles (Geom::UsageHint::UH_static);
6172 prim->reserve_num_vertices (36 );
62- prim->add_vertices (0 , 6 , 3 );
63- prim->add_vertices (0 , 9 , 6 );
64- prim->add_vertices (12 , 15 , 18 );
65- prim->add_vertices (12 , 18 , 21 );
66- prim->add_vertices (22 , 19 , 7 );
67- prim->add_vertices (22 , 7 , 10 );
68- prim->add_vertices (13 , 4 , 16 );
69- prim->add_vertices (13 , 1 , 4 );
70- prim->add_vertices (14 , 23 , 11 );
71- prim->add_vertices (14 , 11 , 2 );
72- prim->add_vertices (17 , 5 , 8 );
73- prim->add_vertices (17 , 8 , 20 );
73+ prim->add_vertices (0 , 1 , 2 );
74+ prim->add_vertices (3 , 2 , 1 );
75+ prim->add_vertices (4 , 5 , 7 );
76+ prim->add_vertices (6 , 4 , 7 );
77+ prim->add_vertices (10 , 11 , 9 );
78+ prim->add_vertices (8 , 9 , 11 );
79+ prim->add_vertices (12 , 13 , 14 );
80+ prim->add_vertices (15 , 14 , 13 );
81+ prim->add_vertices (16 , 17 , 18 );
82+ prim->add_vertices (19 , 18 , 17 );
83+ prim->add_vertices (20 , 21 , 22 );
84+ prim->add_vertices (23 , 22 , 21 );
7485 prim->close_primitive ();
7586
7687 PT (Geom) geom = new Geom (vdata);
0 commit comments