Esempio n. 1
0
void CCamera::ProcessVectorTrackLinear(float time)
{
    m_processedVectorTrackLinear = true;
    float weight = time;
    if (m_vectorTrackLinearConstSpeed)
    {
        weight = (sin(DEG_TO_RAD(270.0f - time * 180.0f)) + 1.0f) / 2.0f;
    }
    m_vectorTrackLinearCurrent = Lerp(m_vectorTrackLinearStart, weight, m_vectorTrackLinearEnd);
}
Esempio n. 2
0
void
sg_camera_rotate_hat(int buttonVal, void *data)
{
  //log_info("hat pushed %d", buttonVal);
  sg_scene_t *sc = sim_get_scene();
  sg_camera_t *cam = sg_scene_get_cam(sc);

  ASSERT_CAM(cam);

  // Note that the camera control will rotate the camera based on WCT.
  // This differ from the normal rotation of objects which is based on SRT.
  // The interpolation doesn't really care, it just expresses time as a
  // normalized value where 0 is the time of the last physics system sync
  // and 1.0 is the expected time of the next sync.
  // We thus need to take the frequency (not the SRT period) here.
  float wct_freq;
  config_get_float_def("openorbit/sim/freq", &wct_freq, 20.0); // Hz

  if ((cam->src == cam->tgt) && cam->src) {
    // We are targeting our follow object this means orbiting it
    if (buttonVal == -1) {
      cam->dq = QD_IDENT;
    } else {
      cam->dq = qd_rot(0.0,
                       cosf(DEG_TO_RAD(buttonVal)),
                       sinf(DEG_TO_RAD(buttonVal)),
                       M_PI_2 / wct_freq);
    }
    cam->q1 = qd_mul(cam->q0, cam->dq);
  } else {
    if (buttonVal == -1) {
      cam->dq = QD_IDENT;
    } else {
      cam->dq = qd_rot(0.0,
                       cosf(DEG_TO_RAD(buttonVal)),
                       sinf(DEG_TO_RAD(buttonVal)),
                       M_PI_2 / wct_freq);
    }
    cam->q1 = qd_mul(cam->q0, cam->dq);
  }

  ASSERT_CAM(cam);
}
Esempio n. 3
0
OOellipse* ooGeoEllipseAreaSeg(size_t segs, float semiMajor, float semiMinor)
{
    OOellipse *e = smalloc(sizeof(OOellipse));
    ooVecArrayInit(&e->vec);
    //uint64_t totalIterations = 0;
    e->semiMajor = semiMajor;
    e->semiMinor = semiMinor;
    e->ecc = ooGeoEllipseEcc(e);

    double area = ooGeoEllipseArea(e);

    double sweep = area / (double)segs;

    ooVecArrayPushC(&e->vec,
                    semiMajor * cos(0.0) - e->ecc * semiMajor, semiMinor * sin(0.0), 0.0f, 0.0f);
    double segArea, tol;
    double prevAngle = 0.0f;
    double newAngle = prevAngle + 1.0*DEG_TO_RAD(360.0/(double)segs);
    double delta;

    for (size_t i = 1 ; i < segs ; i ++) {
        int count = 0;
        segArea = ooGeoEllipseSegmentArea(e, prevAngle, newAngle);
        delta = (newAngle-prevAngle);
        do {
            if (segArea > sweep) {
                delta -= delta/STEPSIZE;
            } else {
                delta += delta/STEPSIZE;
            }
            newAngle = prevAngle + delta;
            segArea = ooGeoEllipseSegmentArea(e, prevAngle, newAngle);
            tol = fabs(1.0 - segArea/sweep);
            count ++;
        } while (tol > 0.00001 && count < ITERSTOP);

        if (count >= ITERSTOP) {
            log_warn("ellipse segment did not converge in %d iterations", ITERSTOP);
        }
        //segArea = segmentArea(prevAngle, newAngle, semimajor, ecc);

        // Insert vec in array, note that center is in foci
        ooVecArrayPushC(&e->vec,
                        semiMajor * cos(newAngle) - e->ecc * semiMajor,
                        semiMinor * sin(newAngle),
                        0.0f, 0.0f);


        double nextNewAngle = newAngle + (newAngle-prevAngle);
        prevAngle = newAngle;
        newAngle = nextNewAngle;
    }

    return e;
}
Esempio n. 4
0
static void swing()
{
	self->thinkTime += 2;

	if (self->thinkTime >= 360)
	{
		self->thinkTime = 0;
	}

	self->x = self->endX + sin(DEG_TO_RAD(self->thinkTime)) * 8;
}
Esempio n. 5
0
static void shudder()
{
	self->startY += 90;

	self->x = self->startX + sin(DEG_TO_RAD(self->startY)) * 4;

	if (self->startY >= 360)
	{
		self->startY = 0;
	}
}
Esempio n. 6
0
// Returns the distance (in meters) to the current waypoint
static float calc_dist_to_waypoint(float lat_1, float long_1, float lat_2, float long_2) {
  float lat_1_rad = DEG_TO_RAD(lat_1);
  float long_1_rad = DEG_TO_RAD(long_1);
  float lat_2_rad = DEG_TO_RAD(lat_2);
  float long_2_rad = DEG_TO_RAD(long_2);

  float diff_lat = lat_2_rad - lat_1_rad;
  float diff_long = long_2_rad - long_1_rad;

  float a = ( pow(sin(diff_lat / 2), 2) ) +
    cos(lat_1_rad) *
    cos(lat_2_rad) *
    ( pow(sin(diff_long / 2), 2) );

  float c = 2 * asin(sqrt(a));

  float distance_m = EARTH_RADIUS_M * c;

  return distance_m;
}
Esempio n. 7
0
static void hover()
{
	self->endX++;

	if (self->endX >= 360)
	{
		self->endX = 0;
	}

	self->y = self->endY + sin(DEG_TO_RAD(self->endX)) * 8;
}
Esempio n. 8
0
static void hover()
{
	self->endX += 4;

	if (self->endX >= 360)
	{
		self->endX = 0;
	}

	self->y = self->startY + sin(DEG_TO_RAD(self->endX)) * 4;
}
Esempio n. 9
0
static void hover()
{
	self->startX++;

	if (self->startX >= 360)
	{
		self->startX = 0;
	}

	self->y = self->startY + sin(DEG_TO_RAD(self->startX)) * 8;
}
Esempio n. 10
0
static void entityWait()
{
	self->thinkTime += 2;

	if (self->thinkTime >= 360)
	{
		self->thinkTime = 0;
	}

	self->y = self->startY + sin(DEG_TO_RAD(self->thinkTime)) * 16;
}
Esempio n. 11
0
/**
 * snaps a vector to the nearest angle that is a multiple of snapAngle
 *
 * @param vector the Vector to be modified
 */
Vector3& angle( Vector3& vector, float snapAngle )
{
    float pitch;
	float yaw;

    bool flipYaw;

    if (vector.x != 0.f)
    {
        yaw = atanf( vector.z / vector.x );
        flipYaw = ( vector.x < 0 );
    }
    else
    {
        yaw = MATH_PI / 2;
        flipYaw = ( vector.z < 0 );
    }

    pitch = acosf( Math::clamp(-1.0f, vector.y, +1.0f) );

    //snap the angles
    yaw	    = value( yaw, DEG_TO_RAD( snapAngle ) );
    //snap the angle
    pitch	= value( pitch, DEG_TO_RAD( snapAngle ) );

    //mirror octants
   	if ( flipYaw )
    	yaw = yaw - MATH_PI;

    //recalc the orientation
    float cosYaw = cosf( yaw );
    float sinYaw = sinf( yaw );
    float cosPitch = cosf( pitch );
    float sinPitch = sinf( pitch );

    vector.set( cosYaw * sinPitch, cosPitch, sinYaw * sinPitch );

    vector.normalise();

	return vector;
}
Esempio n. 12
0
Quaternion Quaternion::rotationQuaternion(GLfloat angle, vec3_t<GLfloat> axis)
{
    Quaternion q;
    GLfloat radians = DEG_TO_RAD(angle);
    GLfloat angBy2 = radians / 2.f;
    q.w = cosf(angBy2);
    q.x = axis.x * sinf(angBy2);
    q.y = axis.y * sinf(angBy2);
    q.z = axis.z * sinf(angBy2);

    return q;
}
Esempio n. 13
0
// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CMatrix
//
//  - prototype : BuildRotation(float fAngle, float fAxisX, float fAxisY, float fAxisZ)
//
//  - Purpose   : Builds a rotation matrix of fAngle degrees around the axis
//                given by (fAxisX, fAxisY, fAxisZ).
//
// -----------------------------------------------------------------------------
void CMatrix::BuildRotation(float fAngle, float fAxisX, float fAxisY, float fAxisZ)
{
	CVector3 axis(fAxisX, fAxisY, fAxisZ);
	axis.Normalize();

	float fRad  = DEG_TO_RAD(fAngle * 0.5f);
	float fSine = sinf(fRad);

	CQuaternion quat(cosf(fRad), fSine * fAxisX, fSine * fAxisY, fSine * fAxisZ);

	*this = quat.Matrix();
}
Esempio n. 14
0
File: Ex3.c Progetto: marrusian/C
Rect_V polar_to_rect(Polar_V pv)
{
   #define PI (4.0*atan(1))
   #define DEG_TO_RAD(X) ((X)*(PI/180.0))
   Rect_V rv;
   register double A = DEG_TO_RAD(pv.angle);
   
   rv.x = pv.magnitude*cos(A);
   rv.y = pv.magnitude*sin(A);

   return rv;   
}
Esempio n. 15
0
void updateFrustum()
{
    // build view frustum from projection and view matrix
    frustum.SetFromMatrix(
        Gs::ProjectionMatrix4::Perspective(
            static_cast<Gs::Real>(resolution.x) / resolution.y,
            0.1f,
            100.0f,
            DEG_TO_RAD(fov)
        ).ToMatrix4()// * viewMatrix.ToMatrix4()
    );
}
Esempio n. 16
0
static void calc_derived_values(rift_priv *priv)
{
	priv->base.properties.hsize = priv->display_info.h_screen_size;
	priv->base.properties.vsize = priv->display_info.v_screen_size;
	priv->base.properties.hres = priv->display_info.h_resolution;
	priv->base.properties.vres = priv->display_info.v_resolution;
	priv->base.properties.lens_sep = priv->display_info.lens_separation;
	priv->base.properties.lens_vpos = priv->display_info.v_center;

	priv->base.properties.fov = DEG_TO_RAD(125.5144f); // TODO calculate.


	// Calculate the screen ratio of each subscreen.
	float full_ratio = (float)priv->display_info.h_resolution /
	                   (float)priv->display_info.v_resolution;
	float ratio = full_ratio / 2.0f;

	priv->base.properties.ratio = ratio;


	// Calculate where the lens is on each screen,
	// and with the given value offset the projection matrix.
	float screen_center = priv->display_info.h_screen_size / 4.0f;
	float lens_shift = screen_center - priv->display_info.lens_separation / 2.0f;
	float proj_offset = 4.0f * lens_shift / priv->display_info.h_screen_size;

	priv->calc_values.proj_offset = proj_offset;


	// Setup the base projection matrix. Each eye mostly have the
	// same projection matrix with the exception of the offset.
	omat4x4f_init_perspective(&priv->calc_values.proj_base,
	                          priv->base.properties.fov,
	                          priv->base.properties.ratio,
	                          priv->base.properties.znear,
	                          priv->base.properties.zfar);


	// Setup the two adjusted projection matricies. Each is setup to deal
	// with the fact that the lens is not in the center of the screen.
	// These matrices only change of the hardware changes, so static.
	mat4x4f translate;

	omat4x4f_init_translate(&translate, proj_offset, 0, 0);
	omat4x4f_mult(&translate,
	              &priv->calc_values.proj_base,
	              &priv->base.properties.proj_left);

	omat4x4f_init_translate(&translate, -proj_offset, 0, 0);
	omat4x4f_mult(&translate,
	              &priv->calc_values.proj_base,
	              &priv->base.properties.proj_right);
}
Esempio n. 17
0
Quaternion::Quaternion(const Vector3f &axis, float angleInDegrees)
{
	float a = DEG_TO_RAD(angleInDegrees) * 0.5f;
	float s = sin(a);
	float norm = axis.Length();
	if (norm < 0.00001f) norm = 0.00001f;

	x = s * axis.x / norm;
	y = s * axis.y / norm;
	z = s * axis.z / norm;
	w = cos(a);
}
Esempio n. 18
0
bool CBlock::CheckCollision (sf::Sprite *p_pSprite, sf::Vector2f p_fPos)
{
    bool bCollided = false;
    int iNbSteps = 0;
    float fDirection = p_pSprite->getRotation ();
    if (p_pSprite->getOrigin () != sf::Vector2f (0.f, 0.f))
    {
        fDirection -= 90.f;
        p_fPos.x += p_pSprite->getOrigin ().x * cos (DEG_TO_RAD(fDirection));
        p_fPos.y += p_pSprite->getOrigin ().y * sin (DEG_TO_RAD(fDirection));
        fDirection += 90.f;
        p_fPos.x +=  p_pSprite->getOrigin ().x * cos (DEG_TO_RAD(fDirection));
        p_fPos.y += p_pSprite->getOrigin ().y * sin (DEG_TO_RAD(fDirection));
    }

    for (int i = 0; i < 4; i++)
    {
        fDirection += 90.f;
        if (i % 2 == 1)
            iNbSteps = p_pSprite->getTextureRect ().height;
        else
            iNbSteps = p_pSprite->getTextureRect ().width;
        for (int j = 0; j < iNbSteps; j++)
        {
            p_fPos.x += 1.f * cos (DEG_TO_RAD(fDirection));
            p_fPos.y += 1.f * sin (DEG_TO_RAD(fDirection));
            if ((p_fPos.x >= m_fPos.x - static_cast<float> (m_iSize.x) / 2) && (p_fPos.x <= m_fPos.x + static_cast<float> (m_iSize.x) / 2) &&
                (p_fPos.y >= m_fPos.y - static_cast<float> (m_iSize.y) / 2) && (p_fPos.y <= m_fPos.y + static_cast<float> (m_iSize.y) / 2))
                bCollided = true;
        }
    }
    return bCollided;
}
Esempio n. 19
0
static void headWait()
{
    int x;

    /* Sway back and forth */

    self->dirX += 0.5;

    if (self->dirX >= 360)
    {
        self->dirX = 0;
    }

    x = 24;

    self->x = self->targetX + (sin(DEG_TO_RAD(self->dirX)) * x);

    alignBodyToHead();

    self->thinkTime--;

    if (self->thinkTime <= 0 && player.health > 0)
    {
        self->thinkTime = 0;

        x = prand() % 4;

        switch (x)
        {
        case 0:
            self->action = &biteAttackInit;
            break;

        case 1:
            self->action = &changeSidesInit;
            break;

        case 2:
            self->action = &shotAttackInit;
            break;

        default:
            self->action = &crushAttackInit;
            break;
        }
    }

    if (prand() % 180 == 0)
    {
        playSoundToMap("sound/boss/snake_boss/hiss", BOSS_CHANNEL, self->x, self->y, 0);
    }
}
Esempio n. 20
0
Matrix Camera::GetProjectionMatrix() {
    double c = -Near / Far;
    double a = -1.0/(c+1.0);
    double b = c/(c+1.0);
    
    Matrix M = Matrix(1, 0,  0, 0,
                      0, 1,  0, 0,
                      0, 0,  a, b,
                      0, 0, -1, 0);
    
    
    
    double sx = 1.0/(tan(DEG_TO_RAD(view*width/height/2))*Far);
    double sy = 1.0/(tan(DEG_TO_RAD(view/2))*Far);
    double sz = 1.0/Far;
    
    Matrix S = Matrix(sx,  0,  0,  0,
                       0, sy,  0,  0,
                       0,  0, sz,  0,
                       0,  0,  0,  1);
    return M * S;
}
Esempio n. 21
0
// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CMatrix
//
//  - prototype : void BuildRotationZ(float fDegrees)
//
//  - Purpose   : Builds a rotation matrix around z axis. Angle in degrees.
//
// -----------------------------------------------------------------------------
void CMatrix::BuildRotationZ(float fDegrees)
{
	float fRad	  = DEG_TO_RAD(fDegrees);
	float fSine   = sinf(fRad);
	float fCosine = cosf(fRad);

	SetIdentity();
	
	m_fM[0][0] = fCosine;
	m_fM[0][1] = -fSine;
	m_fM[1][0] = fSine;
	m_fM[1][1] = fCosine;
}
Esempio n. 22
0
static void createVehicle( Vector2 pos, Color clr )
{
	SteeringVehicle v;

	v.pos = pos;
	v.vel = vec2( 0.0f, 0.0f );
	v.maxSpeed = 200.0f;

	v.rotRad = 0.0f;
	v.rotSpdRad = DEG_TO_RAD( 0.0f );
	v.maxRotSpeedRad = DEG_TO_RAD( 720.0f );

	v.linearAccel = VEC2_ZERO;
	v.angularAccelRad = 0.0f;

	v.radius = 10.0f;
	v.clr = clr;

	v.wanderTarget = pos;

	sb_Push( sbVehicles, v );
}
Esempio n. 23
0
void TaskCubeMap::update( void )
{
	glClearColor( 0.2f, 0.2f, 0.2f, 1.0f );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

	const horizon::input::PadState& pad = horizon::input::getPadState( 0 );

	if( pad.stick.right.y != 0.0f ) {
		mCamera.rotation().x -= DEG_TO_RAD( pad.stick.right.y );
	}
	if( pad.stick.right.x != 0.0f ) {
		mCamera.rotation().y -= DEG_TO_RAD( pad.stick.right.x );
	}

	glm::vec4 direction( -pad.stick.left.x, 0.0f, - pad.stick.left.y, 0.0f );
	glm::mat4 identityMtx( 1.0f );
	direction = glm::rotate( identityMtx, mCamera.rotation().x, GLM_X_AXIS ) * direction;
	direction = glm::rotate( identityMtx, mCamera.rotation().y, GLM_Y_AXIS ) * direction;
	mCamera.position().x += direction.x;
	mCamera.position().y += direction.y;
	mCamera.position().z += direction.z;

	mCamera.apply();

	mCubeMap.useProgram();
	mCubeMap.bindTexture( 0, mTextureCubeChapel );

	mCubeMap.getProgram().setUniform( "SkyBox", 1 );
	mSkyBox.draw();


	glClear( GL_DEPTH_BUFFER_BIT );

	mCubeMap.getProgram().setUniform( "SkyBox", 0 );
	mSphere.draw();

	mShader_PresentNormal.useProgram();
	mSphere.draw();
}
Esempio n. 24
0
//==============================================================================
// Brief  : プレイヤーの移動処理
//==============================================================================
void SceneGame::MovePlayer()
{
	//	wiiボードを利用した、プレイヤーの移動処理1
	//---------------------------------------------------------------------------------------------------------
//#ifdef _WIIBOARD
	float totalCalibKg = wiiContoroller->getCalibKg().Total * 0.7f;
	float totalKgR = wiiContoroller->getKg().BottomR + wiiContoroller->getKg().TopR;
	float totalKgL = wiiContoroller->getKg().BottomL + wiiContoroller->getKg().TopL;
	if(totalKgL
		>=
		totalCalibKg)
	{
		player->addSpeed((-((totalKgL - totalCalibKg) / wiiContoroller->getCalibKg().Total)) * 2.0f);
	}
	if(totalKgR
		>=
		totalCalibKg)
	{
		player->addSpeed((((totalKgR - totalCalibKg) / wiiContoroller->getCalibKg().Total)) * 2.0f);
	}
//#endif

	if(pArgument_->pKeyboard_->IsPress(DIK_LEFT) == true)
	{
		player->AddPositionX(-1.0f);
	}
	if(pArgument_->pKeyboard_->IsPress(DIK_RIGHT) == true)
	{
		player->AddPositionX(1.0f);
	}

	D3DXVECTOR3 buff = player->getPosition();
	//PrintDebug( _T( "\nplayerPos.x = %f\n"), buff.x );
	//---------------------------------------------------------------------------------------------------------

	//	プレイヤー腕オブジェクトに回転量をセット
	D3DXVECTOR3 buffRot = wiiContoroller->getRot();
	player->setRotationArm(DEG_TO_RAD(buffRot.x), DEG_TO_RAD(-buffRot.y), DEG_TO_RAD(buffRot.z));
}
Esempio n. 25
0
static void floatUpAndDown()
{
	self->endX++;

	if (self->endX >= 360)
	{
		self->endX = 0;
	}

	self->y = self->endY + sin(DEG_TO_RAD(self->endX)) * 5;

	self->dirY = 3;
}
Esempio n. 26
0
//===========================================
// Box2dPhysics::updatePos
//===========================================
void Box2dPhysics::updatePos(const EEvent* ev) {
   static long entityRotationStr = internString("entityRotation");
   static long entityShapeStr = internString("entityShape");
   static long entityTranslationStr = internString("entityTranslation");

   if (!m_init)
      throw PhysicsException("Instance of Box2dPhysics is not initialised", __FILE__, __LINE__);

   if (ev->getType() == entityTranslationStr) {
      const EEntityTranslation* event = static_cast<const EEntityTranslation*>(ev);

      b2Vec2 p = m_body->GetPosition();

      // Update position
      float32_t x = event->newTransl_abs.x - event->oldTransl_abs.x;
      float32_t y = event->newTransl_abs.y - event->oldTransl_abs.y;

      m_body->SetTransform(b2Vec2(p.x + x / m_worldUnitsPerMetre, p.y + y / m_worldUnitsPerMetre), m_body->GetAngle());
   }
   else if (ev->getType() == entityRotationStr) {
      const EEntityRotation* event = static_cast<const EEntityRotation*>(ev);

      float32_t a = m_body->GetAngle();
      float32_t r = DEG_TO_RAD(event->newRotation_abs - event->oldRotation_abs);

      m_body->SetTransform(m_body->GetPosition(), a + r);
   }
   else if (ev->getType() == entityShapeStr) {
      const EEntityShape* event = static_cast<const EEntityShape*>(ev);

      unique_ptr<Shape> oldShape(dynamic_cast<Shape*>(event->oldShape.get()->clone()));
      unique_ptr<Shape> newShape(dynamic_cast<Shape*>(event->newShape.get()->clone()));
      oldShape->rotate(-event->oldRotation_abs);
      newShape->rotate(-event->newRotation_abs);

      // Update shape
      if (oldShape == NULL || *oldShape != *newShape) {
         for (unsigned int i = 0; i < m_numFixtures; ++i)
            m_body->DestroyFixture(m_body->GetFixtureList());

         shapeToBox2dBody(*newShape, m_opts, m_body, &m_numFixtures);
      }
   }

   // Wake bodies
/*   b2Body* body = m_world.GetBodyList();
   while (body != NULL) {
      body->SetAwake(true);
      body = body->GetNext();
   }*/
}
Esempio n. 27
0
/*-----------------------------------------------------------------------------
    Name        :  svStartup()
    Description :
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void svStartup(void)
{
    cameraInit(&svCamera, SV_InitialCameraDistance);

    svCamera.angle = DEG_TO_RAD(svAngle);
    svCamera.declination = DEG_TO_RAD(svDeclination);

    feDrawCallbackAdd(SV_ShipViewName, svShipViewRender);   //add render callbacks

    feDrawCallbackAdd(SV_FirepowerName, svFirepowerRender);
    feDrawCallbackAdd(SV_CoverageName, svCoverageRender);
    feDrawCallbackAdd(SV_ManeuverName, svManeuverRender);
    feDrawCallbackAdd(SV_ArmorName, svArmorRender);
    feDrawCallbackAdd(SV_TopSpeedName, svTopSpeedRender);
    feDrawCallbackAdd(SV_MassName, svMassRender);

    svMouseInside     = FALSE;
    svMousePressLeft  = FALSE;
    svMousePressRight = FALSE;

    svShipViewFont = frFontRegister(svShipViewFontName);
    svShipStatFont = frFontRegister(svShipStatFontName);
}
Esempio n. 28
0
//--------------------------------------------------------------
// Name:			CCAMERA::ComputeViewMatrix - public
// Description:		Compute the information for the camera
// Arguments:		-fTimeDelta: amount to interpolate from last frame
//								 (defaults to 1.0f)
// Return Value:	None
//--------------------------------------------------------------
void CCAMERA::ComputeViewMatrix( float fTimeDelta )
{
	if( ( m_fYaw>=360.0f) || ( m_fYaw<=-360.0f ) )
		m_fYaw= 0.0f;

	if( m_fPitch>60.0f )
		m_fPitch= 60.0f;
	if( m_fPitch<-60.0f )
		m_fPitch= -60.0f;
     
	float cosYaw  = cosf( DEG_TO_RAD( m_fYaw ) );
	float sinYaw  = sinf( DEG_TO_RAD( m_fYaw ) );
	float sinPitch= sinf( DEG_TO_RAD( m_fPitch ) );
	float cosPitch= cosf( DEG_TO_RAD( m_fPitch ) );

	m_vecForward[0]= sinYaw * cosPitch;
	m_vecForward[1]= sinPitch;
	m_vecForward[2]= cosPitch * -cosYaw;

	m_vecLookAt= m_vecEyePos + m_vecForward;

	m_vecSide= m_vecForward.CrossProduct( m_vecUp );
}
Esempio n. 29
0
static void entityWait()
{
	if (self->targetY > 0)
	{
		self->targetY -= 20;

		if (self->targetY < 0)
		{
			self->targetY = 0;
		}

		self->x = self->startX + sin(DEG_TO_RAD(self->targetY)) * 10;
	}
}
Esempio n. 30
-1
static gfloat
left_end (gfloat   from,
          gfloat   to,
          gboolean cl)
{
  gfloat alpha  = DEG_TO_RAD (from);
  gfloat beta   = DEG_TO_RAD (to);
  gint   cw_ccw = cl ? -1 : 1;

  switch (cw_ccw)
    {
    case -1:
      if (alpha < beta)
        return alpha + TWO_PI;

    default:
      return alpha; /* 1 */
    }
}