void TestLocRotScaleLevel2(Transform& gparent, Transform& parent, Transform& child) { Transform p = parent; Transform gp = gparent; // Location child.set_local_pos(RandomVec()); CheckPos(parent, child, "Translation effect on child"); AssertEquals(parent, p, "Child's translation has no effect parent"); // Rotation parent.set_rot(RandomQuat()); CheckPos(parent, child, "Rotation effect on child"); AssertEquals(parent.pos(), p.pos(), "Rotation invariant on local_pos"); p = parent; gp = gparent; child.set_rot(parent.rot()); AssertEquals(parent, p, "Child's rotation has no effect on parent"); AssertEquals(gparent, gp, "Child's rotation has no effect on gparent"); // Scale parent.set_local_scale(RandomVec()); CheckPos(parent, child, "Scale effect on child"); AssertEquals(parent.pos(), p.pos(), "Scale invariant on local_pos"); p = parent; gp = gparent; child.set_scale(parent.scale()); AssertEquals(parent, p, "Child's scaling has no effect parent"); AssertEquals(gparent, gp, "Child's scaling has no effect on gparent"); }
Vector AI::RandomValid(Tabla & tab) //bucla infinita daca nu exista mutari { Vector v = RandomVec(); while (!tab.VerificMutare(v)) { v = RandomVec(); } return v; }
int main() { srand(time(nullptr)); Transform parent, child, grand_child; parent.set_pos(RandomVec()); parent.addChild(child); child.addChild(grand_child); TestParentChild(parent, child, grand_child); // Test with a thousand random transformations for (int i = 0; i < 1000; ++i) { TestLocRotScaleLevel1(parent, child); TestLocRotScaleLevel2(parent, child, grand_child); } DirectionTest(); GlobalSettings(parent); GlobalSettings(child); GlobalSettings(grand_child); if (fail_num) { std::cout << "Number of failures: " << fail_num << std::endl; } else { std::cout << "Test was successful" << std::endl; } }
void Application::InitSSAO() { m_Renderer->SetUsePostProcessing(true); m_SSAO = new PostProcessingEffect(m_Renderer); m_SSAO->LoadEffect(Load("Common/SSAO.ppe")); m_Renderer->AddPostProcessingEffect(m_SSAO); m_SSAORandomTex = m_Renderer->GetRasterizer()->CreateTexture(); m_SSAORandomTex->CreateTexture(4,4,Texture::PT_FLOAT); for(i32 x = 0; x < 4; x++) { for(i32 y = 0; y < 4; y++) { m_SSAORandomTex->SetPixel(Vec2(x,y),Vec4(Random(-1.0f,1.0f),Random(-1.0f,1.0f),0.0f,1.0f)); } } m_SSAORandomTex->UpdateTexture(); m_SSAO->GetStage(0)->GetMaterial()->SetMap(Material::MT_CUSTOM0,m_SSAORandomTex); UniformBuffer* SSAOInputs = m_SSAO->GetStage(0)->GetMaterial()->GetUserUniforms(); vector<Vec3> SSAOKernel; for(i32 i = 0; i < SSAOInputs->GetUniformInfo(0)->ArraySize; i++) { Vec3 Sample = RandomVec(1.0f); Sample.z = abs(Sample.z); Sample.Normalize(); Scalar Scale = Scalar(i) / Scalar(SSAOInputs->GetUniformInfo(0)->ArraySize); Scale = 0.1f + ((1.0f - 0.1f) * pow(Scale,2.0f)); Sample *= Scale; SSAOKernel.push_back(Sample); } SSAOInputs->SetUniform(0,SSAOKernel); SSAOInputs->SetUniform(1,SSAOInputs->GetUniformInfo(0)->ArraySize); SSAOInputs->SetUniform(2,0.2f); SSAOInputs->SetUniform(3,1.0f); SetSSAONoiseScale(4); }
void GlobalSettings(Transform& t) { glm::dvec3 v{RandomVec()}, u{RandomVec()}; glm::dquat q{RandomQuat()}; int pnum = GetParentsNum(&t); std::string prnts = " on a transform with " + std::to_string(pnum) + " parents"; t.set_pos(v); AssertEquals(t.pos(), v, "Setting global position" + prnts); t.set_rot(q); AssertEquals(t.rot(), q, "Setting global rotation" + prnts); t.set_scale(v); AssertEquals(t.scale(), v, "Setting global scaling" + prnts); v = RandomVec(); t.set_forward(v); AssertEquals(t.forward(), glm::normalize(v), "Setting global forward" + prnts); v = RandomVec(); t.set_right(v); AssertEquals(t.right(), glm::normalize(v), "Setting global right" + prnts); v = RandomVec(); t.set_up(v); AssertEquals(t.up(), glm::normalize(v), "Setting global up" + prnts); for (int i = 0; i < 1000; ++i) { t.set_rot(v = glm::normalize(RandomVec()), u = glm::normalize(RandomVec())); AssertEquals(t.rot()*v, u, "Setting rot with 'v', 'u'" + prnts); } // There are special cases for rot t.set_rot(v, v); AssertEquals(t.rot()*v, v, "Setting rot with 'v', 'v'" + prnts); t.set_rot(v, -v); AssertEquals(t.rot()*v, -v, "Setting rot with 'v', '-v'" + prnts); }