FVector2D ADynamicCarController::vSample(float deltaSec)
{
	FVector2D vCand;
	float curRot, newRot, d;

	do {
		do {
			vCand = FVector2D(2.0f*rand() - RAND_MAX, 2.0f*rand() - RAND_MAX);
		} while (FVector2D::DotProduct(vCand, vCand) > (((float)RAND_MAX) * ((float)RAND_MAX)));

		vCand *= (vMax / RAND_MAX) * deltaSec;

		curRot = agent->GetActorRotation().Yaw;
		curRot = positiveAngle(curRot);

		newRot = to3D(vCand).Rotation().Yaw;
		newRot = positiveAngle(newRot);

		d = FMath::Abs(newRot - curRot);

		if (d > 90) {
			// We cannot drive forward in this direction, can we drive backwards?

			newRot += 180;
			newRot = positiveAngle(newRot);

			d = FMath::Abs(newRot - curRot);
		}

	} while (d > maxAngle * deltaSec);

	return vCand;
}
Esempio n. 2
0
static void CBglCompMouseRightClick(glCompObj *obj, GLfloat x, GLfloat y,
			     glMouseButtonType t)
{
    if (t == glMouseRightButton) 
	{
		GLfloat X, Y, Z = 0;
		to3D((int) x, (int) y, &X, &Y, &Z);
    }
}
Esempio n. 3
0
static void appmouse_drag(ViewInfo* v,int x,int y)
{
    v->mouse.pos.x=x;
    v->mouse.pos.y=y;
    to3D( x,y, &v->mouse.GLpos.x,&v->mouse.GLpos.y,&v->mouse.GLpos.z);
    prevX=v->mouse.GLpos.x;
    prevY=v->mouse.GLpos.y;
    apply_actions(v,x,y);
}
Esempio n. 4
0
static void appmouse_down(ViewInfo* v,int x,int y)
{
    view->mouse.dragX = 0;
    view->mouse.dragY = 0;
    v->mouse.down=1;
    v->mouse.initPos.x=x;
    v->mouse.initPos.y=y;
    v->mouse.pos.x=x;
    v->mouse.pos.y=y;
    
    to3D(x,y,&v->mouse.GLinitPos.x,&v->mouse.GLinitPos.y,&v->mouse.GLinitPos.z);
    to3D( x,y, &v->mouse.GLpos.x,&v->mouse.GLpos.y,&v->mouse.GLpos.z);

    prevX=0;
    prevY=0;

/*    view->Selection.X = view->mouse.GLpos.x;
    view->Selection.Y = view->mouse.GLpos.y;*/
}
Esempio n. 5
0
void CollisionActor::update(float d_t) {
  // qDebug() << "Actor.update()" << this->id.c_str();
  assert(sceneNode != NULL);
  moveVector *= possibleMoveRatio;
  sceneNode = (Ogre::SceneNode*) sceneNode;
  sceneNode->translate(to3D(moveVector, sceneNode->getPosition().z));
  collisionShape.translate(to2D(sceneNode->getPosition()));

  moveVector = Ogre::Vector2::ZERO;

  possibleMoveRatio = 1.0;
}
Esempio n. 6
0
static void appmouse_up(ViewInfo* v,int x,int y)
{

    /* int a; */
    v->mouse.down=0;
    v->mouse.finalPos.x=x;
    v->mouse.finalPos.y=y;
    /* a=get_mode(v); */
    to3D(x,y, &v->mouse.GLfinalPos.x,&v->mouse.GLfinalPos.y,&v->mouse.GLfinalPos.z);
    if(singleclick(v))
    {
	if (v->mouse.t==glMouseLeftButton)
	    appmouse_left_click(v,x,y);
	if (v->mouse.t==glMouseRightButton)
	    appmouse_right_click(v,x,y);
    }
    apply_actions(v,x,y);
    view->mouse.dragX = 0;
    view->mouse.dragY = 0;
    view->arcball->isDragging=0;


}
Esempio n. 7
0
void NurbsCurve<float,2>::drawAaImg(Image_Color& Img, const Color& color, int precision, int alpha){
  NurbsCurve<float,3> C ;
  to3D(*this,C) ; 
  C.drawAaImg(Img,color,precision,alpha) ;
}
Esempio n. 8
0
int NurbsCurve<float,2>::writeVRML97(ostream& fout,float radius,int K, const Color& color,int Nu,int Nv, float u_s, float u_e) const{
  NurbsCurve<float,3> C ;
  to3D(*this,C) ; 
  return C.writeVRML97(fout,radius,K,color,Nu,Nv,u_s,u_e) ;
}
Esempio n. 9
0
int NurbsCurve<float,2>::writeVRML97(const char* filename,float radius,int K, const Color& color,int Nu,int Nv, float u_s, float u_e) const{
  NurbsCurve<float,3> C ;
  to3D(*this,C) ; 
  return C.writeVRML97(filename,radius,K,color,Nu,Nv,u_s,u_e) ;
}
Esempio n. 10
0
void appmouse_move(ViewInfo* v,int x,int y)
{
    to3D( x,y, &v->mouse.GLpos.x,&v->mouse.GLpos.y,&v->mouse.GLpos.z);
}
Esempio n. 11
0
int NurbsCurve<double,2>::writeVRML97(ostream& fout,double radius,int K, const Color& color,int Nu,int Nv, double u_s, double u_e) const{
  NurbsCurve<double,3> C ;
  to3D(*this,C) ; 
  return C.writeVRML97(fout,radius,K,color,Nu,Nv,u_s,u_e) ;
}
Esempio n. 12
0
int NurbsCurve<double,2>::writeVRML97(const char* filename,double radius,int K, const Color& color,int Nu,int Nv, double u_s, double u_e) const{
  NurbsCurve<double,3> C ;
  to3D(*this,C) ; 
  return C.writeVRML97(filename,radius,K,color,Nu,Nv,u_s,u_e) ;
}
Esempio n. 13
0
CollisionActor* CollisionActor::teleport(Ogre::Vector2 to) {
  this->moveVector = Ogre::Vector2::ZERO;
  sceneNode->setPosition(to3D(to, sceneNode->getPosition().z));
  collisionShape.translate(to2D(sceneNode->getPosition()));
  return this;
}