~mulder-nebulon/openracing/PhysX

« back to all changes in this revision

Viewing changes to src/graphic/OScene.cs

  • Committer: Nagy Imre
  • Date: 2009-03-14 12:52:57 UTC
  • Revision ID: mulder@codenode-20090314125257-cj2uude8ojrq72r4
Added throttle, fixed Barcelona track offset

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
//          mCtx.RegisterResourcePath("/home/mulder/projects/trunk/track/Barcelona/Textures");
136
136
            XmlTextReader reader = new XmlTextReader ("/home/mulder/projects/trunk/track/Barcelona/barcelona.osm");
137
137
 
138
 
            Entity entity = null;
 
138
            Entity      entity = null;
 
139
            SceneNode   node   = null;
139
140
            while (reader.Read())
140
141
                {
141
142
                    if (reader.NodeType==XmlNodeType.Element)
144
145
                                {
145
146
                                    reader.MoveToContent();
146
147
                                    entity = mSceneMgr.CreateEntity(reader.GetAttribute("filename"), reader.GetAttribute("filename"));
147
 
                                    mSceneMgr.RootSceneNode.AttachObject(entity); // TODO: should create scenenode for each object!
 
148
                                    node   = mSceneMgr.RootSceneNode.CreateChildSceneNode();
 
149
                                    node.AttachObject(entity); 
 
150
                                    // mSceneMgr.RootSceneNode.AttachObject(entity); // TODO: should create scenenode for each object!
148
151
                                }
149
152
                                
150
153
                            if (entity!=null)
152
155
                                    if (reader.Name=="position")
153
156
                                        {
154
157
                                            reader.MoveToContent();
155
 
                                            // entity.SetPosition(0,0,0);
 
158
                                            float x = Convert.ToSingle(reader.GetAttribute("x"));
 
159
                                            float y = Convert.ToSingle(reader.GetAttribute("y"));
 
160
                                            float z = Convert.ToSingle(reader.GetAttribute("z"));
 
161
                                            if (false)
 
162
                                                {
 
163
                                                    x =  7318;
 
164
                                                    y = -40;
 
165
                                                    z = -372;
 
166
                                                }
 
167
                                            else if (true)
 
168
                                                {
 
169
                                                    x = 218;
 
170
                                                    y = 827;
 
171
                                                    z = -552;
 
172
                                                }                                                           
 
173
                                            node.SetPosition((float)x, (float)y, (float)z);
 
174
                                            //node.SetPosition((float) 0, (float)0, (float)0);
156
175
                                        }
157
176
                                    else if (reader.Name=="rotation")
158
177
                                        {
159
178
                                            reader.MoveToContent();
 
179
                                            float x = Convert.ToSingle(reader.GetAttribute("x"));
 
180
                                            float y = Convert.ToSingle(reader.GetAttribute("y"));
 
181
                                            float z = Convert.ToSingle(reader.GetAttribute("z"));
 
182
                                            float w = Convert.ToSingle(reader.GetAttribute("w"));
 
183
                                            node.SetOrientation((float)w, (float)x, (float)y, (float)z);
 
184
//                                          node.SetInheritOrientation(true);
 
185
                                            //node.SetOrientation((float)-90,0,1,0);
 
186
                                            
160
187
                                        }
161
188
                                    else if (reader.Name=="scale")              // scale is not yet supported
162
189
                                        {}    
163
190
                                }
164
191
                            
165
192
                        }
166
 
                    switch (reader.NodeType)
167
 
                        {
168
 
                            case XmlNodeType.Element: Console.Out.Write("<1 "+ reader.Name); Console.Out.WriteLine(">");        break;
169
 
                            case XmlNodeType.Text: Console.Out.Write("<2 "+ reader.Value); Console.Out.WriteLine(">");  break;
170
 
                            case XmlNodeType.EndElement: Console.Out.Write("<3 "+ reader.Name); Console.Out.WriteLine(">");break;
171
 
                            
172
 
                        }
173
193
                }
174
194
            
175
 
            
176
195
            Console.Out.WriteLine("============================= TRACKS LOADED ===================================");
177
196
        }
178
197