Esempio n. 1
0
void WorldEditor::render( int skip )
{

	viewportScreen.Render( camView.Object() , TRUE , TRUE );

	float fps = updateFPS();

	TMessageShow msgShow( m_world );
	msgShow.start();
	msgShow.push( "Fps: %6.2f", fps );
	{
		Vec3D pos = camControl.getPosition();
		Vec3D dir = camControl.getViewDir();
		msgShow.push( "Cam pos = ( %.1f %.1f %.1f ) viewDir = ( %.2f %.2f %.2f )" ,
			pos.x() , pos.y() , pos.z() , dir.x() , dir.y() , dir.z() );
	}


	g_devLog.show( msgShow );

	//if ( EditData* data = m_objEdit.getSelectEditData())
	//{
	//	if ( TActor* actor = TActor::upCast( data->entity ) )
	//	{
	//		Vec3D  pos = actor->getPosition();
	//		msgShow.push( "Hit pos = ( %.1f %.1f %.1f ) " ,
	//			pos.x() , pos.y() ,pos.z()  );
	//		actor->getFlyActor().GetWorldPosition( pos );
	//		msgShow.push( "Hit pos = ( %.1f %.1f %.1f ) " ,
	//			pos.x() , pos.y() ,pos.z()  );
	//	}
	//}
	
	if ( m_player )
	{
		Vec3D dir = m_player->getFaceDir();
		msgShow.push( "viewDir = ( %.2f %.2f %.2f )" , dir.x() , dir.y() , dir.z() );
		m_player->getFlyActor().GetDirection( dir , NULL );
		msgShow.push( "viewDir = ( %.2f %.2f %.2f )" , dir.x() , dir.y() , dir.z() );
		FnObject obj; obj.Object( m_player->getFlyActor().GetBaseObject() );
		msgShow.push( "viewDir = ( %.2f %.2f %.2f )" , dir.x() , dir.y() , dir.z() );
	}

	if ( m_Mode == MODE_RUN )
	{
		TProfileIterator* profIter = TProfileManager::createIterator();

		profIter->getCurNode()->showAllChild( true );
		showProfileInfo( profIter , msgShow , NULL );
		TProfileManager::releaseIterator( profIter );
	}



	msgShow.finish();

	m_world.SwapBuffers();
}
Esempio n. 2
0
void Camera::moveRelative(const Vec3D& direction) {
    float elevation = position_.z() - terrain_.heightMap().elevation(Vec2D(position_.x(), position_.y()));

    Vec3D d;
    d.x() = direction.x() * std::cos(rotation_.z()) - direction.y() * std::sin(rotation_.z());
    d.y() = direction.x() * std::sin(rotation_.z()) + direction.y() * std::cos(rotation_.z());

    position_ += d;

    position_.z() = terrain_.heightMap().elevation(Vec2D(position_.x(), position_.y())) + elevation;
}
Esempio n. 3
0
void TShadowManager::refreshTerrainTri()
{
	std::vector< int >& triVec = FuCShadowModify::getTriIDVec();

	triVec.clear();

	FnTriangle tT;
	tT.Object( curLevel->getFlyTerrain().Object() , 0);

	Vec3D actorPos = m_player->getPosition();
	int nList = tT.GetTriangleNumber();

	int tri[3];
	float pos[16];

	float r2 = gShadowMaxRadius * gShadowMaxRadius;

	for (int i = 0; i < nList; i++)
	{
		tT.GetTopology( i , tri);
		tT.GetVertex(tri[0], pos);
		float dx = actorPos.x() - pos[0];
		float dy = actorPos.y() - pos[1];
		if ( dx * dx + dy * dy < r2 )
			triVec.push_back( i );
	}
}
Esempio n. 4
0
Color Cylinder::getDifColor(const Vec3D& pnt, const CIsect& isect/* = CIsect()*/) const
{
	if (mMtrl->DifTexture)
	{
		Vec3D texCoords = getTexCoords(pnt, isect);
		return scale3D(mMtrl->DifTexture->sample(texCoords.x(), texCoords.y()), mMtrl->DifColor);
	}
	return mMtrl->DifColor;
}
Esempio n. 5
0
void PlayerBoxTrigger::debugDraw( bool beDebug )
{
    if ( beDebug )
    {
        FnMaterial mat = UF_CreateMaterial();
        mat.SetEmissive( Vec3D(1,1,1) );
        Vec3D min , max;
        getPhyBody()->getAabb( min , max  );
        Vec3D len = 0.5 * ( max - min );
        UF_CreateBoxLine( &m_dbgObj , len.x() , len.y() , len.z() , mat.Object());
    }
    else
    {
        m_dbgObj.RemoveAllGeometry();
    }

}
Esempio n. 6
0
void TFlyObjectEdit::drawText( FnWorld& gw , int x , int y )
{
	if ( m_selectIndex == -1 )
		return;

	char str[128];
	gw.StartMessageDisplay();
	sprintf( str , "SelectObjectID = %d ", m_selectObj );
	gw.MessageOnScreen( x ,  y , str , 255, 0, 0 );
	{
		Vec3D pos , front , up ;
		m_selectObj.GetWorldPosition( &pos[0] );
		m_selectObj.GetDirection( &front[0] , &up[0] );
		m_selectObj.GetWorldDirection( &front[0] , &up[0] );
		sprintf(str , "Pos = ( %2.2f %2.2f %2.2f ) front = ( %.3f %.3f %.3f )", 
			pos.x() , pos.y() , pos.z() , front.x() , front.y() , front.z() );
		gw.MessageOnScreen( x , y + 15  , str, 255, 0, 0);
	}

	gw.FinishMessageDisplay();
}
Esempio n. 7
0
	int testVertex( int v , Vec3D& vtx )
	{
		int cx = int( vtx.x() / m_cellLen );
		int cy = int( vtx.y() / m_cellLen );
		int cz = int( vtx.z() / m_cellLen );

		for ( int i = -1 ; i <= 1 ; ++i )
		for ( int j = -1 ; j <= 1 ; ++j )
		for ( int k = -1 ; k <= 1 ; ++k )
		{
			unsigned cell = computeHashCellIndex( cx + i , cy + j , cz + j );
			int vT = testVertex( vtx , cell );

			if ( vT != -1)
				return vT;
		}

		unsigned cell = computeHashCellIndex( cx  , cy  , cz  );
		m_cell[cell].push_back( v );

		return -1;
	}
Esempio n. 8
0
	void CopyVector(const Vec3D & vector, GLfixed *params) {
		params[0] = vector.x();
		params[1] = vector.y();
		params[2] = vector.z();
	}
Esempio n. 9
0
int main(int argc, char**argv)
{
  // Test roots solver
  
  unsigned nroots;

#if 0
  double roots2[2];
  double roots3[3];

  double a,b,c,d;
  double A,B,C;

  // (x-A)*(x-B) = x*x - (A+B)*x + A*B

  A = -17;
  B = 10;
  a = -3;
  b = -a*(A+B);
  c = a*A*B;

  nroots = VSAMath::realRoots2(a,b,c,roots2);
  std::cout << nroots << ' ' << roots2[0] << ' ' << roots2[1] << std::endl;

  A = -5;
  B = -5;
  a = 2;
  b = -a*(A+B);
  c = a*A*B;

  nroots = VSAMath::realRoots2(a,b,c,roots2);
  std::cout << nroots << ' ' << roots2[0] << ' ' << roots2[1] << std::endl;

  // (x-A)*(x-B)*(x-C) = x*x*x - (A+B+C)*x*x + (A*B+A*C+B*C)*x - A*B*C

  A = -17;
  B = 10;
  C = 34;
  a = -2;
  b = -a*(A+B+C);
  c = a*(A*B+A*C+B*C);
  d = -a*A*B*C;

  nroots = VSAMath::realRoots3(a,b,c,d,roots3);
  std::cout << nroots << ' ' 
	    << roots3[0] << ' ' << roots3[1] << ' ' << roots3[2] << std::endl;

  A = 12;
  B = 12;
  C = 17;
  a = 2;
  b = -a*(A+B+C);
  c = a*(A*B+A*C+B*C);
  d = -a*A*B*C;

  nroots = VSAMath::realRoots3(a,b,c,d,roots3);
  std::cout << nroots << ' ' 
	    << roots3[0] << ' ' << roots3[1] << ' ' << roots3[2] << std::endl;

  A = 10;
  B = 10;
  C = 10;
  a = 2;
  b = -a*(A+B+C);
  c = a*(A*B+A*C+B*C);
  d = -a*A*B*C;

  nroots = VSAMath::realRoots3(a,b,c,d,roots3);
  std::cout << nroots << ' ' 
	    << roots3[0] << ' ' << roots3[1] << ' ' << roots3[2] << std::endl;
#endif

  //Symmetric3D matrix(1,2,3,4,5,6);
  //Symmetric3D matrix(1,0,0,0,0,0);
  //Symmetric3D matrix(0,0,0,0,0,0);
  //Symmetric3D matrix(0,0,0,1,1,0);
  //Symmetric3D matrix(0,0,0,1,0,0);
  //Symmetric3D matrix(0,0,0,0,1,0);
  //Symmetric3D matrix(0,0,0,0,0,1);
  //Symmetric3D matrix(1.0625,1.1875,1.75,-0.108253175473055,0.216506350946110,-0.375);

  RandomNumbers rng(RandomNumbers::defaultFilename().c_str());
  Eigen3D e;

#if 0
  for(unsigned i=0;i<10000000;i++)
    {
      Symmetric3D matrix(rng.Uniform(),rng.Uniform(),rng.Uniform(),
			 rng.Uniform(),rng.Uniform(),rng.Uniform());
      //nroots = matrix.eigenJacobi(e);
      nroots = matrix.eigenQL(e);
      //std::cout << e.val[0] << std::endl;      
    }
#endif


#if 1
  Symmetric3D matrix(rng.Uniform(),rng.Uniform(),rng.Uniform(),
		     rng.Uniform(),rng.Uniform(),rng.Uniform());
#else
  Symmetric3D matrix(0.641933, 0.587790, 0.858495, 
		     0.683663, 0.302988, 0.970878);
#endif
  std::cout << std::fixed
	    << matrix.a11() << '\t' << matrix.a12() << '\t' << matrix.a13() 
	    << std::endl
	    << matrix.a12() << '\t' << matrix.a22() << '\t' << matrix.a23() 
	    << std::endl
	    << matrix.a13() << '\t' << matrix.a23() << '\t' << matrix.a33() 
	    << std::endl << std::endl;

  nroots = matrix.eigenJacobi(e);
  std::cout << "N eigenvalues: " << nroots << std::endl;
  for(unsigned i=0;i<3;i++)
    std::cout << "l" << i << " = " << e.val[i]
	      << "\te" << i << " = " 
	      << e.vec[i].x() << '\t' << e.vec[i].y() << '\t' << e.vec[i].z()
	      << std::endl;
  std::cout << std::endl;

  nroots = matrix.eigenQL(e);
  std::cout << "N eigenvalues: " << nroots << std::endl;
  for(unsigned i=0;i<3;i++)
    std::cout << "l" << i << " = " << e.val[i]
	      << "\te" << i << " = " 
	      << e.vec[i].x() << '\t' << e.vec[i].y() << '\t' << e.vec[i].z()
	      << std::endl;

#if 0
  Orthogonal3D u(e.vec[0],e.vec[1]);
  Symmetric3D d = u.transFwd(matrix);
  std::cout << std::fixed
	    << d.a11() << '\t' << d.a12() << '\t' << d.a13() << std::endl
	    << d.a12() << '\t' << d.a22() << '\t' << d.a23() << std::endl
	    << d.a13() << '\t' << d.a23() << '\t' << d.a33() << std::endl 
	    << std::endl;

  Symmetric3D d2 = u.inverse().transBwd(matrix);
  std::cout << std::fixed
	    << d2.a11() << '\t' << d2.a12() << '\t' << d2.a13() << std::endl
	    << d2.a12() << '\t' << d2.a22() << '\t' << d2.a23() << std::endl
	    << d2.a13() << '\t' << d2.a23() << '\t' << d2.a33() << std::endl 
	    << std::endl;

  Vec3D phi(1,2,3);
  Vec3D varphi;
  Vec3D psi(3,4,5);

  Orthogonal3D u2(psi,phi,SS_31);

  psi.normalize();
  phi -= psi*(psi*phi);
  phi.normalize();
  varphi = psi^phi;

  std::cerr << phi.x() << '\t' << phi.y() << '\t' << phi.z() << std::endl
	    << varphi.x() << '\t' << varphi.y() << '\t' << varphi.z() << std::endl
	    << psi.x() << '\t' << psi.y() << '\t' << psi.z() << std::endl
	    << std::endl
	    << u2.ax() << '\t' << u2.ay() << '\t' << u2.az() << std::endl
	    << u2.bx() << '\t' << u2.by() << '\t' << u2.bz() << std::endl
	    << u2.cx() << '\t' << u2.cy() << '\t' << u2.cz() << std::endl;
#endif

  return 0;
}