// ================================================================================================================== int mainloop() { this->render.BeginScene(); { this->t = timer->GetTime(); ShaderRef fragmentShader = this->m_fragmentShader->Get(); float2 rot_rp; float3 rot_rpy; rot_rpy = trk_rotate_root->Get(); m_rootActor->Matrix().Identity(); m_rootActor->Matrix().RotateRPY(rot_rpy.x, rot_rpy.y, rot_rpy.z); for (int i = 0; i < 6; i++) { rot_rp = trk_rotate[i]->Get(); modelActors[i]->Transform().Identity(); modelActors[i]->Transform().RotateRPY(rot_rp.x, rot_rp.y, 0); } fragmentShader->SetSamplerSatate(render, "SampleType", m_textureSampler->GetSamplerState()); scene->PreRender(render); scene->Render(render); timer->Update(); } this->render.EndScene(); return 0; };
// ================================================================================================================== int mainloop() { m_postfx->BindInput(render); // pre fx-pass this->render.BeginScene(); { ShaderRef fragmentShader = this->m_fragmentShader->Get(); ShaderRef fxaaShader = this->m_fxFXAA->Get(); ShaderRef fishEyeShader = this->m_fxFishEye->Get(); m_rootActor->Matrix().Identity(); m_rootActor->Matrix().RotateRPY(t,0,0); fragmentShader->GetBRes("SampleType").Set(m_textureSampler->GetSamplerState()); float2 res = float2(); render.GetScreenSizef(res.x, res.y); fxaaShader->GetParam("FXAA").Get("resolution").SetF(res.x, res.y); fishEyeShader->GetParam("Fisheye").Get("theta").SetF(0.5); scene->PreRender(render); scene->Render(render); this->t += 0.01; } // render fx chain m_postfx->Render(render); this->render.EndScene(); return 0; };
int init() { // --- ezeket kell osszeszedni egy initwindowban const int screenWidth = m_window.getRealWidth(), screenHeight = m_window.getRealHeight(); const int VSYNC_ENABLED = 1, FULL_SCREEN = 0; this->render.Initialize(screenWidth, screenHeight, VSYNC_ENABLED, this->m_window.getHWnd(), FULL_SCREEN); // init file loader this->m_file_loader = new FileAssetFactory("./../assets/"); // -------------------------------------------------- // -- camera CameraRef camera = new Camera; //camera->SetPosition(0.0f, 0.0f, -10.0f); //camera->SetLookTo(0, 0, -1); // -- texture TextureResRef texture = new TextureRes(); texture = this->Load<TextureRes>(new TextureFromBitmap("normap", "textures/Normap.jpg")); // -- texture sampler m_textureSampler = new TextureSampler(); m_textureSampler->Initialize(render); // -- load shader m_vertexShader = Load<ShaderRes>(new VertexShaderLoader("vShader", "shaders/vertex.hlsl", "")); m_fragmentShader = Load<ShaderRes>(new PixelShaderLoader("pShader", "shaders/textured.hlsl", "")); // -- load music music = Load<MusicRes>(new MusicBassLoader("alpha_c_-_euh.ogg")); // -- precalc this->DoPrecalc(); // -- precalc utan egybol allitsuk be a synctrackert // Setup syctracker timer = new Timer(); timer->Initialize(music, music->Get()->GetLengthms(), 180, 8); timer->Connect(); valTracker = new ValueTracker(timer); // -- model ModelRef model = new Model; model->SetMaterial(new Material()); model->GetMaterial()->AddTexture(texture, "diffuse"); model = new Model(new Mesh()); model->SetName("cube"); model->GetMesh()->AddPointer("POSITION", GrafkitData::cubeVertexSize, GrafkitData::cubeVertices); model->GetMesh()->AddPointer("TEXCOORD", GrafkitData::cubeTextureUVsSize, GrafkitData::cubeTextureUVs); model->GetMesh()->AddPointer("NORMAL", GrafkitData::cubeVertexSize, GrafkitData::cubeNormals); model->GetMesh()->SetIndices(GrafkitData::cubeVertexCount, GrafkitData::cubeIndicesCount, GrafkitData::cubeIndices); model->GetMesh()->Build(render, m_vertexShader); // -- setup scene scene = new Scene(); this->cameraActor = new Actor(); cameraActor->AddEntity(camera); this->modelActor = new Actor(); modelActor->AddEntity(model); /* Alap right-handed koordinatarendszer szerint osszerakunk egy keresztet Ezeket adjuk hozza a belso kockahoz */ float3 cica[] = { { 1, 0, 0 }, /* Jobb */{ -1, 0, 0 }, /* Bal */ { 0, 1, 0 }, /* fent */{ 0,-1, 0 }, /* lent */ { 0, 0, -1 }, /* elol */{ 0, 0, 1 }, /* hatul */ }; char *names[] = { "r", "l", "u", "d", "f", "b" }; /*right, left, up, down, front, back*/ this->trk_rotate_root = valTracker->newFloat3Track("root", "r", "rpy"); // size_t i = 5; for (size_t i = 0; i < 6; i++) { ActorRef actor = new Actor(); actor->AddEntity(model); modelActor->AddChild(actor); modelActors[i] = actor; float3 v = cica[i]; v.x *= 3; v.y *= 3; v.z *= 3; actor->Matrix().Translate(v); this->trk_rotate[i] = valTracker->newFloat2Track("b", names[i], "rpy"); } ActorRef rootActor = new Actor(); cameraActor->Matrix().Translate(0,0,-10); rootActor->AddChild(cameraActor); rootActor->AddChild(modelActor); m_rootActor = rootActor; scene->BuildScene(render, m_vertexShader, m_fragmentShader); scene->Initialize(rootActor); scene->SetActiveCamera(0); // --- this->t = 0; return 0; };
int init() { // --- ezeket kell osszeszedni egy initwindowban const int screenWidth = m_window.getRealWidth(), screenHeight = m_window.getRealHeight(); const int VSYNC_ENABLED = 1, FULL_SCREEN = 0; this->render.Initialize(screenWidth, screenHeight, VSYNC_ENABLED, this->m_window.getHWnd(), FULL_SCREEN); // init file loader this->m_file_loader = new FileAssetFactory("./../../assets/postfx/"); // -------------------------------------------------- // -- camera CameraRef camera = new Camera; camera->SetPosition(0.0f, 0.0f, -10.0f); // -- texture TextureResRef texture = new TextureRes(); texture = this->Load<TextureRes>(new TextureFromBitmap("Normap.jpg")); // -- texture sampler m_textureSampler = new TextureSampler(); m_textureSampler->Initialize(render); // -- load shader m_vertexShader = Load<ShaderRes>(new ShaderLoader("vShader", "texture.hlsl", "TextureVertexShader", ST_Vertex)); m_fragmentShader = Load<ShaderRes>(new ShaderLoader("pShader", "texture.hlsl", "TexturePixelShader", ST_Pixel)); m_fxFXAA = Load<ShaderRes>(new ShaderLoader("xFXAA", "fxaa.hlsl", "FXAA", ST_Pixel)); m_fxFishEye = Load<ShaderRes>(new ShaderLoader("xFishEye", "fisheye.hlsl", "fisheyeProc", ST_Pixel)); // m_fxVhs = Load<ShaderRes>(new ShaderLoader("xVhs", "vhstape.hlsl", "TextureVertexShader", ST_Pixel)); // this->DoPrecalc(); // -- model ModelRef model = new Model; model->SetMaterial(new MaterialBase); model->GetMaterial()->AddTexture(texture, "diffuse"); SimpleMeshGenerator generator(render, m_vertexShader); generator["POSITION"] = (void*)GrafkitData::cubeVertices; generator["TEXCOORD"] = (void*)GrafkitData::cubeTextureUVs; generator(GrafkitData::cubeVertexLength, GrafkitData::cubeIndicesLength, GrafkitData::cubeIndices, model); // -- setup scene scene = new Scene(); ActorRef cameraActor = new Actor(); cameraActor->AddEntity(camera); ActorRef modelActor = new Actor(); modelActor->AddEntity(model); ActorRef modelActorL = new Actor(); modelActorL->AddEntity(model); modelActorL->Matrix().Translate(3, 0, 0); modelActor->AddChild(modelActorL); ActorRef modelActorR = new Actor(); modelActorR->AddEntity(model); modelActorR->Matrix().Translate(-3, 0, 0); modelActor->AddChild(modelActorR); ActorRef modelActorU = new Actor(); modelActorU->AddEntity(model); modelActorU->Matrix().Translate(0, 3, 0); modelActor->AddChild(modelActorU); ActorRef modelActorD = new Actor(); modelActorD->AddEntity(model); modelActorD->Matrix().Translate(0, -3, 0); modelActor->AddChild(modelActorD); ActorRef modelActorF = new Actor(); modelActorF->AddEntity(model); modelActorF->Matrix().Translate(0, 0, 3); modelActor->AddChild(modelActorF); ActorRef modelActorB = new Actor(); modelActorB->AddEntity(model); modelActorB->Matrix().Translate(0, 0, -3); modelActor->AddChild(modelActorB); // ActorRef lightActor = new Actor(); lightActor->AddEntity(light); ActorRef rootActor = new Actor(); rootActor->AddChild(cameraActor); rootActor->AddChild(modelActor); m_rootActor = rootActor; scene->SetRootNode(rootActor); scene->SetCameraNode(cameraActor); // scene->AddLightNode(lightActor); scene->SetVShader(m_vertexShader); scene->SetFShader(m_fragmentShader); // -- setup postfx size_t k = 0; m_postfx = new EffectComposer(); m_postfx->Initialize(render); k = m_postfx->AddPass(new EffectPass()); m_postfx->GetEffect(k)->Initialize(render, m_fxFXAA); k = m_postfx->AddPass(new EffectPass()); m_postfx->GetEffect(k)->Initialize(render, m_fxFishEye); // k = m_postfx->AddPass(new EffectPass()); m_postfx->GetEffect(k)->Initialize(render, m_fxVhs); // k = m_postfx->AddPass(new EffectPass()); m_postfx->GetEffect(k)->Initialize(render, sahder); // k = m_postfx->AddPass(new EffectPass()); m_postfx->GetEffect(k)->Initialize(render, sahder); // k = m_postfx->AddPass(new EffectPass()); m_postfx->GetEffect(k)->Initialize(render, sahder); // --- return 0; };