コード例 #1
0
ファイル: Test.cpp プロジェクト: vilonosec/dava.framework
void Test::LoadResources()
{
	time = 0.f;
	isFinished = false;
	skipFrames = 100;

	Scene *scene = new Scene();
	scene->AddNode(scene->GetRootNode(fullName));
	DVASSERT_MSG(scene, "Could not load the scene");

	Camera* cam = new Camera();
	scene->AddCamera(cam);

	Core* core = DAVA::Core::Instance();
	float32 aspect = core->GetVirtualScreenHeight() / core->GetVirtualScreenWidth();

	cam->Setup(70.f, aspect, 1.f, 5000.f);
	cam->SetLeft(Vector3(1, 0, 0));
	cam->SetUp(Vector3(0, 0, 1));
    
    scene->SetCurrentCamera(cam);
	SafeRelease(cam);

	UI3DView *sceneView = new UI3DView(Rect(0, 0, GetSize().x, GetSize().y));
	sceneView->SetScene(scene);
	AddControl(sceneView);
	SafeRelease(sceneView);

	Landscape* landscape = GetLandscape();
	DVASSERT_MSG(scene, "There is no landscape in a scene");
	landscape->SetTiledShaderMode(Landscape::TILED_MODE_TEXTURE);

	uint32 textureMemory = TextureHelper::GetSceneTextureMemory(scene, GetFilePath());
	testData.SetTextureMemorySize(textureMemory);

	File* file = File::Create(fullName, File::OPEN | File::READ);
	DVASSERT_MSG(file, "Could not open file scene file");
	testData.SetSceneFileSize(file->GetSize());
	SafeRelease(file);

	PreparePath();
    PrepareFpsStat();
    PrepareCameraAnimation();
    ZeroCurFpsStat();
    MoveToNextPoint();

    SafeRelease(scene);
}
コード例 #2
0
void ViewSceneScreen::LoadResources()
{
    BaseScreen::LoadResources();
 
    ScopedPtr<Scene> scene(new Scene());
    Entity *entity = scene->GetRootNode(GameCore::Instance()->GetScenePath());
    scene->AddNode(entity);
    scene->ReleaseRootNode(GameCore::Instance()->GetScenePath());
    
    DVASSERT(camera == NULL);
    camera = new Camera();
    
	Core* core = DAVA::Core::Instance();
	float32 aspect = core->GetVirtualScreenHeight() / core->GetVirtualScreenWidth();
    
	camera->SetupPerspective(70.f, aspect, 0.5f, 2500.f);
	camera->SetLeft(Vector3(1, 0, 0));
	camera->SetUp(Vector3(0, 0, 1.f));
    camera->SetTarget(Vector3(0, 0, 0));
    camera->SetPosition(Vector3(0, 0, 100));


    //TODO: debug
    camera->SetPosition(Vector3(18.7855f, 111.0697f, 57.0635f));
    camera->SetDirection(Vector3(-1.2904f, 9.0496f, -4.0545f));
    //ENDOFTODO

    
    scene->AddCamera(camera);
    scene->SetCurrentCamera(camera);
    
    const Rect screenRect = GetRect();
    ScopedPtr<UI3DView> sceneView(new UI3DView(screenRect));
    sceneView->SetScene(scene);
    sceneView->SetInputEnabled(false);
    AddControl(sceneView);
    
    ScopedPtr<UIButton> backButton(CreateButton(Rect(0, 0, 90, 30), L"Back"));
    backButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ViewSceneScreen::OnBack));
    backButton->SetDebugDraw(true);
    AddControl(backButton);
    
    
    const float32 joyPADSize = 100.f;
    
    moveJoyPAD = new UIJoypad(Rect(0, screenRect.dy - joyPADSize, joyPADSize, joyPADSize));
    moveJoyPAD->GetBackground()->SetSprite("~res:/Gfx/Joypad/joypad", 0);
    moveJoyPAD->SetStickSprite("~res:/Gfx/Joypad/joypad", 1);

    AddControl(moveJoyPAD);
    
    viewJoyPAD = new UIJoypad(Rect(screenRect.dx - joyPADSize, screenRect.dy - joyPADSize, joyPADSize, joyPADSize));
    viewJoyPAD->GetBackground()->SetSprite("~res:/Gfx/Joypad/joypad", 0);
    viewJoyPAD->SetStickSprite("~res:/Gfx/Joypad/joypad", 1);
    AddControl(viewJoyPAD);
    
    viewXAngle = 0;
    viewYAngle = 0;
    
    DVASSERT(info == NULL);
    info = new UIStaticText(Rect(0, 0, screenRect.dx, 30.f));
    info->SetFont(font);
    info->SetTextColor(Color::White);
    info->SetTextAlign(ALIGN_VCENTER | ALIGN_RIGHT);
    
    AddControl(info);
}