Esempio n. 1
0
void RotationMC::GetValueLive(TimeValue t,void *val, GetSetMethod method)
	{
	Point3 pt = base;
	for (int i=0; i<3; i++) if (bind[i]) pt[i] += DegToRad(bind[i]->Eval(t));
	Quat q;
	EulerToQuat(pt,q);
	if (method==CTRL_ABSOLUTE) {		
		*((Quat*)val) = q;
	} else {
		Matrix3 *tm = (Matrix3*)val;		
		PreRotateMatrix(*tm,q);		
		}
	}
Esempio n. 2
0
void GetPerspectiveMatrix(M4* result, float fov, float aspect, float znear, float zfar)
{
    float rad = DegToRad(fov);
    float frustum_scale = 1.0f / (float)tan(rad / 2.0f);

    memset(result, 0, M4SIZE);
    
    result->data[0] = frustum_scale / aspect;
    result->data[5] = frustum_scale;
    result->data[10] = (zfar + znear) / (znear - zfar);
    result->data[14] = (2.0f * zfar * znear) / (znear - zfar);
    result->data[11] = -1.0f;
}
Esempio n. 3
0
static glm::mat3 RotateX(float angDeg)
{
    float angRad = DegToRad(angDeg);
    float cos = cosf(angRad);
    float sin = sinf(angRad);

    glm::mat3 theMat(1.0f);
    theMat[1].y = cos;
    theMat[2].y = -sin;
    theMat[1].z = sin;
    theMat[2].z = cos;
    return theMat;
}
Esempio n. 4
0
Matrix Matrix::CreateRotationByAxisAngle(Vector3 axis, float angle)
{
	float x = axis.x;
	float y = axis.y;
	float z = axis.z;
	
	float sin = sinf(DegToRad(-angle));
	float cos = cosf(DegToRad(-angle));

	float x2 = x*x;
	float y2 = y*y;
	float z2 = z*z;

	float xy = x*y;
	float xz = x*z;
	float yz = y*z;

	return Matrix(x2 + (cos * (1.0f - x2)), (xy - (cos * xy)) + (sin * z), (xz - (cos * xz)) - (sin * y), 0.0f,
		(xy - (cos * xy)) - (sin * z), y2 + (cos * (1.0f - y2)), (yz - (cos * yz)) + sin * x, 0.0f,
		(xz - (cos * xz)) + sin * y, (yz - (cos * yz)) - sin * x, z2 + (cos * (1.0f - z2)), 0.0f,
		0.0f, 0.0f, 0.0f, 1.0f);	
}
Esempio n. 5
0
void FreqCircle::UpdateBars(){
	//Exclusive Lock this object while bars are updated.
	//Fill our buffer with frequency information
	Lock();
	FrequencyAnalysis::Instance().Fill(buffer, specLeft, specRight);

	//Apply the correct transformations to the children (the bars)
	for (unsigned int i = 0; i< children.size(); ++i){

		float angle = ((float) i / accuracy) * 360;
		float modification = (float) i+1.0f;

		float value = clamp(buffer[i] * modification , 0.0f, 1.0f);

		//This method is threadsafe, no children locks necessary
		children[i]->SetModelMatrix(
			Matrix4::Translation(Vector3(
			value * cos(DegToRad( angle )),
			value * sin(DegToRad( angle )), -0.05f)));
	}
	Unlock();
}
Esempio n. 6
0
void RenderHelper::DrawCircle3D(const Vector3 & center, const Vector3 &emissionVector, float32 radius, bool useFilling)
{
	Polygon3 pts;
    float32 angle = SEGMENT_LENGTH / radius;
	int ptsCount = (int)(PI_2 / (DegToRad(angle))) + 1;

	for (int k = 0; k < ptsCount; ++k)
	{
		float32 angleA = ((float)k / (ptsCount - 1)) * PI_2;
		float sinAngle = 0.0f;
		float cosAngle = 0.0f;
		SinCosFast(angleA, sinAngle, cosAngle);

		Vector3 directionVector(radius * cosAngle,
								radius * sinAngle,
								0.0f);
		
		// Rotate the direction vector according to the current emission vector value.
		Vector3 zNormalVector(0.0f, 0.0f, 1.0f);
		Vector3 curEmissionVector = emissionVector;
		curEmissionVector.Normalize();
		
		// This code rotates the (XY) plane with the particles to the direction vector.
		// Taking into account that a normal vector to the (XY) plane is (0,0,1) this
		// code is very simplified version of the generic "plane rotation" code.
		float32 length = curEmissionVector.Length();
		if (FLOAT_EQUAL(length, 0.0f) == false)
		{
			float32 cosAngleRot = curEmissionVector.z / length;
			float32 angleRot = acos(cosAngleRot);
			Vector3 axisRot(curEmissionVector.y, -curEmissionVector.x, 0);

			Matrix3 planeRotMatrix;
			planeRotMatrix.CreateRotation(axisRot, angleRot);
			Vector3 rotatedVector = directionVector * planeRotMatrix;
			directionVector = rotatedVector;
		}
		
		Vector3 pos = center - directionVector;
		pts.AddPoint(pos);
	}
	
	if (useFilling)
	{
		FillPolygon(pts);
	}
	else
	{
    	DrawPolygon(pts, false);
	}
}
Esempio n. 7
0
HRESULT CPartEmitter::AddForce(char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) {
	CPartForce *Force = AddForceByName(Name);
	if (!Force) return E_FAIL;

	Force->m_Type = Type;
	Force->m_Pos = Vector2(PosX, PosY);

	Force->m_Direction = Vector2(0, Strength);
	Matrix4 MatRot;
	MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180)));
	MatRot.TransformVector2(Force->m_Direction);

	return S_OK;
}
Esempio n. 8
0
//---------------------------------------------------------------------------
GrProjection::GrProjection()
: E_IMPL_NEW( GrProjection )
, m_fFovY( DegToRad(60.0F) )
, m_fAspect( 1.0F )
, m_fZNear( 1.0F )
, m_fZFar( 0.0F )
, m_fFarCull( 10000.0F )
, m_fLeft( -1.0F )
, m_fRight( 1.0F )
, m_fBottom( -1.0F )
, m_fTop( 1.0F )
, m_bDirty( true )
{
}
Esempio n. 9
0
void CStage::Draw(){

	/*for(int x=0;x<width;x++){
		for(int y=0;y<height;y++){

		}
	}*/
	if (quakeFlag && pauseFlag == false) {
		gStage->Draw(cos(DegToRad((double)GetRand(360)))*20, sin(DegToRad((double)GetRand(360))) * 20,num);
	}
	else {
		gStage->Draw(num);
	}
	quakeFlag = false;
	DrawJiki();
	enemy.Draw();
	barrageManager.Draw();
	enemy.enemyBarrage.Draw();
	jikiBarrage->Draw();
	gScore->Draw();
	DrawScore();
	DrawIcon();
}
bool EC_MeshmoonWater::AddWind(float speed, float direction)
{
#ifndef MESHMOON_TRITON
    return false;
#else
    if(framework->IsHeadless() || !state_.environment)
        return false;

    Triton::WindFetch fetch;
    fetch.SetWind(speed, DegToRad(direction));
    state_.environment->AddWindFetch(fetch);
    return true;
#endif
}
void EC_MeshmoonWater::UpdateWeatherConditions()
{
#ifdef MESHMOON_TRITON
    if (!state_.environment)
        return;

    PROFILE(EC_MeshmoonWater_UpdateWeatherConditions);

    state_.environment->ClearWindFetches();
    state_.environment->SimulateSeaState(beaufortScale.Get(), DegToRad(fmod(state_.windDirDegrees, 360.0f)));
    if (state_.windSpeedPerSec != 0.0f)
        AddWind(state_.windSpeedPerSec, state_.windDirDegrees);
#endif
}
Esempio n. 12
0
ROSE_NAMESPACE_START

    PinholeCamera::PinholeCamera(const Vector3f &eye, const Vector3f &at, const Vector3f &up,
                                 float fov, uint32_t w, uint32_t h)
            : eye_world(eye), width(w), height(h) {
        // Compute cameras view volume
        top = std::tan(DegToRad(fov / 2.f));
        bottom = -top;
        right = (width / (float) height) * top;
        left = -right;

        // Compute look at matrix
        look_at = LookAt(eye, at, up);
    }
HRESULT CBObject::GetMatrix(D3DXMATRIX* ModelMatrix, D3DXVECTOR3* PosVect)
{
	if(PosVect==NULL) PosVect = &m_PosVector;

	D3DXMATRIX matRot, matScale, matTrans;
	D3DXMatrixRotationYawPitchRoll(&matRot, DegToRad(m_Angle), 0, 0);
	D3DXMatrixScaling(&matScale, m_Scale3D, m_Scale3D, m_Scale3D);

	D3DXMatrixTranslation(&matTrans, PosVect->x, PosVect->y, PosVect->z);
	D3DXMatrixMultiply(ModelMatrix, &matRot, &matScale);
	D3DXMatrixMultiply(ModelMatrix, ModelMatrix, &matTrans);

	return S_OK;
}
Esempio n. 14
0
void Item::SpawnSubItems()
{
	int numItems = GetRandomNumber(2, 4);

	if(m_itemType == eItem_Chest)
	{
		numItems += 3; // Spawn more coins
	}

	for(int i = 0; i < numItems; i++)
	{
		float scale = 0.15f;
		float lifeTime = 1.0f;
		float r = 0.13f;
		float g = 0.65f;
		float b = 1.0f;
		float a = 1.0f;

		float radius = 0.5f;
		//float angle = DegToRad(((float)i/(float)numItems) * 360.0f);
		float angle = DegToRad(GetRandomNumber(0, 360, 1));
		vec3 ItemPosition = GetCenter() + vec3(cos(angle) * radius, 0.0f, sin(angle) * radius);

		vec3 gravity = vec3(0.0f, -1.0f, 0.0f);
		gravity = normalize(gravity);
		Item* pItem = NULL;
		ItemSubSpawnData *pItemSubSpawnData = m_pItemManager->GetItemSubSpawnData(m_itemType);
		if(pItemSubSpawnData != NULL)
		{
			pItem = m_pItemManager->CreateItem(GetCenter(), vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, 0.0f, 0.0f), pItemSubSpawnData->m_spawnedItemFilename.c_str(), pItemSubSpawnData->m_spawnedItem, pItemSubSpawnData->m_spawnedItemTitle.c_str(), pItemSubSpawnData->m_interactable, pItemSubSpawnData->m_collectible, pItemSubSpawnData->m_scale);

			if(pItem != NULL)
			{
				pItem->SetGravityDirection(gravity);
				vec3 vel = ItemPosition - GetCenter();
				pItem->SetVelocity(normalize(vel)*(float)GetRandomNumber(2, 4, 2) + vec3(0.0f, 9.5f+GetRandomNumber(-2, 4, 2), 0.0f));
				pItem->SetRotation(vec3(0.0f, GetRandomNumber(0, 360, 2), 0.0f));
				pItem->SetAngularVelocity(vec3(0.0f, 90.0f, 0.0f));

				if(pItemSubSpawnData->m_droppedItemItem != eItem_Coin)
				{
					pItem->SetDroppedItem(pItemSubSpawnData->m_droppedItemFilename.c_str(), pItemSubSpawnData->m_droppedItemTextureFilename.c_str(), pItemSubSpawnData->m_droppedItemInventoryType, pItemSubSpawnData->m_droppedItemItem, pItemSubSpawnData->m_droppedItemStatus, pItemSubSpawnData->m_droppedItemEquipSlot, pItemSubSpawnData->m_droppedItemQuality, pItemSubSpawnData->m_droppedItemLeft, pItemSubSpawnData->m_droppedItemRight, pItemSubSpawnData->m_droppedItemTitle.c_str(), pItemSubSpawnData->m_droppedItemDescription.c_str(), pItemSubSpawnData->m_droppedItemPlacementR, pItemSubSpawnData->m_droppedItemPlacementG, pItemSubSpawnData->m_droppedItemPlacementB, pItemSubSpawnData->m_droppedItemQuantity);
				}

				pItem->SetAutoDisappear(20.0f + (GetRandomNumber(-20, 20, 1) * 0.2f));
			}
		}
	}
}
Esempio n. 15
0
// draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
void wxGraphicsPathData::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r )
{   
    wxPoint2DDouble current;
    GetCurrentPoint(&current.m_x,&current.m_y);
    wxPoint2DDouble p1(x1,y1);
    wxPoint2DDouble p2(x2,y2);

    wxPoint2DDouble v1 = current - p1;
    v1.Normalize();
    wxPoint2DDouble v2 = p2 - p1;
    v2.Normalize();

    wxDouble alpha = v1.GetVectorAngle() - v2.GetVectorAngle();

    if ( alpha < 0 )
        alpha = 360 + alpha;
    // TODO obtuse angles

    alpha = DegToRad(alpha);

    wxDouble dist = r / sin(alpha/2) * cos(alpha/2);
    // calculate tangential points
    wxPoint2DDouble t1 = dist*v1 + p1;
    wxPoint2DDouble t2 = dist*v2 + p1;

    wxPoint2DDouble nv1 = v1;
    nv1.SetVectorAngle(v1.GetVectorAngle()-90);
    wxPoint2DDouble c = t1 + r*nv1;

    wxDouble a1 = v1.GetVectorAngle()+90;
    wxDouble a2 = v2.GetVectorAngle()-90;

    AddLineToPoint(t1.m_x,t1.m_y);
    AddArc(c.m_x,c.m_y,r,DegToRad(a1),DegToRad(a2),true);
    AddLineToPoint(p2.m_x,p2.m_y);
}
Esempio n. 16
0
Quaternion Quaternion::EulerAnglesToQuaternion(float pitch, float yaw, float roll)	{
	float y2 = (float)DegToRad(yaw / 2.0f);
	float p2 = (float)DegToRad(pitch / 2.0f);
	float r2 = (float)DegToRad(roll / 2.0f);


	float cosy = (float)cos(y2);
	float cosp = (float)cos(p2);
	float cosr = (float)cos(r2);

	float siny = (float)sin(y2);
	float sinp = (float)sin(p2);
	float sinr = (float)sin(r2);

	Quaternion q;


	q.x = cosr * sinp * cosy + sinr * cosp * siny;
	q.y = cosr * cosp * siny - sinr * sinp * cosy;
	q.z = sinr * cosp * cosy - cosr * sinp * siny;
	q.w = cosr * cosp * cosy + sinr * sinp * siny;

	return q;
};
Esempio n. 17
0
void
ConeAngleManipulator::SetAngle(float angle)
{


    // Check for self-manipulation
    if (mhTarget) {

        TimeValue t = GetCOREInterface()->GetTime();
        ConeAngleManipulator* pManip = (ConeAngleManipulator*) mhTarget;
        angle = DegToRad(angle);
        pManip->mpPblock->SetValue(kConeAngleAngle,     t, angle);
        pManip->mpPblock->GetDesc()->InvalidateUI(kConeAngleAngle);
    }
}
void PDF_D_HFAGfit_4D::setObservables(config c)
{
	switch(c)
	{
		case truth:{
					   setObservablesTruth();
					   break;
				   }
		case toy:{
					 setObservablesToy();
					 break;
				 }
		case hfagFP2014:{
							// http://www.slac.stanford.edu/xorg/hfag/charm/FPCP14/results_mix+cpv.html
							obsValSource = "HFAG FP2014, CPV allowed";
							setObservable("dD_kpi_obs",   DegToRad(7.3+180.0));
							setObservable("rD_kpi_obs",   0.349e-2);
							setObservable("AcpDpipi_obs", 0.14e-2);
							setObservable("AcpDKK_obs",   -0.11e-2);
							break;
						}
		case hfagCHARM2015:{
							// http://www.slac.stanford.edu/xorg/hfag/charm/CHARM15/results_mix_cpv.html
							obsValSource = "HFAG CHARM2015, CPV allowed";
							setObservable("dD_kpi_obs",   DegToRad(11.8+180.0));
							setObservable("rD_kpi_obs",   0.349e-2);
							setObservable("AcpDpipi_obs", 0.10e-2);
							setObservable("AcpDKK_obs",   -0.15e-2);
							break;
						}
		default:{
					cout << "PDF_D_HFAGfit_4D::setObservables() : ERROR : config "+ConfigToTString(c)+" not found." << endl;
					exit(1);
				}
	}
}
HRESULT CPartEmitter::AddForce(char* Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength)
{
	CPartForce* Force = AddForceByName(Name);
	if(!Force) return E_FAIL;

	Force->m_Type = Type;
	Force->m_Pos = D3DXVECTOR2(PosX, PosY);

	Force->m_Direction = D3DXVECTOR2(0, Strength);
	D3DXMATRIX MatRot;
	D3DXMatrixRotationZ(&MatRot, DegToRad(CBUtils::NormalizeAngle(Angle - 180)));
	D3DXVec2TransformCoord(&Force->m_Direction, &Force->m_Direction, &MatRot);

	return S_OK;
}
Esempio n. 20
0
Matrix4 Matrix4::Rotation(float degrees, const Vector3 &inaxis)	 {
	Matrix4 m;

	Vector3 axis = inaxis;

	axis.Normalise();

	float c = cos((float)DegToRad(degrees));
	float s = sin((float)DegToRad(degrees));

	m.values[0]  = (axis.x * axis.x) * (1.0f - c) + c;
	m.values[1]  = (axis.y * axis.x) * (1.0f - c) + (axis.z * s);
	m.values[2]  = (axis.z * axis.x) * (1.0f - c) - (axis.y * s);

	m.values[4]  = (axis.x * axis.y) * (1.0f - c) - (axis.z * s);
	m.values[5]  = (axis.y * axis.y) * (1.0f - c) + c;
	m.values[6]  = (axis.z * axis.y) * (1.0f - c) + (axis.x * s);

	m.values[8]  = (axis.x * axis.z) * (1.0f - c) + (axis.y * s);
	m.values[9]  = (axis.y * axis.z) * (1.0f - c) - (axis.x * s);
	m.values[10] = (axis.z * axis.z) * (1.0f - c) + c;

	return m;
}
Esempio n. 21
0
Vec3f BloodFx::NewPos() const
{
    // Origin should be at mouth, which depends on dino size
    float d = 30.0f; // TODO TEMP TEST
    float y = 35.0f;
    float rad = DegToRad(m_dino->GetDir());
    float x = sin(rad); // flipping sin/cos to match atan2 call in AIChasePet
    float z = cos(rad);

//std::cout << "Dino heading: " << m_dino->GetDir() << " x: " << x << " z: " << z << "\n";

    x *= d;
    z *= d;
    return m_dino->GetPos() + Vec3f(x, y, z);
}
Esempio n. 22
0
void PDF_D_Cleo::setObservables(config c)
{
    switch(c)
    {
    case truth:
    {
        setObservablesTruth();
        break;
    }
    case toy:
    {
        setObservablesToy();
        break;
    }
    case cleo:
        obsValSource = "Cleo 2009 ARXIV:0903.4853";
        setObservable("kD_k3pi_obs",0.33);
        setObservable("dD_k3pi_obs",DegToRad(114.0));
        setObservable("kD_kpipi0_obs",0.84);
        setObservable("dD_kpipi0_obs",DegToRad(227.));
        setObservable("xD_obs",     0.96 /100.);
        setObservable("yD_obs",     0.81 /100.);
        setObservable("dD_kpi_obs", DegToRad(-151.5+360.));
        setObservable("B1_obs",     3.89e-2);
        setObservable("B2_obs",     1.47e-4);
        setObservable("B3_obs",     7.96e-2);
        setObservable("B4_obs",     2.65e-4);
        setObservable("B5_obs",     13.8e-2);
        setObservable("B6_obs",     3.05e-4);
        break;

    default:
        cout << "PDF_D_Cleo::setObservables() : ERROR : config "+ConfigToTString(c)+" not found." << endl;
        exit(1);
    }
}
void PDF_Dmixing_CLEO2D::setObservables(config c)
{
    switch(c)
    {
    case truth: {
        setObservablesTruth();
        break;
    }
    case toy: {
        setObservablesToy();
        break;
    }
    case cleo2009: {
        obsValSource = "arXiv:0903.4853 - CLEO 2009";
        setObservable("dD_k3pi_obs",DegToRad(114.0));
        setObservable("kD_k3pi_obs",0.33);
        break;
    }
    case cleo2014: {
        obsValSource = "arXiv:1401.1904 - CLEO 2013";
        setObservable("dD_k3pi_obs",DegToRad(255.0));  // CLEO 2014
        setObservable("kD_k3pi_obs",0.32);             // CLEO 2014
        break;
    }
    case cleo2015: {
        obsValSource = "Guy";
        setObservable("dD_k3pi_obs",DegToRad(170.0));  // CLEO 2015
        setObservable("kD_k3pi_obs",0.32);             // CLEO 2015
        break;
    }
    default: {
        cout << "PDF_Dmixing_CLEO2D::setObservables() : ERROR : config "+ConfigToTString(c)+" not found." << endl;
        exit(1);
    }
    }
}
void WASDCameraController::UpdateCamAlt3But(Camera * camera)
{		
    if (!camera)return;
    viewZAngle += (stopPt.x - startPt.x);
    viewYAngle += (stopPt.y - startPt.y);
    
    
    if(viewYAngle < -MAX_ANGLE)
        viewYAngle = -MAX_ANGLE;
    
    if(viewYAngle > MAX_ANGLE)
        viewYAngle = MAX_ANGLE;


    Matrix4 mt, mt2;
    mt.CreateRotation(Vector3(0,0,1), DegToRad(viewZAngle));
    mt2.CreateRotation(Vector3(1,0,0), DegToRad(viewYAngle));
    mt2 *= mt;
    
    Vector3 position = center - Vector3(0, radius, 0) * mt2;
    
    camera->SetTarget(center);
    camera->SetPosition(position);
}
Esempio n. 25
0
//================================================================================
//  SIMPLE 2D rotation matrix for rose compass
//  To speed up CPU we use a table of sin and cos for 10° increments.
//  Todo:   Try to compute in integer by multipling all trigonometrics values by 16384
//          to get 4 digits of precision.
//    Then shift out results for x and y values.
//================================================================================
CRoseMatrix::CRoseMatrix()
{ int inx = 0;
  float deg = 0;
  float rad = 0;
  while (inx < 9)
  { rad = DegToRad(deg);
    sinB[inx] = sin(rad);
    cosB[inx] = cos(rad);
    deg += 10;
    inx ++;
  }
  sinN  = 1;
  cosN  = 0;
  sin5  = sin(5 * DEG2RAD);
  cos5  = cos(5 * DEG2RAD);
}
void CTestGame::Render()
{
    //draw background
    SDL_Rect* rect = MakeRect(0,0,GetScreenWidth(),GetScreenHeight());
    int col = SDL_MapRGB(Display_Surface->GetSDLSurface()->format,255,255,255);
    Display_Surface->FillRect(rect,col);
    delete rect;

    //draw rotated image
    mysurface->Draw(Display_Surface,x,y,DegToRad(angle));
    //mysurface->Draw(Display_Surface,100,100);

    //draw fps and other stats
    CGame::GameStats->Draw(Display_Surface);
    CGame::GameOutput->Draw(Display_Surface);
}
Esempio n. 27
0
void ProtHelpObject::BuildMesh()
{
   if(meshBuilt)
      return;
   int nverts = 7;
   int nfaces = 8;
   mesh.setNumVerts(nverts);
   mesh.setNumFaces(nfaces);

   float d = 5.0f;
   float ds = 0.866f * d;
   float h = 2.0f * 0.866f * 5.0f;

   mesh.setVert(0, Point3(0.0f, 0.0f, 0.0f ));
   mesh.setVert(1, Point3(  -d,  -ds, -h ));
   mesh.setVert(2, Point3(   d,  -ds, -h ));
   mesh.setVert(3, Point3(0.0f,   ds, -h ));
   mesh.setVert(4, Point3(  -d,  -ds,  h ));
   mesh.setVert(5, Point3(   d,  -ds,  h ));
   mesh.setVert(6, Point3(0.0f,   ds,  h ));
   mesh.faces[0].setVerts(0, 1, 2);
   mesh.faces[0].setEdgeVisFlags(1,1,1);
   mesh.faces[1].setVerts(0, 2, 3);
   mesh.faces[1].setEdgeVisFlags(1,1,1);
   mesh.faces[2].setVerts(0, 3, 1);
   mesh.faces[2].setEdgeVisFlags(1,1,1);
   mesh.faces[3].setVerts(3, 2, 1);
   mesh.faces[3].setEdgeVisFlags(1,1,1);
   mesh.faces[4].setVerts(0, 5, 4);
   mesh.faces[4].setEdgeVisFlags(1,1,1);
   mesh.faces[5].setVerts(0, 6, 5);
   mesh.faces[5].setEdgeVisFlags(1,1,1);
   mesh.faces[6].setVerts(0, 4, 6);
   mesh.faces[6].setEdgeVisFlags(1,1,1);
   mesh.faces[7].setVerts(4, 5, 6);
   mesh.faces[7].setEdgeVisFlags(1,1,1);
#if 1
   // whoops- rotate 90 about x to get it facing the right way
   Matrix3 mat;
   mat.IdentityMatrix();
   mat.RotateX(DegToRad(90.0));
   for (int i=0; i<nverts; i++)
      mesh.getVert(i) = mat*mesh.getVert(i);
#endif
// mesh.buildNormals();
   meshBuilt = 1;
}
Esempio n. 28
0
//-----------------------------------------------------------------------------
CPUTResult CPUTCamera::LoadCamera(CPUTConfigBlock *pBlock, int *pParentID)
{
    // TODO: Have render node load common properties.
    CPUTResult result = CPUT_SUCCESS;

    mName = pBlock->GetValueByName("name")->ValueAsString();
    *pParentID = pBlock->GetValueByName("parent")->ValueAsInt();

    mFov = pBlock->GetValueByName("FieldOfView")->ValueAsFloat();
    mFov = DegToRad(mFov);
    mNearPlaneDistance = pBlock->GetValueByName("NearPlane")->ValueAsFloat();
    mFarPlaneDistance = pBlock->GetValueByName("FarPlane")->ValueAsFloat();

    LoadParentMatrixFromParameterBlock( pBlock );

    return result;
}
Esempio n. 29
0
void ComputeMouseVector(int winx,int winy){
		/* Win32 is a bit strange about the x, y position that
		   it returns when the mouse is off the left or top edge
		   of the window (due to them being unsigned). therefore,
		   roll the Win32's 0..2^16 pointer co-ord range to the
		   more amenable (and useful) 0..+/-2^15. */
	if(winx & 1 << 15) winx -= (1 << 16);
	if(winy & 1 << 15) winy -= (1 << 16);
	MouseX=winx;
	MouseY=Height-winy;  // I prefer opengl's standard of origin in bootom left
	float spread = tanf(DegToRad(viewangle/2));  
	float y = spread * ((MouseY)-Height/2) /(Height/2.0f);
	float x = spread * (MouseX-Width/2)  /(Height/2.0f);
	float3 v(x ,y,-1.0f); 
	// v=UserOrientation *v;
	v=normalize(v);
	MouseVector = v;
}
Esempio n. 30
0
void RenderHelper::DrawCircle(const Vector3 & center, float32 radius)
{
	Polygon3 pts;
    float32 angle = SEGMENT_LENGTH / radius;
	int ptsCount = (int)(2 * PI / (DegToRad(angle))) + 1;


	for (int k = 0; k < ptsCount; ++k)
	{
		float32 angle = ((float)k / (ptsCount - 1)) * 2 * PI;
		float32 sinA = sinf(angle);
		float32 cosA = cosf(angle);
		Vector3 pos = center - Vector3(sinA * radius, cosA * radius, 0);

		pts.AddPoint(pos);
	}
    DrawPolygon(pts, false);
}