void fxRenderImage::faceAwayCamera(TSRenderContext & rc, bool _findCamAxis)
{
	if (_findCamAxis)
		findCameraAxis(rc);
        Point3F awayAxis = camAxis;
        awayAxis *= -1.0f;
	faceDirection(awayAxis);
}
Exemple #2
0
void Fist::fire() const {
    float time = timer::totalTime();
    if (time - timer_ > 0.5f) {
        timer_ = time;
        float angleRad = parent_->rotation()*M_PI / 180.f;
        Vector2f faceDirection(std::cos(angleRad), std::sin(angleRad));

        particles::spawn(particles::pAmmoFist, parent_->location() + faceDirection*parent_->radius(), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());

        parent_->velocity() -= faceDirection*200.f;
        sound::playSound(sound::Pump, parent_->location());
    }
}
Exemple #3
0
void Burner::fire() const {
    float time = timer::totalTime();
    if (time - timer_ > 0.05f) {
        timer_ = time;
        float angleRad = parent_->rotation()*M_PI / 180.f;
        Vector2f faceDirection(std::cos(angleRad), std::sin(angleRad));
        for (int i=0; i<20; ++i) {
            particles::spawn(particles::pAmmoBurner, parent_->location() + faceDirection*parent_->radius()*1.5f, faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
            particles::spawn(particles::pHeatBurner, parent_->location() + faceDirection*parent_->radius()*1.5f, faceDirection, parent_->velocity());
        }
        parent_->velocity() -= faceDirection*10.f;
    }
}
// assumes dirY is normalized
void fxRenderImage::faceDirection(Point3F & dirY)
{
	// if we rotate about an axis, use a different routine...
	if (useRotationAxis)
	{
		faceDirection(dirY,rotationAxis);
		return;
	}

	Point3F dirX,dirZ;

	if (fabs(dirY.z) < 0.95)
	{
		// dirY is not near vector (0,0,1), so we can
		// use it as the pivot vector
		m_cross(dirY, Point3F(0,0,1), &dirX);
		dirX.normalize();
		m_cross(dirX, dirY, &dirZ);
	}
	else
	{
		// dirY is near vector (0,0,1), so use
		// pivot Point3F(1,0,0) instead
		m_cross(Point3F(1,0,0), dirY, &dirZ);
		dirZ.normalize();
		m_cross(dirY, dirZ, &dirX);
	}

	transform.setRow(0,dirX);
	transform.setRow(1,dirY);
	transform.setRow(2,dirZ);
	transform.flags |=  TMat3F::Matrix_HasRotation;
	transform.flags &= ~TMat3F::Matrix_HasScale;

   if (useAxisSpin == true) {
      RMat3F tempRot(EulerF(0, axisSpin, 0));
      TMat3F tempOutput;
      m_mul(tempRot, transform, &tempOutput);
      transform = tempOutput;
   }
}
void fxRenderImage::faceCamera(TSRenderContext & rc, bool _findCamAxis)
{
	if (_findCamAxis)
		findCameraAxis(rc);
	faceDirection(camAxis);
}