Ejemplo n.º 1
0
			inline void Clear(void) {
				m_id = -1;
				m_first = false;
				
				radiusX = 0.0f;
				radiusY = 0.0f;
				rotationAngle = 0.0f;
				force = 0.0f;
	
				delta.Set(0.0f, 0.0f);
				position.Set(0.0f, 0.0f);
			}
Ejemplo n.º 2
0
Vec2f InterModule::unproject(const int xx, const int yy, const int h) const {
  float x = float(xx) + .5, y = float(yy) + .5;
  GLdouble proj[16], model[16];
  GLint view[4];
  GLdouble ox, oy, oz;
  Vec2f result;

  glGetDoublev(GL_PROJECTION_MATRIX, proj);
  glGetDoublev(GL_MODELVIEW_MATRIX, model);
  glGetIntegerv(GL_VIEWPORT, view);
  
  int res = gluUnProject(x, h-y, 0, model, proj, view, &ox, &oy, &oz);
  assert(res == GL_TRUE);
  result.Set(ox, oy);
  return result;  
}
Ejemplo n.º 3
0
    bool GeometryManager::Load() {
        for (auto i = sceneObjectTemplates.begin(),
                  i_e = sceneObjectTemplates.end();
             i != i_e; i++) {
            delete i->second;
        }
        sceneObjectTemplates.clear();

        std::ifstream in("templates.txt");

        if (in.is_open() == false) {
            return false;
        }

        unsigned int templates_count = 0;
        unsigned int figures_count = 0;
        unsigned int vertices_count = 0;
        float z = 0;
        float depth = 0;
        Vec2f vertex;
        std::string name = "";

        in >> templates_count;

        for (unsigned int i = 0; i < templates_count; i++) {
            name = "";
            figures_count = 0;

            in >> name;
            in >> figures_count;

            SceneObjectGeometry* g = CreateGeometry(name.c_str());

            g->figures.resize(figures_count);

            for (unsigned int j = 0; j < figures_count; j++) {
                vertices_count = 0;
                z = 0;
                depth = 0;

                in >> z;
                in >> depth;
                in >> vertices_count;

                g->figures[j].z = z;
                g->figures[j].depth = depth;
                g->figures[j].vertices.resize(vertices_count);

                for (unsigned int k = 0; k < vertices_count; k++) {
                    vertex.Set(0, 0);

                    in >> vertex.x;
                    in >> vertex.y;

                    g->figures[j].vertices[k] = vertex;
                }
            }
        }

        return true;
    }