コード例 #1
0
	std::shared_ptr<Scene> FBXConverter::LoadScene(FbxScene* fbxScene, FbxManager* fbxManager)
	{
		// convert a coordinate system
		FbxAxisSystem axis(FbxAxisSystem::eOpenGL);
		axis.ConvertScene(fbxScene);

		auto scene = std::make_shared<Scene>();

		// import nodes
		auto root = fbxScene->GetRootNode();
		scene->Root = LoadHierarchy(nullptr, root, fbxManager);

		// import animations
		auto animStackCount = fbxScene->GetSrcObjectCount<FbxAnimStack>();

		for (auto animStackIndex = 0; animStackIndex < animStackCount; animStackIndex++)
		{
			auto animStack = fbxScene->GetSrcObject<FbxAnimStack>(animStackIndex);

			fbxScene->SetCurrentAnimationStack(animStack);
			auto animClip = LoadAnimation(animStack, root);

			if(animClip.get() == nullptr) continue;
			scene->AnimationClips.push_back(animClip);
		}

		return scene;
	}
コード例 #2
0
	dAnimIKController* CreateHuman(DemoEntity* const model, const dMatrix& origin)
	{
		DemoEntityManager* const scene = (DemoEntityManager*) NewtonWorldGetUserData(GetWorld());

		DemoEntity* const character = (DemoEntity*)model->CreateClone();
		character->SetNameID("dommyRoot");
		character->ResetMatrix(*scene, character->GetCurrentMatrix() * origin);
		scene->Append(character);

		dAnimIKController* const controller = CreateSkeletonRig(character);

//		dAnimCharacterUserData* const userData = new dAnimCharacterUserData(controller);
//		character->SetUserData(userData);
		
		// populate base pose
		PopulateBasePose(controller->GetBasePose(), character);
		//dAnimTakeData* const walkCycle = LoadAnimation(controller, "whiteman_walk.ngd");
		dAnimTakeData* const walkCycle = LoadAnimation(controller, "whiteman_idle.ngd");

		dAnimIKBlendNodeTake* const walk = new dAnimIKBlendNodeTake(controller, walkCycle);
		//dAnimIKBlendNodePose* const walk = new dAnimIKBlendNodePose(controller);
		//dAnimIKBlendNodePose* const pose = new dAnimIKBlendNodePose(controller);
		dAnimIKBlendNodeRoot* const animTree = new dAnimIKBlendNodeRoot(controller, walk);
		//dAnimIKBlendNodeRoot* const animTree = new dAnimIKBlendNodeRoot(controller, pose);

		controller->SetAnimationTree(animTree);
		return controller;
	}
コード例 #3
0
			U1 Resource::ParseConfig(CAString&	strConfig){
	
	
				CoreMesh*	pCoreMesh	=	new	CoreMesh(m_strProductName);
				m_pObject				=	(UInt*)pCoreMesh;
	
				Data	pData;
				
				ResourceSystem::GetSingleton()->Find(m_strProductName + m_strSkeleton,pData);
				if(pData.IsNull())
					return	false;
	
				if(!pCoreMesh->loadCoreSkeleton(pData.buff)){
					SAF_D(pCoreMesh);
					return false;
				}

				ResourceSystem::GetSingleton()->Find(strConfig,pData);
				if(pData.IsNull())
					return	false;
	
				CSV csv;
				csv.Load(pData.buff,pData.size);
	
				for(U32 i=1;i<csv.GetLineCount();i++)
				{
					LoadAnimation(csv.GetItem(4,i).pStr);
				}	

				return true;
			}
コード例 #4
0
bool GCBanner::Load( const u8* GCBannAshData, u32 GCBannAshSize )
{
	if( loaded )
	{
		return true;
	}

	if( !GCBannAshData || !GCBannAshSize )
	{
		return false;
	}

	U8Archive arc( GCBannAshData, GCBannAshSize );
	if( !( lyt = LoadLayout( arc, "my_GCTop_a" ) ) )
	{
		return false;
	}

	if( !( lan = LoadAnimation( arc, "my_GCTop_a_BackLoop" ) ) )
	{
		return false;
	}

	obj->BindPane( lyt->FindPane( "RootPane" ) );
	obj->BindMaterials( lyt->Materials() );
	obj->AddAnimation( lan );
	obj->SetAnimation( "my_GCTop_a_BackLoop" );
	obj->Start();

	loaded = true;
	return true;
}
コード例 #5
0
ファイル: AnimationLoader.cpp プロジェクト: asmCode/ssg02
Animation* AnimationLoader::LoadAnimation(BinaryReader &br)
{
	Animation *anim = new Animation();

	bool hasOwnAnim = false;
	float angleScale;

	anim ->id = br.Read<int>();
	anim ->worldTMInv = LoadMatrix(br);
	anim ->pos = LoadVec3Anim(br, anim ->localPos);
	anim ->rot = LoadQuatAnim(br, anim ->localRot, hasOwnAnim, angleScale);
	anim ->scale = LoadVec3Anim(br, anim ->localScale);

	if (hasOwnAnim)
	{
		anim->hasOwnRotate = hasOwnAnim;
		anim->angleScale = angleScale;
	}

	int subAnimsCount = br.Read<int>();
	for (int i = 0; i < subAnimsCount; i++)
		anim ->subAnims.push_back(LoadAnimation(br));

	return anim;
}
コード例 #6
0
ファイル: AnimationSet2D.cpp プロジェクト: aster2013/Urho3D
bool AnimationSet2D::EndLoad()
{
    // Actually load the folders and animations now
    if (!loadXMLFile_)
        return false;

    XMLElement rootElem = loadXMLFile_->GetRoot("spriter_data");
    if (!LoadFolders(rootElem))
    {
        loadXMLFile_.Reset();
        return false;
    }

    XMLElement entityElem = rootElem.GetChild("entity");
    if (!entityElem)
    {
        LOGERROR("Could not find entity");
        loadXMLFile_.Reset();
        return false;
    }
    
    for (XMLElement animationElem = entityElem.GetChild("animation"); animationElem; animationElem = animationElem.GetNext("animation"))
    {
        if (!LoadAnimation(animationElem))
        {
            loadXMLFile_.Reset();
            return false;
        }
    }

    loadXMLFile_.Reset();
    return true;
}
コード例 #7
0
ファイル: FlashMenuScreen.cpp プロジェクト: RenEvo/dead6
bool CFlashMenuScreen::Load(const char *strFile)
{
    if (LoadAnimation(strFile))
    {
        IRenderer *pRenderer = gEnv->pRenderer;
        UpdateRatio();
        //m_pFlashPlayer->SetViewport(0,0,pRenderer->GetWidth(),pRenderer->GetHeight());
        GetFlashPlayer()->SetBackgroundAlpha(0.0f);
        return true;
    }

    return false;
}
コード例 #8
0
ファイル: Flash.cpp プロジェクト: FrozenCow/Monocle-Engine
	void TestScene::Begin()
	{
		Scene::Begin();

		Graphics::SetBackgroundColor(Color::black);

		editPart = NULL;
		selectedPartIndex = 0;
		isRecording = false;
		isPlaying = false;
		currentAnimation = NULL;
		isEditing = false;
		
#ifdef ANIM_MONOCLE_LOGO
		LoadAnimation("../../Content/Flash/animations.xml");
		LoadTextureSheet("../../Content/Flash/sheets.xml");
#else
		LoadAnimation("../../Content/Flash/test.xml");
#endif

		eAnimation = new Entity();
		eAnimation->position = Vector2(400,300);
		Add(eAnimation);

		InitAnimation(&animations[0], eAnimation);
		Play(&animations[0], 15.0f);

		// fudging:
		eAnimation->position.x += 40;
		eAnimation->scale = Vector2(800.0f/640.0f, 600.0f/480.0f);

		//editor
		//Pause();
		isEditing = true;
		isRecording = true;
		Debug::showBounds = true;
	}
コード例 #9
0
ファイル: AnimationLoader.cpp プロジェクト: asmCode/ssg02
Animation* AnimationLoader::LoadFromFile(const std::string &path)
{
	uint8_t *data;
	uint32_t size;

	if (!Path::GetFileContent(path.c_str(), data, size))
		return NULL;

	BinaryReader br(data);

	Animation *anim = new Animation();

	int subAnimsCount = br.Read<int>();
	for (int i = 0; i < subAnimsCount; i++)
		anim ->subAnims.push_back(LoadAnimation(br));

	delete [] data;

	return anim;
}
コード例 #10
0
ファイル: md32spr.cpp プロジェクト: crystalspace/CS
bool MD32spr::ReadVfsDir()
{
  char *str;
  size_t i = 0;

  for (i = 0; i < fileNames->GetSize (); i++) 
  {
    str = (char*)fileNames->Get(i);

    if (str) {
      if (player) {

	if (stristr(str, "head") && stristr(str, ".skin"))
	  if (!headModel->LoadSkin(str)) {
	    ReportError("Fatal Error: Reading skin File of head.");
	    return false;
	  }

	if (stristr(str, "upper") && stristr(str, ".skin"))
	  if (!upperModel->LoadSkin(str)) {
	    ReportError("Fatal Error: Reading skin File of Upper Body.");
	    return false;
	  }

	if (stristr(str, "lower") && stristr(str, ".skin"))
	  if (!lowerModel->LoadSkin(str)) {
	    ReportError("Fatal Error: Reading skin File of Lower Body.");
	    return false;
	  }

	if (stristr(str, ".cfg"))
	  if (!LoadAnimation(str)) {
	    ReportError("Fatal Error: Reading animation file.");
	    return false;
	  }
      }
    }
  }
  return true;
}
コード例 #11
0
void ScreenRecoveryUI::Init() {
    gr_init();

    density_ = static_cast<float>(property_get_int32("ro.sf.lcd_density", 160)) / 160.f;
    is_large_ = gr_fb_height() > PixelsFromDp(800);

    gr_font_size(&char_width_, &char_height_);
    text_rows_ = gr_fb_height() / char_height_;
    text_cols_ = gr_fb_width() / char_width_;

    text_ = Alloc2d(text_rows_, text_cols_ + 1);
    file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1);
    menu_ = Alloc2d(text_rows_, text_cols_ + 1);

    text_col_ = text_row_ = 0;
    text_top_ = 1;

    LoadBitmap("icon_error", &error_icon);

    LoadBitmap("progress_empty", &progressBarEmpty);
    LoadBitmap("progress_fill", &progressBarFill);

    LoadBitmap("stage_empty", &stageMarkerEmpty);
    LoadBitmap("stage_fill", &stageMarkerFill);

    // Background text for "installing_update" could be "installing update"
    // or "installing security update". It will be set after UI init according
    // to commands in BCB.
    installing_text = nullptr;
    LoadLocalizedBitmap("erasing_text", &erasing_text);
    LoadLocalizedBitmap("no_command_text", &no_command_text);
    LoadLocalizedBitmap("error_text", &error_text);

    LoadAnimation();

    pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);

    RecoveryUI::Init();
}
コード例 #12
0
bool ToolTip::Load( const u8* balloonAshData, u32 balloonAshSize )
{
	DELETE( obj );
	DELETE( layout );
	DELETE( brlan );
	tbox = NULL;
	loaded = false;
	if( !balloonAshData || !balloonAshSize )
	{
		return false;
	}

	U8Archive arc( balloonAshData, balloonAshSize );
	if( !( layout = LoadLayout( arc, "my_IplTopBalloon_a" ) ) )
	{
		return false;
	}
	if( !(tbox = layout->FindTextbox( "T_Balloon" ) ) )
	{
		return false;
	}
	if( !(brlan = LoadAnimation( arc, "my_IplTopBalloon_a_balloonInOut" ) ) )
	{
		return false;
	}
	//tbox->SetText( NULL );

	obj = new Object;
	obj->AddAnimation( brlan );
	obj->BindPane( layout->FindPane( "RootPane" ));
	obj->SetAnimation( "my_IplTopBalloon_a_balloonInOut", 0, -1, -1, true, true );
	obj->Start();

	loaded = true;
	return true;
}
コード例 #13
0
ファイル: TSRModel_Load.cpp プロジェクト: ShadyEM/Twister3D
void TSRModel::LoadModel( TSRModel* pModel, const char* _pFileName )
{
    /// new : if this is a .obj file, we create a dummy model  around its mesh
    string strFilename = _pFileName;

    string strExtension = strFilename.substr( strlen( _pFileName ) - 3, strlen( _pFileName ) );

    if ( strExtension == "obj" )
    {
        LoadFromOBJ( pModel, _pFileName );
        return;
    }

	TSRFileStream* fptr = TSRFileSystem::OpenFileStream( _pFileName, "rb" );

	// first read the version
	unsigned int uiVersion = 0;

	fread( &uiVersion, sizeof( unsigned int ), 1, fptr );

	// read geometries
	fread( &pModel->m_uiGeometriesCount, sizeof( unsigned int ), 1, fptr );
	if ( pModel->m_uiGeometriesCount > 0 )
	{
		pModel->m_pGeometries = new TSRModelGeometry[ pModel->m_uiGeometriesCount ];
	}
	for ( unsigned int i = 0; i < pModel->m_uiGeometriesCount; i++ )
	{
		LoadGeometry( pModel->m_pGeometries + i, fptr );
	}

	/// read skinned geometries
	fread( &pModel->m_uiSkinnedGeometriesCount, sizeof( unsigned int ), 1, fptr );
	if ( pModel->m_uiSkinnedGeometriesCount )
	{
		pModel->m_pSkinnedGeometries = new TSRModelSkinnedGeometry[ pModel->m_uiSkinnedGeometriesCount ];
	}
	for ( unsigned int i = 0; i < pModel->m_uiSkinnedGeometriesCount; i++ )
	{
		LoadSkinnedGeometry( pModel->m_pSkinnedGeometries + i, fptr );
	}


	/// read effects 
	fread( &pModel->m_uiEffectsCount, sizeof( unsigned int ), 1, fptr );

	if ( pModel->m_uiEffectsCount > 0 )
	{
		pModel->m_ppEffects = new TSREffect* [ pModel->m_uiEffectsCount ];
		for ( unsigned int i = 0; i < pModel->m_uiEffectsCount; i++ )
		{
			char effectName[ 16 ];
			fread( effectName, 16, 1, fptr );
			pModel->m_ppEffects[ i ] = EffectManager()->Aquire( effectName );
		}
	}

	/// read textures
	fread( &pModel->m_uiTexturesCount, sizeof( unsigned int ), 1, fptr );
	pModel->m_uiTexturesCount += 2;
	pModel->m_pModelTextures = new TSRModelTexture[ pModel->m_uiTexturesCount ];
	pModel->m_ppTextures = new TSRTexture*[ pModel->m_uiTexturesCount ];


	if ( pModel->m_uiTexturesCount > 2 )
	{
		fread( &pModel->m_pModelTextures[ 2 ], sizeof( TSRModelTexture ), pModel->m_uiTexturesCount - 2, fptr );
	}


	/// read materials
	fread( &pModel->m_uiMaterialsCount, sizeof( unsigned int ), 1, fptr );
	
	// always add one default material 
	pModel->m_pMaterials = new TSRModelMaterial[ pModel->m_uiMaterialsCount ];
	if ( pModel->m_uiMaterialsCount > 0 )
	{
		fread( pModel->m_pMaterials, sizeof( TSRModelMaterial ), pModel->m_uiMaterialsCount, fptr );
	}

	snprintf( pModel->m_RootNode.m_Name, 32, "RootNode" );

	// read the root node transform
	fread( &pModel->m_RootNode.m_LocalTransform, sizeof( TSRMatrix4 ), 1, fptr );

	// read number of nodes under root
	fread( &pModel->m_RootNode.m_uiChildrenCount, sizeof( unsigned int ), 1, fptr );

	// allocate them
	pModel->m_RootNode.m_pChildren = new TSRModelNode[ pModel->m_RootNode.m_uiChildrenCount ];
	for ( unsigned int i = 0; i < pModel->m_RootNode.m_uiChildrenCount; i++ )
	{
		ReadModelNodesRec( pModel->m_RootNode.m_pChildren + i, fptr );
	}

	// read the whole model aabb..
	fread( &pModel->m_BoundBox, sizeof( TSRBBox ), 1, fptr );

	// read number of render nodes.
	fread( &pModel->m_uiRenderNodesCount, sizeof( unsigned int ), 1, fptr );

	if ( pModel->m_uiRenderNodesCount > 0 )
	{
		pModel->m_pRenderNodes = new TSRModelRenderNode[ pModel->m_uiRenderNodesCount ];
	}

	for ( unsigned int i = 0; i < pModel->m_uiRenderNodesCount; i++ )
	{
		// allocate a new render node
		TSRModelRenderNode*  pNewRenderNode = pModel->m_pRenderNodes + i ;

		// read it without the trailing pointer (world transform and the number of geometry instances)
		fread( pNewRenderNode, sizeof( TSRMatrix4 ) + sizeof( int ), 1, fptr );

		// allocate  geometry indices
		pNewRenderNode->m_pGeometriesIndices = new int[ pNewRenderNode->m_uiGeometriesCount ];

		// read them
		fread( pNewRenderNode->m_pGeometriesIndices, pNewRenderNode->m_uiGeometriesCount * sizeof( int ), 1, fptr );
	}

	/// read skinned nodes
	fread( &pModel->m_uiSkinnedNodesCount, sizeof( unsigned int ), 1, fptr );

	if ( pModel->m_uiSkinnedNodesCount >  0 )
	{
		pModel->m_pSkinnedNodes = new TSRModelRenderNode[ pModel->m_uiSkinnedNodesCount ];
	}

	for ( unsigned int i = 0; i < pModel->m_uiSkinnedNodesCount; i++ )
	{
		// allocate a new skinned node
		TSRModelRenderNode*  pNewSkinnedNode = pModel->m_pSkinnedNodes + i ;

		// read it without the trailing pointer (world transform and the number of geometry instances)
		fread( pNewSkinnedNode, sizeof( TSRMatrix4 ) + sizeof( int ), 1, fptr );

		// allocate  geometry indices
		pNewSkinnedNode->m_pGeometriesIndices = new int[ pNewSkinnedNode->m_uiGeometriesCount ];

		// read them
		fread( pNewSkinnedNode->m_pGeometriesIndices, pNewSkinnedNode->m_uiGeometriesCount * sizeof( int ), 1, fptr );
	}

	// read the animations
	fread( &pModel->m_AnimationsCount, sizeof( unsigned int ), 1, fptr );

	// allocate the animations
	if ( pModel->m_AnimationsCount > 0 )
	{
		pModel->m_pAnimations = new TSRModelAnimation[ pModel->m_AnimationsCount ];

		for ( unsigned int i = 0; i < pModel->m_AnimationsCount; i++ )
		{
			LoadAnimation( pModel->m_pAnimations + i, fptr );
		}
	}

	// read lights 
	fread( &pModel->m_uiLightsCount, sizeof( unsigned int ), 1, fptr );

	// allocate lights and read them in one go..
	if ( pModel->m_uiLightsCount > 0 )
	{
		pModel->m_pLights = new TSRModelLight[ pModel->m_uiLightsCount ];
		fread( pModel->m_pLights, sizeof( TSRModelLight ), pModel->m_uiLightsCount, fptr );
	}

	/// read number of light nodes
	fread( &pModel->m_uiLightNodesCount, sizeof( unsigned int ), 1, fptr );

	if ( pModel->m_uiLightNodesCount > 0 )
	{
		pModel->m_pLightNodesIndices = new unsigned int[ pModel->m_uiLightNodesCount ];
		fread( pModel->m_pLightNodesIndices, sizeof( unsigned int ), pModel->m_uiLightNodesCount, fptr );
	}
	/// read number of bones and create the skeleton matrix data 
	fread( &pModel->m_uiBonesCount, sizeof( unsigned int ), 1, fptr );

	fclose( fptr );


    /// white and default normal are always first 2 textures..
    pModel->m_ppTextures[ 0 ] = TextureManager()->GetWhite();
    pModel->m_ppTextures[ 1 ] = TextureManager()->GetDefaultNormal();

    // change the current working directory according to the file's path, so textures can be read properly
    string fullPath = _pFileName;
    int iSlashPosition = ( int ) fullPath.find_last_of( "/" );
    string textureFileNameHeader = "";

	if ( iSlashPosition == -1 )
	{
		iSlashPosition = ( int ) fullPath.find_last_of( "\\" );
	}

    if ( iSlashPosition > -1 )
    {
        textureFileNameHeader = fullPath.substr( 0, iSlashPosition + 1 );
    }

    string textureFileName;

    // change directory if needed before getting the textures..
    for ( unsigned int i = 2; i < pModel->m_uiTexturesCount; i++ )
    {
        textureFileName = textureFileNameHeader + pModel->m_pModelTextures[ i ].m_Name;
        pModel->m_ppTextures[ i ] = TextureManager()->Aquire( textureFileName.c_str() );
    }
}
コード例 #14
0
ファイル: loadgame.cpp プロジェクト: mdtrooper/game-lv
int readScenes(string filePrefix) {
	dout << " loadScenes" << endl;	
	
	string fileName = filePrefix + "scenes.dat";
	FILE *fin = fopen(fileName.c_str(), "rb");
	if(!fin) {
		dout << "ERROR- loadScenes: Could not open " << fileName << " for reading." << endl;
		return 1;
	}

	int currentSceneId = readInt(fin);
	int totalScenes = readInt(fin);

	dout << "  total scenes: " << totalScenes << endl;
	for(int a = 0; a < totalScenes; a++) {
		Scene *s = new Scene;
		s->id = readInt(fin);
		dout << "   scene: " << s->id << endl;
		s->gfxFile = readString(fin);
		s->maskFile = readString(fin);
		s->soundFile = readString(fin);

		int hotspotsTotal = readInt(fin);		
		int hotspotId;
		for(int b = 0; b < hotspotsTotal; b++) {
			hotspotId = readInt(fin);
			dout << "    hotspot: " << hotspotId << endl;
			HMI i = all_hotspots.find(hotspotId);
			if(i == all_hotspots.end()) {
				dout << "ERROR- Could not find hotspot" << endl;
				exit(1);
			}
			Hotspot *h = i->second;
			s->hotspots.insert(make_pair<int, Hotspot*>(hotspotId, h));

			if(s->id == currentSceneId) {
				loadHotspotAnimData(h);
			}
		}

		s->walkMask = new WalkMask;
		if(s->walkMask->readWalkMask(fin)) {
			dout << "ERROR- could not load walkmask" << endl;
			return 1;
		}

		ResortHotspots(s);

		all_scenes.insert(make_pair<int, Scene*>(s->id, s));
		if(s->id == currentSceneId) {
			current_scene = s;
		}
	}

	if(!current_scene) {
		dout << "ERRRO- no current scene" << endl;
		return 1;
	}

	current_scene->gfx = LoadAnimation(current_scene->gfxFile, true, false);
	if(!current_scene->gfx) {
		dout << "ERROR- Could not load gfx for scene: " << current_scene->id << endl;
		exit(1);
	}
	readAnimationState(fin, current_scene->gfx);

	current_scene->w = current_scene->walkMask->getWidth();
	current_scene->h = current_scene->walkMask->getHeight();

	current_scene->sound = loadSoundCollection(current_scene->soundFile, SOUND_TYPE_SCENE);
	if(current_scene->sound) {
		loadSoundCollectionState(fin, current_scene->sound);
		soundPlayer.loadSceneSoundState(fin, current_scene->sound);
	}
	fclose(fin);
	dout << " End loadScenes" << endl;
	
	return 0;
}
コード例 #15
0
ファイル: FbxLoader.cpp プロジェクト: nian0601/DirectXEngine
void LoadAnimation(AnimationData& aAnimation,FbxNode* aNode,FbxAMatrix& aParentOrientation, FbxPose* aPose, FbxAnimLayer* aCurrentAnimLayer, int parentBone)
{
	FbxAMatrix lGlobalPosition = GetGlobalPosition(aNode, static_cast<FbxTime>(0.0f), aPose, &aParentOrientation);
	FbxNodeAttribute* lNodeAttribute = aNode->GetNodeAttribute();
	int boneId = -1;
	if (lNodeAttribute)
	{
		if(lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eSkeleton)
		{
			Bone newBone;
			newBone.myAnimationTime = GetAnimationTime(aNode,aCurrentAnimLayer);
			float oneFrameTime = 1.0f/24.0f;
				
			CU::Matrix44f fixMatrix;
			fixMatrix.myMatrix[0] = -1;
			FbxAMatrix lLocalTransform = aNode->EvaluateLocalTransform();
			newBone.myBaseOrientation = fixMatrix * CreateMatrix(lLocalTransform) * fixMatrix;

			char buffer[32];
			_itoa_s<32>(parentBone,buffer,10);
			newBone.myName = aNode->GetName();	
			newBone.myName += buffer;

			int lNodeIndex = aPose->Find(aNode);
			auto bindPoseMatrix = aPose->GetMatrix(lNodeIndex);

			FbxAMatrix bindMatrix;
			memcpy((double*)bindMatrix, (double*)bindPoseMatrix, sizeof(bindMatrix.mData));

			FbxAMatrix localPosOffset;
				
			memcpy((double*)localPosOffset, (double*)bindPoseMatrix, sizeof(localPosOffset.mData));
			localPosOffset =  localPosOffset * aParentOrientation.Inverse();

			newBone.myBindMatrix = fixMatrix * CreateMatrix(lGlobalPosition.Inverse()) * fixMatrix;

			CU::Matrix44f localStartOffset = CreateMatrix(bindMatrix.Inverse());
			for(float currentFrameTime = 0.0f;currentFrameTime < newBone.myAnimationTime;currentFrameTime+= oneFrameTime)
			{
				KeyFrame keyFrame;
				keyFrame.myTime = currentFrameTime;

				FbxTime time;
				time.SetSecondDouble(currentFrameTime);
				keyFrame.myMatrix = fixMatrix * CreateMatrix(aNode->EvaluateLocalTransform(time)) * fixMatrix;
				newBone.myFrames.push_back(keyFrame);
			}
			FbxAMatrix animationMatrix;

			FbxSkeleton* sekeleton = aNode->GetSkeleton();
			if(sekeleton->IsSkeletonRoot())
			{
				aAnimation.myBindMatrix = CU::Matrix44<float>();
				aAnimation.myRootBone = aAnimation.myBones.size();
			}
			boneId = aAnimation.myBones.size();
			aNode->SetUserDataPtr((void*)boneId);

			if(parentBone != -1)
			{
				aAnimation.myBones[parentBone].myChilds.push_back(boneId);
			}
			newBone.myId = boneId;
			aAnimation.myBones.push_back(newBone);
		}
	}

	const int lChildCount = aNode->GetChildCount();
	for (int lChildIndex = 0; lChildIndex < lChildCount; ++lChildIndex)
	{
		LoadAnimation( aAnimation, aNode->GetChild(lChildIndex), lGlobalPosition , aPose, aCurrentAnimLayer, boneId);
	}
}
コード例 #16
0
ファイル: FbxLoader.cpp プロジェクト: nian0601/DirectXEngine
FbxModelData* FBXLoader::loadModel( const char* aFile )
{
	FBX_LOG("FBXLoader Creating ModelData...");
	myLoadingModel = new FbxModelData;
	FBX_LOG("Success!");
	FBX_LOG("FBXLoader Creating TextureData...");
	myLoadingModel->myTextureData = new TextureData();
	FBX_LOG("Success!");
	FBX_LOG("FBXLoader Loading Scene...");
	auto scene = LoadScene(aFile);
	FBX_LOG("Successfully loaded scene!");

	FBX_LOG("FBXLoader Loading Textures...");
	//TextureData
	const int lTextureCount = scene->GetTextureCount();
	for (int lTextureIndex = 0; lTextureIndex < lTextureCount; ++lTextureIndex)
	{
		FbxTexture * lTexture = scene->GetTexture(lTextureIndex);
		FbxFileTexture * lFileTexture = reinterpret_cast<FbxFileTexture*>(lTexture);
		if (lFileTexture && !lFileTexture->GetUserDataPtr())
		{
			const FbxString lFileName = lFileTexture->GetFileName();
			
			unsigned int lTextureObject = 0;
			lTextureObject;
			bool lStatus = false;
			lStatus;
			
			const FbxString lAbsFbxFileName = FbxPathUtils::Resolve(aFile);
			const FbxString lAbsFolderName = FbxPathUtils::GetFolderName(lAbsFbxFileName);
			
			const FbxString lTextureFileName = lAbsFolderName + "\\" + lFileTexture->GetRelativeFileName();// FbxPathUtils::GetFileName(lFileName);
				
			const FbxString lResolvedFileName = lAbsFolderName + "\\" + FbxPathUtils::GetFileName(lFileName);// lFileTexture->GetRelativeFileName();;// FbxPathUtils::Bind(lAbsFolderName, lTextureFileName);
			TextureInfo info;
			info.myFileName = lResolvedFileName;
			//info.myFileName += "\\";
			info.myFileName = lFileTexture->GetRelativeFileName();
			myLoadingModel->myTextureData->myTextures.push_back(info);
			lFileTexture->SetFileName(lResolvedFileName);
		}
	}
	FBX_LOG("Success!");
	FBX_LOG("FBXLoader Loading Animations...");

	FbxArray<FbxString*> animationNames;
	FbxArray<FbxPose*> poses;
	scene->FillAnimStackNameArray(animationNames);
	scene->FillPoseArray(poses);
	FbxAnimStack * lCurrentAnimationStack = nullptr;
	FbxAnimLayer* lCurrentAnimLayer = nullptr;
	if(animationNames.GetCount() > 0)
	{
		lCurrentAnimationStack = scene->FindMember<FbxAnimStack>(animationNames[0]->Buffer());
		if (lCurrentAnimationStack != NULL)
		{
			lCurrentAnimLayer = lCurrentAnimationStack->GetMember<FbxAnimLayer>();
		}
	}
	//lCurrentAnimLayer->IsR
	myLoadingModel->myAnimation = new AnimationData();
	FbxPose* pose = nullptr;
	if(poses.GetCount() > 0)
	{
		pose = poses[0];
	}

	LoadAnimation(*myLoadingModel->myAnimation,scene->GetRootNode(),FbxAMatrix(),pose, lCurrentAnimLayer,-1);
	LoadNodeRecursive(myLoadingModel, *myLoadingModel->myAnimation, scene->GetRootNode(), FbxAMatrix(), pose, lCurrentAnimLayer, -1);
	FBX_LOG("Success!");
		
	return myLoadingModel;
}
コード例 #17
0
ファイル: FileLoader.cpp プロジェクト: jjuiddong/Dx3D-Study
//-----------------------------------------------------------------------------//
// animation script를 binaryfile로 만든다. (확장자 .a)
// szSrcFileName : ani script file name
// szDstFileName : 생성될 filename
//-----------------------------------------------------------------------------//
BOOL CFileLoader::WriteScripttoBinary_Ani( char *szSrcFileName, char *szDstFileName )
{
	SAniLoader *pLoader = LoadAnimation( szSrcFileName );
	BOOL bResult = WriteScripttoBinary_Ani( pLoader, szDstFileName );
	return bResult;
}
コード例 #18
0
void OneObject::MakeMeFly(word MagID){
	if(MagID==0xFFFF||Media==2)return;
	if(!Ref.General->CanFly)return;
	MagSrcID=MagID;
	int cx=x>>2;
	int cy=y>>2;
	ClearOrders();
	if(InLineCom)FreeAsmLink();
	FlyCell* FC=&FlyMap[cy][cx];
	if(FC->NFly>=15)return;
	//Deleting from the terra
	if(LLock[y][x])DecLock(x,y);
	LLock[y][x]=0;
	Mops[y][x]=0xFFFF;
	int Rex=(x<<9)+256;
	int Rey=(y<<9)+256;
	for(int k=0;FC->FlyList[k]!=0xFFFF;k++);
	FC->NFly++;
	FC->FlyList[k]=Index;
	//Cell8x8* CELL=&TCInf[NNUM][y>>2][x>>2];
	//OneObject* G=Group[i];
	//GeneralObject* GO=Mon[n];
	//CELL->UnitsAmount[GO->Kind]++;
	//G->DefaultSettings(GO);
	//G->Teleport=false;
	//G->capTeleport=GO->Teleport;
	RealX=Rex;
	RealY=Rey;
	DestX=Rex;
	DestY=Rey;
	RealVx=0;
	RealVy=-128;
	RealDir=((Direction<<5)+16)&255;
	Media=2;
	OnWater=false;
	Ready=true;
	delay=0;
	NearBase=0xFFFF;
	memset(&(ARegs),0,sizeof ARegs);
	LoadAnimation(0,0,0);
	LoadCurAnm(0);
	LocalOrder=NULL;
	PrioryLevel=0;
	InLineCom=NULL;
	LineOffset=0;
	Ticks=0;
	Addx=0;
	Addy=0;
	Npush=0;
	StandTime=100;
	Sdoxlo=false;
	EnemyDist=5000;
	Attack=false;
	EnemyID=0xFFFF;
	Egoist=false;
	Height=0;
	LoadAnimation(0,0,0);//stand=motion animation
	LoadAnimation(1,2,0);//attack
	LoadAnimation(2,3,0);//death
	BestDist=32*16*6;
	FlyAttackMode=false;
};