Solar System - demo scence

Functions

void operations_load_xml (const char *filename, std::vector< float > *operations)
 

Detailed Description

Function Documentation

◆ operations_load_xml()

void operations_load_xml ( const char *  filename,
std::vector< float > *  operations 
)
133 {
134 tinyxml2::XMLDocument doc;
135
136 if (doc.LoadFile(filename)) {
137 fprintf(stderr, "%s", doc.ErrorName());
138 exit(1);
139 }
140
141 tinyxml2::XMLElement *world = doc.FirstChildElement("world");
142
143 /*camera*/
144 tinyxml2::XMLElement *camera = world->FirstChildElement("camera");
145
146 tinyxml2::XMLElement *position = camera->FirstChildElement("position");
147 operations_push_transform_attributes(position, operations);
148
149 tinyxml2::XMLElement *lookAt = camera->FirstChildElement("lookAt");
150 operations_push_transform_attributes(lookAt, operations);
151
152 tinyxml2::XMLElement *up = camera->FirstChildElement("up");
153 if (up) operations_push_transform_attributes(up, operations);
154 else operations->insert(operations->end(), {0, 1, 0});
155
156 tinyxml2::XMLElement *projection = camera->FirstChildElement("projection");
157 if (projection) {
158 operations->push_back(projection->FloatAttribute("fov"));
159 operations->push_back(projection->FloatAttribute("near"));
160 operations->push_back(projection->FloatAttribute("far"));
161 } else operations->insert(operations->end(), {60, 1, 1000});
162 /*end of camera*/
163
164 // groups
165 tinyxml2::XMLElement *group = world->FirstChildElement("group");
166 operations_push_groups(group, operations);
167}
void operations_push_groups(tinyxml2::XMLElement *group, std::vector< float > *operations)
Definition: parsing.cpp:112
void operations_push_transform_attributes(tinyxml2::XMLElement *transform, std::vector< float > *operations)
Definition: parsing.cpp:45

References operations_push_groups(), and operations_push_transform_attributes().

Referenced by example1(), and xml_load_and_set_env().