Example #1
0
void PolarDiagram::addLine( const float &speed, const float &angle, const float &TA){
    if(debug)
        qDebug() << Q_FUNC_INFO;

    Angles aux;
    aux.insert(angle, TA);

    // setAngles() will take care if the speed already exists
    setAngles(speed, aux);
}
Example #2
0
SceneObject::SceneObject(const SceneObject &cloneFrom) : HierarchicalObject(cloneFrom.parentObject())
{
    m_pScene = cloneFrom.m_pScene;
    m_pGeometry.reset(new GeometryData(*cloneFrom.m_pGeometry.data()));
    m_RenderFlags = cloneFrom.m_RenderFlags;
    m_bHidden = cloneFrom.m_bHidden;
    m_bSerialiseGeometry = cloneFrom.m_bSerialiseGeometry;

    setPosition(cloneFrom.position());
    setAngles(cloneFrom.angles());
    setScale(cloneFrom.scale());
}
Example #3
0
void ThrowObject::Throw( const Entity *owner, float speed, const Sentient *targetent, float gravity, float throw_damage )
{
	float    traveltime;
	float    vertical_speed;
	Vector   target;
	Vector   dir;
	Vector   xydir;
	Event    *e;
	
	
	e = new Event( EV_Detach );
	ProcessEvent( e );
	
	this->owner = owner->entnum;
	edict->ownerNum = owner->entnum;
	
	damage = throw_damage;
	target = targetent->origin;
	target.z += targetent->viewheight;
	
	setMoveType( MOVETYPE_BOUNCE );
	setSolidType( SOLID_BBOX );
	edict->clipmask = MASK_PROJECTILE;
	
	dir = target - origin;
	xydir = dir;
	xydir.z = 0;
	traveltime = xydir.length() / speed;
	vertical_speed = ( dir.z / traveltime ) + ( 0.5f * gravity * sv_currentGravity->value * traveltime );
	xydir.normalize();
	
	// setup ambient flying sound
	if ( throw_sound.length() )
	{
		LoopSound( throw_sound.c_str() );
	}
	
	velocity = speed * xydir;
	velocity.z = vertical_speed;
	
	angles = velocity.toAngles();
	setAngles( angles );
	
	avelocity.x = crandom() * 200.0f;
	avelocity.y = crandom() * 200.0f;
	takedamage = DamageYes;
}
Example #4
0
joueur::joueur(char Modele, anglePts Angles, affichage*Modelisation, point Position, char Couleur, std::string Pseudo, int Level, int ID)
{

modele = Modele;
setAngles(Angles);
modelisation = Modelisation;
setPosition(Position);
couleur = Couleur;
pseudo = Pseudo;
level = Level;
id = ID;
if(modele == 0)
{
//collision.initialiser(3.5, 3.5, 7.5);
//collision.setPosition(Position);
//collision.placer(angles.angleX, angles.angleY, 0);
}
}
Example #5
0
int main()
{
    connect_to_robot();
    initialize_robot();
	setAngles();
    inputMotors();
    //wallFollowing();

    int i;
    for (i=0; i<4; i++){
        printf("%d\n", i);
        thetaAcc = 0.0;
        SPEED = SPEED + 8;
        //wallFollowing();
        wallFollowingR();
    }

}
Example #6
0
void GooDebris::Touch( Event *ev )
{
	Entity *other;
	Entity *owner;
	Vector ang;
	
	other = ev->GetEntity( 1 );
	
	if ( other == world )
	{
		vectoangles( level.impact_trace.plane.normal, ang );
		setAngles( ang );
	}
	
	if ( level.time < nexttouch )
	{
		return;
	}
	
	nexttouch = level.time + 0.5f;
	
	if ( !other || !other->isSubclassOf( Sentient ) )
	{
		return;
	}
	
	owner = G_GetEntity( this->owner );
	
	if ( !owner )
	{
		owner = world;
	}
	
	if ( !other )
	{
		return;
	}
	
	other->Damage( this, owner, damage, origin, Vector( 0.0f, 0.0f, 0.0f ), Vector( 0.0f, 0.0f, 0.0f ), 0, 0, meansofdeath );
}
SphericEmitter::SphericEmitter(const Vector3D& direction, float angleA, float angleB) :
	Emitter()
{
	setDirection(direction);
	setAngles(angleA, angleB);
}
Example #8
0
void CameraNode::applyVerticalAngle(const Geometry::Angle & angle) {
	const Geometry::Angle halfVAngle = angle * 0.5f;
	const float aspectRatio = static_cast<float>(getWidth()) / static_cast<float>(getHeight());
	const Geometry::Angle halfHAngle = Geometry::Angle::rad(std::atan(aspectRatio * std::tan(halfVAngle.rad())));
	setAngles(-halfHAngle, halfHAngle, -halfVAngle, halfVAngle);
}
Example #9
0
//Basic wall following code
void wallFollowing()
{
    //Sensor readings 
    int rightSideIR, leftSideIR, rightFrontIR, leftFrontIR;
    int ultrasound;
    get_front_ir_dists(&leftFrontIR, &rightFrontIR);
    get_side_ir_dists(&leftSideIR, &rightSideIR);
    inputMotors();

    while (1)
    {
        if (thetaAcc > 40)
            { break; }

        int lbump, rbump;
        check_bumpers(&lbump, &rbump);
        if (lbump){
            set_motors(SPEED+20, SPEED-20);
        }
        if (rbump){
            set_motors(SPEED-20, SPEED+20);
        }

        get_front_ir_dists(&leftFrontIR, &rightFrontIR);
        get_side_ir_dists(&leftSideIR, &rightSideIR);
        ultrasound = get_us_dist(); 


        //Hit wall
        if (ultrasound < 30){
            int i;
/*
           for(i=0; i<20; i++){
                set_motors(-SPEED, -SPEED);
                ultrasound = get_us_dist();
            }
*/
            //set_ir_angle(RIGHT, 45);
            //set_ir_angle(LEFT, -45);

        get_front_ir_dists(&leftFrontIR, &rightFrontIR);
            //for (i=0; i<15; i++){
        if (leftFrontIR - rightFrontIR > 0){
        set_motors(-SPEED, -SPEED);
        //set_motors(-SPEED, SPEED);
        set_motors(-25,25);
        }
           else{
        set_motors(-SPEED, -SPEED);         
                 set_motors(SPEED, -SPEED);
       }
    get_front_ir_dists(&leftFrontIR, &rightFrontIR);
    //}
                   
                   setAngles();
        }


/*
        //Deadlock
        if (ultrasound < 30 && leftFrontIR < 40 && rightFrontIR < 40)
        {   
            int i;

            //while ((ultrasound < 80 && leftFrontIR < 45) || (ultrasound < 80 && rightFrontIR < 45))
            
            while (ultrasound < 87)
                { set_motors(-SPEED, -SPEED); 
                   //get_side_ir_dists(&leftFrontIR, &rightSideIR); 
                   ultrasound = get_us_dist();
               }
            
               
               set_ir_angle(RIGHT, 45);
               set_ir_angle(LEFT, -45);
               
               get_front_ir_dists(&leftFrontIR, &rightFrontIR);
               //printf("%d %d\n", leftFrontIR, rightFrontIR);
               
                   if (leftFrontIR - rightFrontIR > 0){
                    //for (i=0; i<20; i++)
                        set_motors(-SPEED-20, -SPEED+20);
                    //turnLeft(50);
                   }
                   else if (rightFrontIR - leftFrontIR > 0){
                    //for (i=0; i<20; i++)
                        set_motors(-SPEED+20, -SPEED-20);
                    //turnRight(50);
                   }
               
               setAngles();
               

               

           //Make 90 deg left turn 
               //for (i=0; i<35; i++)
               //{ set_motors(SPEED, -SPEED); }
        } 
        */

        else{
            
            if (leftFrontIR > rightFrontIR)
            {       
                set_motors(SPEED-25, SPEED+25);

                //addNode(pointer, LEFT);
            }

            else if (rightFrontIR > leftFrontIR )
            {
                set_motors(SPEED+25, SPEED-25);

                //addNode(pointer, RIGHT);
            }

            else 
            { 
                set_motors(SPEED, SPEED);

                //addNode(pointer, STRAIGHT);
            }
        }
        calculateTheta();
    }
}
Example #10
0
void Camera::rotateRightDiscrete() {
	Vector3 angles = getAngles();
	angles[CAMERA_YAW] -= SPEED_TURN;
	setAngles(angles);
}
Example #11
0
Joint::Joint(float zAngle, float yAngle) :
		JointModel(zAngle, yAngle), cube(new Cube()) {
	setAngles(zAngle, yAngle);
}