void SampleUtil_Init() { std::string dir; CPUTFileSystem::GetExecutableDirectory(&dir); CPUTFileSystem::StripDirectoriesFromPath(&dir, 4); CPUTFileSystem::CombinePath(dir, "Media\\MyAssets", &gUtilGlob.myAssetsDirectory); CPUTFileSystem::CombinePath(dir, "userdata", &gUtilGlob.userDataDirectory); CPUTAssetLibrary *pAssetLibrary = CPUTAssetLibrary::GetAssetLibrary(); for (int i = 0; i < CODE_TEXTURE_COUNT; i++) { char textureName[64]; snprintf(textureName, sizeof(textureName), "$CODETEXTURE%d", i); std::string textureNameString = std::string(textureName); gUtilGlob.codeTextures[i] = (CPUTTextureDX11*)CPUTTextureDX11::Create(textureNameString, NULL, NULL); pAssetLibrary->AddTexture(textureName, "", "", gUtilGlob.codeTextures[i]); } gUtilGlob.codeMaterial = pAssetLibrary->GetMaterial("MyAssets/codesprite"); pAssetLibrary->SetMediaDirectoryName(GetMyAssetsDirectory() + "\\"); gUtilGlob.meshPreviewMaterial = pAssetLibrary->GetMaterial("meshpreview"); // Load cube and sphere pAssetLibrary->SetRootRelativeMediaDirectory(""); std::string filename; CPUTFileSystem::GetMediaDirectory(&filename); CPUTFileSystem::CombinePath(filename, "common.scene", &filename); gUtilGlob.boxScene = CPUTScene::Create(); gUtilGlob.boxScene->LoadScene(filename.c_str()); gUtilGlob.boxModel = pAssetLibrary->FindModel("pCube1", true); pAssetLibrary->SetMediaDirectoryName(GetMyAssetsDirectory() + "\\"); CPUTMaterial *quadSpriteMat = pAssetLibrary->GetMaterial("debugQuad"); gUtilGlob.QuadSprite = CPUTSprite::Create(0.0f, 0.0f, 1.0f, 1.0f, quadSpriteMat); SAFE_RELEASE(quadSpriteMat); }
void Menu_FaceMapping::Init() { MenuBase::Init(); SetDefaultTweaks(&mTweaks); CPUTAssetLibrary *pAssetLibrary = CPUTAssetLibrary::GetAssetLibrary(); mpFaceMapRTColor = CPUTRenderTargetColor::Create(); mpFaceMapRTColor->CreateRenderTarget("$FaceColor", FACE_DISPLACEMENT_WIDTH_HEIGHT, FACE_DISPLACEMENT_WIDTH_HEIGHT, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); mpFaceMapRTDepth = CPUTRenderTargetColor::Create(); mpFaceMapRTDepth->CreateRenderTarget("$FaceDisplacement", FACE_DISPLACEMENT_WIDTH_HEIGHT, FACE_DISPLACEMENT_WIDTH_HEIGHT, DXGI_FORMAT_R32_FLOAT); mpFaceMapDepthBuffer = CPUTRenderTargetDepth::Create(); mpFaceMapDepthBuffer->CreateRenderTarget("$FaceDisplacementDepth", FACE_DISPLACEMENT_WIDTH_HEIGHT, FACE_DISPLACEMENT_WIDTH_HEIGHT, DXGI_FORMAT_D32_FLOAT); mDisplacementCamera = CPUTCamera::Create(CPUT_ORTHOGRAPHIC); mDisplacementCamera->SetPosition(0.0f, 0.0f, -10.0f); mDisplacementCamera->LookAt( 0.0f, 0.0f, 0.0f ); mDisplacementCamera->SetFarPlaneDistance(20); mDisplacementCamera->SetNearPlaneDistance(1.0f); mDisplacementCamera->SetAspectRatio(1.0f); mDisplacementCamera->SetWidth(10); mDisplacementCamera->SetHeight(10); mDisplacementCamera->Update(); pAssetLibrary->SetRootRelativeMediaDirectory("MyAssets"); CPUTMaterial* mat = pAssetLibrary->GetMaterial("render_map_diffuse"); mMapSprites[FaceMapTexture_Color] = CPUTSprite::Create(-1.0f, -1.0f, 0.5f, 0.5f, mat); SAFE_RELEASE(mat); mat = pAssetLibrary->GetMaterial("render_map_depth"); mMapSprites[FaceMapTexture_Depth] = CPUTSprite::Create(-1.0f, -0.4f, 0.5f, 0.5f, mat); SAFE_RELEASE(mat); // load the head model std::string mediaFilename; CPUTFileSystem::GetMediaDirectory(&mediaFilename); pAssetLibrary->SetMediaDirectoryName(mediaFilename+"\\"); CPUTFileSystem::CombinePath(mediaFilename, "basicHead_03.scene", &mediaFilename); mScene = CPUTScene::Create(); mScene->LoadScene(mediaFilename); mHeadModel = pAssetLibrary->FindModel("head4", true); CPUTAssetSet *hairSetMale = pAssetLibrary->FindAssetByNameNoPath("hairMale_01.set", CPUTAssetLibrary::mpAssetSetList); CPUTAssetSet *hairSetMale_Black = pAssetLibrary->FindAssetByNameNoPath("hairMale_01_black.set", CPUTAssetLibrary::mpAssetSetList); CPUTAssetSet *hairSetFemale = pAssetLibrary->FindAssetByNameNoPath("hairGeekGirl.set", CPUTAssetLibrary::mpAssetSetList); CPUTAssetSet *hairSetFemale_Blonde = pAssetLibrary->FindAssetByNameNoPath("hairGeekGirl_blonde.set", CPUTAssetLibrary::mpAssetSetList); CPUTAssetSet *hairSetFemale_Black = pAssetLibrary->FindAssetByNameNoPath("hairGeekGirl_black.set", CPUTAssetLibrary::mpAssetSetList); CPUTAssetSet *hairSetCrazy = pAssetLibrary->FindAssetByNameNoPath("hair_01.set", CPUTAssetLibrary::mpAssetSetList); HairInfo info; info.name = "Hair Short"; info.set = hairSetMale; mHairList.push_back(info); info.name = "Hair Short Black"; info.set = hairSetMale_Black; mHairList.push_back(info); info.name = "Hair Long"; info.set = hairSetFemale; mHairList.push_back(info); info.name = "Hair Long Blonde"; info.set = hairSetFemale_Blonde; mHairList.push_back(info); info.name = "Hair Long Black"; info.set = hairSetFemale_Black; mHairList.push_back(info); info.name = "Madness"; info.set = hairSetCrazy; mHairList.push_back(info); GetCPUTLandmark( std::string( "LANDMARK_EYE_LEFT_CENTER" ), &mHeadLandmark_LeftEyeCenter); GetCPUTLandmark( std::string( "LANDMARK_EYE_RIGHT_CENTER" ), &mHeadLandmark_RightEyeCenter); GetCPUTLandmark(std::string("LANDMARK_NOSE_TIP"), &mHeadLandmark_NoseTip); mCameraController = new CPUTCameraModelViewer(); mCameraController->SetTarget(float3(0, 0, 0)); mCameraController->SetDistance( 20, 10, 40); mCameraController->SetViewAngles(0, 0); mMapProjectionCamera = CPUTCamera::Create(CPUT_ORTHOGRAPHIC); float y = 5.0f; mMapProjectionCamera->SetPosition(0.0f, y, -10.0f ); mMapProjectionCamera->LookAt(0.0f, y, 0.0f); mMapProjectionCamera->SetFarPlaneDistance(100); mMapProjectionCamera->SetNearPlaneDistance(0.1f); mMapProjectionCamera->SetAspectRatio(1.0f); mMapProjectionCamera->SetWidth(15); mMapProjectionCamera->SetHeight(15); mMapProjectionCamera->Update(); mSaveSculptedObj = false; }