예제 #1
0
void mouseMotion(int x, int y)
{
    float dx, dy;
    dx = (float)(x - mouse_old_x);
    dy = (float)(y - mouse_old_y);

    if (button_mask & 0x01) 
    {// left button
        head += dy * 0.2f;
        pitch += dx * 0.2f;
    } 
    else if (button_mask & 0x02) 
    {// right button
        eye_distance -= dy * 0.01f;
    }
    else if (button_mask & 0x04)
    {// middle button
        glm::vec3 vdir(lookat - cam_pos);
        glm::vec3 u(glm::normalize(glm::cross(vdir, up)));
        glm::vec3 v(glm::normalize(glm::cross(u, vdir)));

        lookat += 0.01f * (dy * v - dx * u);
    }

    mouse_old_x = x;
    mouse_old_y = y;
}
예제 #2
0
void
BlackBot::doorCollision(unsigned did, const V2D &cv)
{
  //  std::cerr << "I am "<<pid<<" and collided with door: "<<did<<"\n";
  dir=vdir(-cv);
  followMode=false;
}
예제 #3
0
void
BlackBot::follow()
{
  const Player &me(client.getPlayers()[pid]);
  const Player &other(client.getPlayers()[rabbit]);
  V2D diff(other.m_pos-me.m_pos);
  dir=vdir(diff);
}
예제 #4
0
void Camera::MouseChangeLookat(float coe, float dx, float dy)
{
    glm::vec3 vdir(m_lookat - m_position);
    glm::vec3 u(glm::normalize(glm::cross(vdir, m_up)));
    glm::vec3 v(glm::normalize(glm::cross(u, vdir)));

    m_lookat += coe * (dy * v - dx * u);
    updateViewMatrix();
}
예제 #5
0
void 
BlackBot::wallCollision(const std::vector<FWEdge::EID> &eids, const V2D &cv)
{
  /*  std::cerr << "I am "<<pid<<" and collided with wall(s):";
      for (unsigned w=0;w<eids.size();++w){
      std::cerr << " "<<eids[w];
      }
      std::cerr << "\n";
  */
  dir=vdir(cv.rot(M_PI/180*(threshold+90)));
  followMode=false;
}
예제 #6
0
void WMOModelInstance::draw()
{
  if (!model) return;

  glPushMatrix();

  glTranslatef(pos.x, pos.y, pos.z);
  Vec3D vdir(-dir.z, dir.x, dir.y);
  glQuaternionRotate(vdir, w);
  glScalef(sc, -sc, -sc);

  model->draw();
  glPopMatrix();
}
예제 #7
0
void ModelInstance::draw2(const Vec3D& ofs, const float rot)
{
	Vec3D tpos(ofs + pos);
	rotate(ofs.x,ofs.z,&tpos.x,&tpos.z,rot*PI/180.0f);
	if ( (tpos - gWorld->camera).lengthSquared() > (gWorld->doodaddrawdistance2*model->rad*sc) ) return;
	if (!gWorld->frustum.intersectsSphere(tpos, model->rad*sc)) return;

	glPushMatrix();

	glTranslatef(pos.x, pos.y, pos.z);
	Vec3D vdir(-dir.z,dir.x,dir.y);
	glQuaternionRotate(vdir,w);
	glScalef(sc,-sc,-sc);

	model->draw();
	glPopMatrix();
}
예제 #8
0
void vdir::cdup()
{
	fs::path p(path_);
	*this = vdir(p.parent_path().string());
}
예제 #9
0
void vdir::cd(std::string path)
{
	fs::path p(path);
	*this = vdir(p.string());
}