예제 #1
0
EditData& TFlyObjectEdit::createActor( char const* name , unsigned modelID )
{
	EditData data;
	data.flag |= EF_SAVE_XFORM | EF_CREATE;

	TCamera& cam = m_game->getCamControl();

	Vec3D pos = cam.getCameraPos() + 500 * cam.getViewDir();

	XForm trans;
	trans.setIdentity();

	TActor* entity = new TActor( modelID ,trans );
	data.type = EOT_TNPC;
	m_curLevel->addEntity( entity );
	data.flag |= EF_LOAD_MODEL;

	FnObject obj;
	obj.Object(  entity->getFlyActor().GetBaseObject() );

	obj.SetPosition( pos );
	obj.SetDirection( Vec3D(1,0,0) , Vec3D(0,0,1) );
	obj.SetName( (char*) name );
	entity->getFlyActor().SetName((char*) name);

	data.id     = obj.Object();
	data.entity = entity;

	g_editDataVec.push_back( data );

	return g_editDataVec.back();

}
예제 #2
0
MiniMap::MiniMap(WORLDid gID, SCENEid sMiniID, Lyubu *lyubu, int x_pos, int y_pos, int width, int height )
{
	FnWorld gw;
	FnScene scene;
	FnViewport vp;
	FnCamera camera;
	FnObject camStand;
	FnTerrain terrain;
	//adr_turn = this->turn;
	/*
	pos_begin[0]=3569.0;
	pos_begin[1]=-3208.0;
	pos_begin[2]=1000.0f;
	*/
	gw.Object(gID);

	//miniMap
	gw.SetObjectPath("Data\\NTU4\\Scenes");
	FnScene miniScene;
	miniScene.Object(sMiniID);
	miniTerrainID = miniScene.CreateObject(ROOT);
	FnObject miniTerrain;
	miniTerrain.Object(miniTerrainID);
	miniTerrain.Load("terrain");
	miniTerrain.SetOpacity(0.8f);

	// create a camera stand for minimap
	miniMapStandID = miniScene.CreateObject(ROOT);

	gw.SetObjectPath("Data\\NTU4\\Characters");
	anchorID = miniScene.CreateObject(miniMapStandID);
	FnObject anchor;
	anchor.Object(anchorID);
	anchor.Load("arrowGreen");
	float pos[]={0,0,10};
	anchor.SetPosition(pos);

   // create a camera for minimap
	miniMapCameraID = miniScene.CreateCamera(miniMapStandID);
	FnCamera miniCamera;
	miniCamera.Object(miniMapCameraID);
	miniCamera.Translate(0.0f, 0.0f, 5000.0f, REPLACE);
	miniCamera.SetNear(5.0f);
	miniCamera.SetFar(100000.0f);
	miniCamera.Rotate(Z_AXIS, 180.0f, LOCAL);

	// create a light for minimap camera
	FnLight miniLight;
	miniLight.Object(miniScene.CreateLight(miniMapCameraID));
	miniLight.SetIntensity(1.0f);
	miniLight.SetRange(9500.0f);

	vpMiniMapID = gw.CreateViewport(x_pos, y_pos, width, height);
}
예제 #3
0
	void save(EditData& data)
	{
		type = data.type;
		flag = data.flag;

		switch( data.type )
		{
		case EOT_TOBJECT:
			if  ( data.flag & EF_LOAD_MODEL )
			{
				TObject* tObj = TObject::upCast( data.entity );
				modelID = tObj->getModelID();
			}
			break;
		case EOT_TNPC:
			{
				TActor* actor = TActor::upCast( data.entity );
				modelID = actor->getModelID();
			}
			break;
		case EOT_TERRAIN:
		case EOT_FLY_OBJ:
		case EOT_OTHER:
			break;
		}


		FnObject obj; obj.Object( data.id );
		name = obj.GetName();
		if ( data.flag & EF_SAVE_XFORM )
		{
			obj.GetWorldPosition( pos );
			obj.GetWorldDirection( front , up );
		}
	}
BOOL ActorStateMachine::initLife(){
	this->life = (int) MAX_LIFE;

	FnScene scene;
	scene.Object(sID);
	bloodID = scene.CreateObject(ROOT);
	FnObject blood;
	blood.Object(bloodID);
	//FnBillBoard blood;
	//blood.Object(bloodID, 0);
	FnActor actor;
	actor.Object(this->character);
	OBJECTid baseID = actor.GetBaseObject();

	float pos[3], size[2], color[3];
	pos[0] = 0.0f;
	pos[1] = 0.0f;
	pos[2] = 80.0f;
	size[0] = 50.0f;
	size[1] = 2.0f;
	color[0] = 1.0f; color[1] = color[2] = 0.0f;
	blood.Billboard(pos, size, NULL, 0, color);
	blood.SetParent(baseID);
	return TRUE;
}
예제 #5
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();
}
예제 #6
0
static void FuShadowDisplayCallback(OBJECTid oID)
{
   FnObject seed;
   FuCShadowModify **s;

   seed.Object(oID);
   s = (FuCShadowModify **) seed.GetData();

   (*s)->Display();
}
예제 #7
0
void TFlyObjectEdit::showObject( unsigned typeBit , bool isShow )
{
	int type = 1 << typeBit;
	for( int i =0;i < g_editDataVec.size() ; ++i )
	{
		EditData& data = g_editDataVec[i];
		if ( data.type & typeBit )
		{
			FnObject obj; obj.Object( data.id );
			obj.Show( isShow );
		}
	}
}
예제 #8
0
//------------------------------------------------------------------------------------
// timer callback function which will be invoked by TheFly3D System every 1/30 second
// C.Wang 0308, 2004
//------------------------------------------------------------------------------------
void GameAI(int skip)
{
   if (mmID != FAILED_ID) {
      FnMedia md;
      md.Object(mmID);
      if (md.GetState() == MEDIA_STOPPED) {
         // after playing, delete the media object
         FyDeleteMediaPlayer(mmID);
         mmID = FAILED_ID;
      }
      else {
         return;
      }
   }

   FnLight lgt;
   lgt.Object(lID);
   lgt.Rotate(Z_AXIS, 0.5f, GLOBAL);

   FnObject model;
   model.Object(nID);
   model.Rotate(Z_AXIS, 3.0f, GLOBAL);

   // render the scene
   FnViewport vp;
   vp.Object(vID);
   vp.Render3D(cID, TRUE, TRUE);

   // show frame rate

   static char string[128];

   if (frame == 0) {
      FyTimerReset(0);
   }

   if (frame/10*10 == frame) {
      float curTime;

      curTime = FyTimerCheckTime(0);
      sprintf(string, "Fps: %6.2f", frame/curTime);
   }

   frame += skip;

   if (frame >= 1000) {
      frame = 0;
   }

   FySwapBuffers();
}
예제 #9
0
	void load(EditData& data , TLevel* level )
	{
		FnScene& scene = level->getFlyScene();
		data.type  = type;
		data.flag  = flag;

		switch( data.type )
		{
		case EOT_TOBJECT:
			if  ( data.flag & EF_LOAD_MODEL )
			{
				TObject* tObj = new TObject( modelID );
				level->addEntity( tObj );
				data.id = tObj->getFlyObj().Object();
				data.entity = tObj;
			}
			break;
		case EOT_TNPC:
			{
				XForm trans; trans.setIdentity();
				TActor* actor = new TActor(  modelID , trans );
				level->addEntity( actor );
				data.id = actor->getFlyActor().GetBaseObject();
				data.entity = actor;
			}
			break;
		case EOT_TERRAIN:
		case EOT_FLY_OBJ:
		case EOT_OTHER:
			data.id = scene.GetObjectByName( (char*) name.c_str() );
			break;
		}

		FnObject obj; obj.Object( data.id );
		obj.SetName( (char*) name.c_str() );

		if ( data.flag & EF_SAVE_XFORM )
		{
			obj.SetWorldPosition( pos );
			obj.SetWorldDirection( front , up );
		}
	}
예제 #10
0
void TFlyObjectEdit::saveTerrainData( char const* name )
{
	TTerrainData terrain;

	for( int i=0; i < g_editDataVec.size(); ++i )
	{
		EditData& data = g_editDataVec[i];

		if ( data.type == EOT_TERRAIN )
		{
			FnObject obj; obj.Object( data.id );
			terrain.add( obj );
		}
	}
	TString terrFile = TString(name) + ".ter"; 
	terrain.save( terrFile.c_str() );

	TString bvhFile = TString(name) + ".bvh";
	btBvhTriangleMeshShape* shape = terrain.createConcaveShape( bvhFile.c_str() );
	delete shape;

}
예제 #11
0
/*-------------------------------------
  constructor of classic shadow object
  C.Wang 0608, 2007
 --------------------------------------*/
FuCShadowModify::FuCShadowModify(SCENEid sID, int rgID)
{
   // initialize the shadow
   mHost = sID;
   mShadowMat = FAILED_MATERIAL_ID;
   mViewport = FAILED_ID;
   mRenderTarget = FAILED_MATERIAL_ID;

   // create the camera
   FnScene scene;
   FnObject seed;

   scene.Object(sID);
   m_lightCam.Object( scene.CreateCamera(ROOT) );

   // backup the rendering group
   int oldRG = scene.GetCurrentRenderGroup();

   if (rgID >= 0) {
      // set current rendering group
      scene.SetCurrentRenderGroup(rgID);
   }

   // create the seed object for displaying the shadow
   mSeed = scene.CreateObject(ROOT);
   seed.Object(mSeed);
   seed.BindPostRenderFunction(FuShadowDisplayCallback);
   seed.SetRenderOption(ALPHA, TRUE);
   FuCShadowModify **s = (FuCShadowModify **)seed.InitData(sizeof(FuCShadowModify *));
   *s = this;

   mShadowHeightOffset = 0.4f;
   mShadowSize = 50.0f;

   // recover current rendering group
   scene.SetCurrentRenderGroup(oldRG);

}
예제 #12
0
/*----------------------------------
  display the shadow on the terrain
  C.Wang 0522, 2006
 -----------------------------------*/
void FuCShadowModify::Display()
{
	TPROFILE("Shadow Display");

	if ( m_fyActor.Object() == FAILED_ID ) 
		return;

	FnObject model;
	model.Object(mSeed);
	if (!model.GetVisibility()) 
		return;

	WORLDid wID;
	FnTriangle tT;
	FnScene scene;
	FnTerrain terrain;
	int vLen , texLen = 2, tri[3];
	float M[16], *G, vLC[3];
	
	// get all neighboring triangles
	//nList = terrain.GetAllVertexNeighborTriangles(iOne, list, 64);
	//if (nList <= 0) return;

	// get the matrix to character's base coordinate
	m_lightCam.SetWorldPosition( m_actorPos );
	G = m_lightCam.GetMatrix(TRUE);
	FyInverseM16(G, M);

	tT.Object( m_terrain.Object() , 0);
	scene.Object(mHost);
	wID = scene.GetWorld();

	// reset all rendering states
	FyResetRenderStates(wID);
	FySetD3DRenderState(wID, D3DRS_LIGHTING, FALSE);
	FySetD3DRenderState(wID, D3DRS_FOGENABLE, FALSE);
	FySetD3DRenderState(wID, D3DRS_ZWRITEENABLE, FALSE);

	// set current material
	FySetCurrentMaterial(wID, mRenderTarget, FALSE, 1.0f);

	FySetD3DRenderState(wID, D3DRS_ALPHABLENDENABLE, TRUE);
	FySetD3DRenderState(wID, D3DRS_ALPHATESTENABLE, FALSE);
	FySetD3DRenderState(wID, D3DRS_SRCBLEND, D3DBLEND_ZERO);
	FySetD3DRenderState(wID, D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);

	LPDIRECT3DDEVICE9 dev = FyGetD3DDevice(wID);
	float pos[16];


	FuLitedVertex v[3];

	// display these triangles
	vLen = 6;

	v[0].diffuse = D3DCOLOR_RGBA(255, 255, 255, 255);
	v[1].diffuse = D3DCOLOR_RGBA(255, 255, 255, 255);
	v[2].diffuse = D3DCOLOR_RGBA(255, 255, 255, 255);

	int nTri = m_triIDVec.size();
	for ( int i = 0; i < nTri ; i++) 
	{
		// get the triangle vertices
		tT.GetTopology( m_triIDVec[i] , tri);

		for ( int j = 0; j < 3; ++j ) 
		{
			tT.GetVertex(tri[2-j], pos);
			v[j].pos[0] = pos[0];
			v[j].pos[1] = pos[1];
			v[j].pos[2] = pos[2] + mShadowHeightOffset;

			// calculate the texture coordinate
			FUTransformVertexWithM16_Simple(vLC, v[j].pos, M);
			CalculateShadowUV(vLC, v[j].uv);
		}

		FyDrawTriangles(wID, XYZ_DIFFUSE, 3 , 1 , &texLen, (float *) &v[0] );

	}

}
예제 #13
0
/*-----------------------
  show / hide the shadow
  C.Wang 0910, 2006
 ------------------------*/
void FuCShadowModify::Show(BOOL beShow)
{
   FnObject seed;
   seed.Object(mSeed);
   seed.Show(beShow);
}
예제 #14
0
Donzo::Donzo( WORLDid gID, SCENEid sID )
{
	FnWorld gw;
	FnScene scene;

	HP_MAX = 9000;
	HP = HP_MAX;

	pos_begin[0]=3469.0;
	pos_begin[1]=-3208.0;
	pos_begin[2]=1000.0f;

	this->gID = gID;
	this->sID = sID;

	gw.Object(gID);
	scene.Object(sID);

	gw.SetObjectPath("Data\\NTU4\\Characters");
	gw.SetTexturePath("Data\\NTU4\\Characters");
	gw.SetCharacterPath("Data\\NTU4\\Characters");
	gw.SetShaderPath( "Data\\NTU4\\Shaders" );

	aID = scene.LoadActor("Donzo");
	actor.Object(aID);


	//-------action---------
	//IDLE
	ourIdleAction = new OurAction();
	ourIdleAction->actID = actor.GetBodyAction(NULL, "CombatIdle");
	ourIdleAction->frames_num = 0;
	ourIdleAction->play_speed = 1;
	ourIdleAction->priority = 0;
	ourIdleAction->type.value = DonzoAction::ACTION_IDLE();

	current_OurAction = ourIdleAction;
	actor.MakeCurrentAction(0, NULL, ourIdleAction->actID);

	ourCombatIdleAction = ourIdleAction;
	
	//Run
	ourRunAction = new OurAction();
	ourRunAction->actID = actor.GetBodyAction(NULL, "Run");
	ourRunAction->frames_num = 0;
	ourRunAction->play_speed = 1;
	ourRunAction->priority = 0;
	ourRunAction->type.value = Action_type::ACTION_WALK();

	//Attack
	ourAttack1Action = new OurAction();
	ourAttack1Action->actID = actor.GetBodyAction(NULL, "AttackL1");
	ourAttack1Action->isAttack = true;
	ourAttack1Action->frames_num = 0;
	ourAttack1Action->play_speed = 1;
	ourAttack1Action->priority = 5;
	ourAttack1Action->type.value = Action_type::ACTION_ATTACK();
	ourAttack1Action->numOfKeyFrames = 1;
	ourAttack1Action->keyFrames = new OurFrame*[1];
	ourAttack1Action->keyFrames[0] = new OurFrame;
	ourAttack1Action->keyFrames[0]->frameNO = 10;
	ourAttack1Action->keyFrames[0]->start_angle = 320;
	ourAttack1Action->keyFrames[0]->plus_angle = 80;
	ourAttack1Action->keyFrames[0]->valid_dis = 200;
	ourAttack1Action->keyFrames[0]->damage_pt = 100;

	ourHeavyAttack1Action = new OurAction();
	ourHeavyAttack1Action->actID = actor.GetBodyAction(NULL, "AttackH");
	ourHeavyAttack1Action->isAttack = true;
	ourHeavyAttack1Action->frames_num = 0;
	ourHeavyAttack1Action->play_speed = 1;
	ourHeavyAttack1Action->priority = ourAttack1Action->priority + 10;
	ourHeavyAttack1Action->type.value = Action_type::ACTION_ATTACK();
	ourHeavyAttack1Action->numOfKeyFrames = 3;
	ourHeavyAttack1Action->keyFrames = new OurFrame*[3];
	ourHeavyAttack1Action->keyFrames[0] = new OurFrame;
	ourHeavyAttack1Action->keyFrames[0]->frameNO = 23;
	ourHeavyAttack1Action->keyFrames[0]->start_angle = 270;
	ourHeavyAttack1Action->keyFrames[0]->plus_angle = 100;
	ourHeavyAttack1Action->keyFrames[0]->valid_dis = 200;
	ourHeavyAttack1Action->keyFrames[0]->damage_pt = 100;
	ourHeavyAttack1Action->keyFrames[1] = new OurFrame;
	ourHeavyAttack1Action->keyFrames[1]->frameNO = 42;
	ourHeavyAttack1Action->keyFrames[1]->start_angle = 270;
	ourHeavyAttack1Action->keyFrames[1]->plus_angle = 180;
	ourHeavyAttack1Action->keyFrames[1]->valid_dis = 200;
	ourHeavyAttack1Action->keyFrames[1]->damage_pt = 90;
	ourHeavyAttack1Action->keyFrames[2] = new OurFrame;
	ourHeavyAttack1Action->keyFrames[2]->frameNO = 70;
	ourHeavyAttack1Action->keyFrames[2]->start_angle = 0;
	ourHeavyAttack1Action->keyFrames[2]->plus_angle = 360;
	ourHeavyAttack1Action->keyFrames[2]->valid_dis = 200;
	ourHeavyAttack1Action->keyFrames[2]->damage_pt = 80;

	ourHeavyAttack2Action = new OurAction();
	ourHeavyAttack2Action->actID = actor.GetBodyAction(NULL, "HeavyAttack");
	ourHeavyAttack2Action->isAttack = true;
	ourHeavyAttack2Action->frames_num = 0;
	ourHeavyAttack2Action->play_speed = 1;
	ourHeavyAttack2Action->priority = ourAttack1Action->priority + 10;
	ourHeavyAttack2Action->type.value = Action_type::ACTION_ATTACK();
	ourHeavyAttack2Action->numOfKeyFrames = 2;
	ourHeavyAttack2Action->keyFrames = new OurFrame*[2];
	ourHeavyAttack2Action->keyFrames[0] = new OurFrame;
	ourHeavyAttack2Action->keyFrames[0]->frameNO = 31;
	ourHeavyAttack2Action->keyFrames[0]->start_angle = 0;
	ourHeavyAttack2Action->keyFrames[0]->plus_angle = 270;
	ourHeavyAttack2Action->keyFrames[0]->valid_dis = 190;
	ourHeavyAttack2Action->keyFrames[0]->damage_pt = 80;
	ourHeavyAttack2Action->keyFrames[1] = new OurFrame;
	ourHeavyAttack2Action->keyFrames[1]->frameNO = 41;
	ourHeavyAttack2Action->keyFrames[1]->start_angle = 270;
	ourHeavyAttack2Action->keyFrames[1]->plus_angle = 180;
	ourHeavyAttack2Action->keyFrames[1]->valid_dis = 200;
	ourHeavyAttack2Action->keyFrames[1]->damage_pt = 120;

	//DamageL
	ourDamageLAction = new OurAction();
	ourDamageLAction->actID = actor.GetBodyAction(NULL, "DamageL");
	ourDamageLAction->frames_num = 0;
	ourDamageLAction->play_speed = 1.5;
	ourDamageLAction->priority = 100;
	ourDamageLAction->type.value = DonzoAction::ACTION_DAMAGED();
	//fx
	ourDamageLAction->numOfFxFrames = 1;
	ourDamageLAction->fxFrames = new OurFxFrame*[1];
	ourDamageLAction->fxFrames[0] = new OurFxFrame;
	ourDamageLAction->fxFrames[0]->frameNO = 1;
	ourDamageLAction->fxFrames[0]->fxName = AllFx::SmallHurt01;

	//DamageH
	ourDamageHAction = new OurAction();
	ourDamageHAction->actID = actor.GetBodyAction(NULL, "DamageH");
	ourDamageHAction->frames_num = 0;
	ourDamageHAction->play_speed = 1.5;
	ourDamageHAction->priority = 100;
	ourDamageHAction->type.value = DonzoAction::ACTION_DAMAGED();
	//fx
	ourDamageHAction->numOfFxFrames = 1;
	ourDamageHAction->fxFrames = new OurFxFrame*[1];
	ourDamageHAction->fxFrames[0] = new OurFxFrame;
	ourDamageHAction->fxFrames[0]->frameNO = 1;
	ourDamageHAction->fxFrames[0]->fxName = AllFx::BigHurt01;

	//Die
	ourDieAction = new OurAction();
	ourDieAction->actID = actor.GetBodyAction(NULL, "Die");
	ourDieAction->frames_num = 0;
	ourDieAction->play_speed = 1;
	ourDieAction->priority = 1000;
	ourDieAction->type.value = DonzoAction::ACTION_DIE();
	//fx
	ourDieAction->numOfFxFrames = 1;
	ourDieAction->fxFrames = new OurFxFrame*[1];
	ourDieAction->fxFrames[0] = new OurFxFrame;
	ourDieAction->fxFrames[0]->frameNO = 1;
	ourDieAction->fxFrames[0]->fxName = AllFx::smoke;

	//blood
	{
		FnObject blood;
		float pos[3], size[2], color[3];
		blood_length = 50;
		blood_width = 2;

		bloodID = scene.CreateObject(ROOT);
		blood.Object(bloodID);
		
		pos[0] = 0.0f;
		pos[1] = 0.0f;
		pos[2] = 100.0f;
		size[0] = blood_length;
		size[1] = blood_width;
		color[0] = 1.0f; color[1] = 0.8; color[2] = 0.2f;

		blood.Billboard(pos, size, NULL, 0, color);
		blood.SetParent(actor.GetBaseObject());
	}
	this->blood.Object(bloodID,0);
}