@@ -47,10 +47,12 @@ NodeModel *M5 = new NodeModel(Cylinder);
4747NodeModel *M6 = new NodeModel(Torus);
4848NodeModel *M7 = new NodeModel(Tetrahedron);
4949
50+ Vector3D tempVec3;
51+
5052// function which will populate a sample graph
5153void initGraph (){
5254 // temporary place which holds out values
53- Vector3D tempVec3;
55+ // Vector3D tempVec3;
5456
5557
5658 // TRANSFORMATION
@@ -93,23 +95,13 @@ void initGraph(){
9395
9496void runGraph (){
9597 // temporary place which holds out values
96- Vector3D tempVec3;
98+ // Vector3D tempVec3;
9799
98100
99101 // TRANSFORMATION
100102 // a tranlation transformation node
101103 // how much translation
102- tempVec3.x = 1000 ;
103- tempVec3.y = 10 ;
104- tempVec3.z = 10 ;
105- T1 = new NodeTransform (Translate, tempVec3);
106-
107104
108- // add the node as a child of root node
109- // T1 = new NodeTransform(Translate, tempVec3);
110- // //insert the node into the graph
111- // SG->insertChildNodeHere(T1);
112- // //go to the child node
113105// SG->goToChild(0);
114106
115107
@@ -125,6 +117,10 @@ void runGraph(){
125117// NodeModel *M7 = new NodeModel(Tetrahedron);
126118
127119
120+ // tempVec3.x = 2;
121+ // tempVec3.y = 1;
122+ // tempVec3.z = 1;
123+
128124
129125// SG->insertChildNodeHere(M2);
130126//
@@ -136,30 +132,52 @@ void runGraph(){
136132 // THE SAME FLOW CAN BE USED TO DYNAMICALLY ADD NODES
137133 // DURING RUNTIME */
138134 if (teapot){
135+ T1 = new NodeTransform (Translate, tempVec3);
136+ SG->insertChildNodeHere (T1);
137+ SG->goToChild (SG -> returnChildNode ());
138+
139139 teapot = false ;
140140 SG->insertChildNodeHere (M1);
141141 }
142142 else if (sphere){
143+ T1 = new NodeTransform (Translate, tempVec3);
144+ SG->insertChildNodeHere (T1);
145+ SG->goToChild (SG -> returnChildNode ());
143146 sphere = false ;
144147 SG->insertChildNodeHere (M2);
145148 }
146149 else if (cube){
150+ T1 = new NodeTransform (Translate, tempVec3);
151+ SG->insertChildNodeHere (T1);
152+ SG->goToChild (SG -> returnChildNode ());
147153 cube = false ;
148154 SG->insertChildNodeHere (M3);
149155 }
150156 else if (cone){
157+ T1 = new NodeTransform (Translate, tempVec3);
158+ SG->insertChildNodeHere (T1);
159+ SG->goToChild (SG -> returnChildNode ());
151160 cone = false ;
152161 SG->insertChildNodeHere (M4);
153162 }
154163 else if (cylinder){
164+ T1 = new NodeTransform (Translate, tempVec3);
165+ SG->insertChildNodeHere (T1);
166+ SG->goToChild (SG -> returnChildNode ());
155167 cylinder = false ;
156168 SG->insertChildNodeHere (M5);
157169 }
158170 else if (torus){
171+ T1 = new NodeTransform (Translate, tempVec3);
172+ SG->insertChildNodeHere (T1);
173+ SG->goToChild (SG -> returnChildNode ());
159174 torus = false ;
160175 SG->insertChildNodeHere (M6);
161176 }
162177 else if (thedron){
178+ T1 = new NodeTransform (Translate, tempVec3);
179+ SG->insertChildNodeHere (T1);
180+ SG->goToChild (SG -> returnChildNode ());
163181 thedron = false ;
164182 SG->insertChildNodeHere (M7);
165183 }
@@ -204,6 +222,19 @@ void keyboard(unsigned char key, int x, int y)
204222 case ' J' :
205223 thedron = true ;
206224 break ;
225+ case ' m' :
226+ // TRANSFORMATION
227+ // a tranlation transformation node
228+ // how much translation
229+ tempVec3.x = 5 ;
230+ tempVec3.y = 5 ;
231+ tempVec3.z = 5 ;
232+ // add the node as a child of root node
233+ T1 = new NodeTransform (Translate, tempVec3);
234+ // //insert the node into the graph
235+ SG->insertChildNodeHere (T1);
236+ // go to the child node
237+ SG->goToChild (SG -> returnChildNode ());
207238 }
208239 glutPostRedisplay ();
209240}
0 commit comments