コード例 #1
0
ファイル: WorldEditor.cpp プロジェクト: uvbs/GameProject
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();
}
コード例 #2
0
ファイル: debugShow.cpp プロジェクト: uvbs/GameProject
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();
    }

}
コード例 #3
0
ファイル: VSAAlgebra.cpp プロジェクト: sfegan/ChiLA
Vec3D Vec3D::makeRotation(const Vec3D& v1, const Vec3D& v2, 
			  Subspace2D subspace)
{
  Vec3D ea(v1);
  ea.normalize();
  Vec3D eb(v2);
  eb -= (ea*eb)*ea;
  eb.normalize();
  Vec3D ec;

  switch(subspace)
    {
    case SS_12:
      ec = ea^eb;
      break;
    case SS_23:
      ec = eb;
      eb = ea;
      ea = eb^ec;
      break;
    case SS_31:
      ec = ea;
      ea = eb;
      eb = ec^ea;
      break;
    }

  Vec3D r2 = Vec3D(0,0,1)^ec;
  double sin_theta = r2.norm();
  double cos_theta = ec.z();
  if(sin_theta!=0)r2 *= atan2(sin_theta,cos_theta)/sin_theta;

  Vec3D r2t_ea(ea); r2t_ea.rotate(-r2);
  //Vec r2t_eb(eb); r2t_eb.rotate(-r2);

  double sin_phi = r2t_ea.y();
  double cos_phi = r2t_ea.x();
  Vec3D r1 = Vec3D(0,0,atan2(sin_phi,cos_phi));

  Vec3D rc(r1); rc &= r2;
  return rc;
}
コード例 #4
0
ファイル: TFlyObjectEdit.cpp プロジェクト: uvbs/GameProject
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();
}
コード例 #5
0
ファイル: NavMesh.cpp プロジェクト: uvbs/GameProject
	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;
	}
コード例 #6
0
ファイル: Utils.cpp プロジェクト: OpenedHand/ogles
	void CopyVector(const Vec3D & vector, GLfixed *params) {
		params[0] = vector.x();
		params[1] = vector.y();
		params[2] = vector.z();
	}
コード例 #7
0
ファイル: VSAAlgebra.cpp プロジェクト: sfegan/ChiLA
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;
}