Пример #1
0
// ==============================================================================================================================================
//
void Orbit::SetOrbitPosition(double t)
{
	VECTOR3 x=Position(t), xx=Tangent(t);
	rv=x, vv=xx;
	trl = t;
	tra = limit(trl-lpe);
	mna = tra2mna(tra,ecc);
}
Пример #2
0
Matrix4 perspective(Scalar fovy, Scalar aspectRatio, Scalar near, Scalar far)
{
  Scalar xMax, yMax;
  yMax = near * Tangent(DegToRad(fovy / 2));
  xMax = yMax * aspectRatio;
  return frustum(-xMax, xMax, -yMax, yMax, near, far);

}
Пример #3
0
// ==============================================================================================================================================
// Hyberbolic use only
// ReCalculate orbit position (mna,tra,trl,rad,vel)
//
void Orbit::SetTimeToPeriapsis(double t)
{
	if (Defined()) {
		mna = -t * MeanMotion();
		tra = mna2tra(mna,ecc);
		trl = limit(tra+lpe);
		vv  = Tangent(trl);
		rv  = Position(trl);
		rad = length(rv);
		vel = length(vv);
	}
}
task PostCalc(){
	while(true)
	{
		x = (-1*dist)* (Tangent(leftcurrent))/(Tangent(leftcurrent))-(Tangent(rightcurrent));
		y = (dist)* Tangent(leftcurrent) * (Tangent(rightcurrent))/(Tangent(rightcurrent)) - (Tangent(leftcurrent));
		//add stuff here
		wait1Msec(1000);
	}
}
Пример #5
0
	void ModelOBJ::CreateVertexTangentsBinormals( const MaterialGroupIterator & p_MatGroupIt, BIT_FLOAT32 * p_pTangents,
		BIT_FLOAT32 * p_pBinormals, const BIT_UINT32 p_TriangleCount )
	{
		// Go through all the triangles
		BIT_UINT32 ti = 0;
		for( TriangleIterator it_tr = (*p_MatGroupIt)->Triangles.begin( ); it_tr != (*p_MatGroupIt)->Triangles.end( ); it_tr++ )
		{

			for( BIT_UINT32 vt = 0; vt < 3; vt++ )
			{
				Vector3_ui32 Indices( vt, ( vt + 1 ) % 3, ( vt + 2 ) % 3 );

				const Vector3_f32 Vertex1 = m_VertexPositions[ (*it_tr).PositionIndices[ Indices.x ] ];
				const Vector3_f32 Vertex2 = m_VertexPositions[ (*it_tr).PositionIndices[ Indices.y ] ];
				const Vector3_f32 Vertex3 = m_VertexPositions[ (*it_tr).PositionIndices[ Indices.z ] ];

				const Vector2_f32 Texture1 = m_TexturePositions[ (*it_tr).TextureIndices[ Indices.x ] ];
				const Vector2_f32 Texture2 = m_TexturePositions[ (*it_tr).TextureIndices[ Indices.y ] ];
				const Vector2_f32 Texture3 = m_TexturePositions[ (*it_tr).TextureIndices[ Indices.z ] ];

				float x1 = Vertex2.x - Vertex1.x;
				float x2 = Vertex3.x - Vertex1.x;
				float y1 = Vertex2.y - Vertex1.y;
				float y2 = Vertex3.y - Vertex1.y;
				float z1 = Vertex2.z - Vertex1.z;
				float z2 = Vertex3.z - Vertex1.z;

				float s1 = Texture2.x - Texture1.x;
				float s2 = Texture3.x - Texture1.x;
				float t1 = Texture2.y - Texture1.y;
				float t2 = Texture3.y - Texture1.y;

				float r = 1.0f / ( s1 * t2 - s2 * t1 );

				// Tangent
				if( p_pTangents )
				{
					Vector3_f32 Tangent( (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r,
						(t2 * z1 - t1 * z2) * r );
					Tangent.Normalize( );

					p_pTangents[ ( ti * 9 ) + ( vt * 3 ) + 0 ] = Tangent.x;
					p_pTangents[ ( ti * 9 ) + ( vt * 3 ) + 1 ] = Tangent.y;
					p_pTangents[ ( ti * 9 ) + ( vt * 3 ) + 2 ] = Tangent.z;
				}

				// Binormal
				if( p_pTangents )
				{
					Vector3_f32 Binormal( (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r,
						(s1 * z2 - s2 * z1) * r );
					Binormal.Normalize( );

					p_pBinormals[ ( ti * 9 ) + ( vt * 3 ) + 0 ] = Binormal.x;
					p_pBinormals[ ( ti * 9 ) + ( vt * 3 ) + 1 ] = Binormal.y;
					p_pBinormals[ ( ti * 9 ) + ( vt * 3 ) + 2 ] = Binormal.z;
				}
			}

			// Increment the triangle index
			ti++;
		}


	}