/*! \brief Set up Zoom transition */ void TransitionZoom::Initialise() { // Both images are same size int width = m_old->GetArea().width(); // Zoom away to left Animation *oldZoom = new Animation(m_prev, Animation::Zoom); oldZoom->Set(1.0, 0.0, m_duration, QEasingCurve::OutQuad); m_animation->Add(oldZoom); Animation *oldMove = new Animation(m_prev, Animation::Position); oldMove->Set(QPoint(0, 0), QPoint(-width / 2, 0), m_duration, QEasingCurve::InQuad); m_animation->Add(oldMove); // Zoom in from right Animation *newZoom = new Animation(m_next, Animation::Zoom); newZoom->Set(0.0, 1.0, m_duration, QEasingCurve::InQuad); m_animation->Add(newZoom); Animation *newMove = new Animation(m_next, Animation::Position); newMove->Set(QPoint(width / 2, 0), QPoint(0, 0), m_duration, QEasingCurve::OutQuad); m_animation->Add(newMove); // Hide new image until it's needed m_new->SetZoom(0.0); }
/*! \brief Set up Twist transition */ void TransitionTwist::Initialise() { // Reduce hzoom of left image to nothing Animation *oldPic = new Animation(m_prev, Animation::HorizontalZoom); oldPic->Set(1.0, 0.0, m_duration / 2, QEasingCurve::InQuart); m_animation->Add(oldPic); // Increase hzoom of right image from nothing to full Animation *newPic = new Animation(m_next, Animation::HorizontalZoom); newPic->Set(0.0, 1.0, m_duration / 2, QEasingCurve::OutQuart); m_animation->Add(newPic); // Hide new image until it's needed m_new->SetHorizontalZoom(0); }
/*! \brief Set up Blend transition */ void TransitionBlend::Initialise() { // Fade out prev image Animation *oldPic = new Animation(m_prev, Animation::Alpha); oldPic->Set(255, 0, m_duration, QEasingCurve::InOutQuad); m_animation->Add(oldPic); // Fade in next image Animation *newPic = new Animation(m_next, Animation::Alpha); newPic->Set(0, 255, m_duration, QEasingCurve::InOutQuad); m_animation->Add(newPic); // Hide new image until it's needed m_new->SetAlpha(0); }
/*! \brief Set up Slide transition */ void TransitionSlide::Initialise() { // Both images are same size int width = m_old->GetArea().width(); // Slide off to left Animation *oldPic = new Animation(m_prev, Animation::Position); oldPic->Set(QPoint(0, 0), QPoint(-width, 0), m_duration, QEasingCurve::InOutQuart); m_animation->Add(oldPic); // Slide in from right Animation *newPic = new Animation(m_next, Animation::Position); newPic->Set(QPoint(width, 0), QPoint(0, 0), m_duration, QEasingCurve::InOutQuart); m_animation->Add(newPic); // Hide new image until it's needed m_new->SetPosition(width, 0); }
void CEnemySuperRetardZombie::InitAnimation() { Animation* cAnim; cAnim = new Animation(); cAnim->Set(1, 1, 0, 0.f); AddAnimation(cAnim, DIR_IDLE_DOWN); //Idle East cAnim = new Animation(); cAnim->Set(4, 4, 0, 0.f); AddAnimation(cAnim, DIR_IDLE_LEFT); //Idle East cAnim = new Animation(); cAnim->Set(7, 7, 0, 0.f); AddAnimation(cAnim, DIR_IDLE_RIGHT); //Idle North cAnim = new Animation(); cAnim->Set(10, 10, 0, 0.f); AddAnimation(cAnim, DIR_IDLE_UP); //Walk South cAnim = new Animation(); cAnim->Set(0, 2, 0, 0.8f); AddAnimation(cAnim, DIR_DOWN); //Walk East cAnim = new Animation(); cAnim->Set(3, 5, 0, 0.4f); AddAnimation(cAnim, DIR_LEFT); //Walk East cAnim = new Animation(); cAnim->Set(6, 8, 0, 0.4f); AddAnimation(cAnim, DIR_RIGHT); //Walk North cAnim = new Animation(); cAnim->Set(9, 11, 0, 0.4f); AddAnimation(cAnim, DIR_UP); }
/*! \brief Set up Spin transition */ void TransitionSpin::Initialise() { // Set up blend TransitionBlend::Initialise(); // Add simultaneous spin Animation *an = new Animation(m_prev, Animation::Angle); an->Set(0.0, 360.1, m_duration, QEasingCurve::InOutQuad); m_animation->Add(an); an = new Animation(m_next, Animation::Angle); an->Set(0.0, 360.1, m_duration, QEasingCurve::InOutQuad); m_animation->Add(an); // Zoom prev away, then back SequentialAnimation *seq = new SequentialAnimation(); m_animation->Add(seq); an = new Animation(m_prev, Animation::Zoom); an->Set(1.0, 0.5, m_duration / 2, QEasingCurve::InOutQuad); seq->Add(an); an = new Animation(m_prev, Animation::Zoom); an->Set(0.5, 1.0, m_duration / 2, QEasingCurve::InOutQuad); seq->Add(an); // Zoom next away, then back seq = new SequentialAnimation(); m_animation->Add(seq); an = new Animation(m_next, Animation::Zoom); an->Set(1.0, 0.5, m_duration / 2, QEasingCurve::InOutQuad); seq->Add(an); an = new Animation(m_next, Animation::Zoom); an->Set(0.5, 1.0, m_duration / 2, QEasingCurve::InOutQuad); seq->Add(an); }
void ResourcePool::processMesh(string config) { Branch meshBranch = TextTree::FileToRead(config); for (vector<Branch>::iterator branch = meshBranch.childBranches.begin(); branch != meshBranch.childBranches.end(); ++branch) { string meshName = branch->branchName; Color meshColor; enum MISC_VARIABLE { VAR_LENGTH, VAR_WIDTH, VAR_HEIGHT, VAR_RADIUS, VAR_INNER_RADIUS, VAR_OUTER_RADIUS, VAR_SLICES, VAR_STACKS, VAR_ANIM_TIME, MAX_VAR, }; float meshVar[MAX_VAR]; for (int i = 0; i < MAX_VAR; ++i) { meshVar[i] = 1.0f; } string meshVarNames[MAX_VAR] = { "Length", "Width", "Height", "Radius", "InnerRadius", "OuterRadius", "Slices", "Stacks", }; // default 2D mesh variables int meshPosX = 0; int meshPosY = 0; int meshTextRow = 0; int meshTextCol = 0; // Spirte Animation int meshSpriteRow = 0; int meshSpriteCol = 0; // Tile sheet int meshTileRow = 0; int meshTileCol = 0; string directory = ""; string meshType = ""; unsigned textureID = 0; for (vector<Attribute>::iterator attri = branch->attributes.begin(); attri != branch->attributes.end(); ++attri) { Attribute tempAttri = *attri; string attriName = tempAttri.name; string attriValue = tempAttri.value; if (attriName == "ColorValue") { Vector3 tempColor; stringToVector(attriValue, tempColor); meshColor.Set(tempColor.x, tempColor.y, tempColor.z); } if (attriName == "ColorName") { meshColor = retrieveColor(attriValue); } else if (attriName == "Type") { meshType = attriValue; } else if (attriName == "Texture") { textureID = this->retrieveTexture(attriValue); } else if (attriName == "Directory") { directory = attriValue; } else if (attriName == "SpriteRow") { meshSpriteRow = stoi(attriValue); } else if (attriName == "SpriteCol") { meshSpriteCol = stoi(attriValue); } else if (attriName == "TextRow") { meshTextRow = stoi(attriValue); } else if (attriName == "TextCol") { meshTextCol = stoi(attriValue); } else if (attriName == "PosX") { meshPosX = stoi(attriValue); } else if (attriName == "PosY") { meshPosY = stoi(attriValue); } else if (attriName == "TileRow") { meshTileRow = stoi(attriValue); } else if (attriName == "TileCol") { meshTileCol = stoi(attriValue); } else { for (int k = 0; k < MAX_VAR; ++k) { if (attriName == meshVarNames[k]) { meshVar[k] = stof(attriValue); break; } } } } // process data, generate mesh using meshbuilder Mesh* mesh = NULL; if (meshType == "Axis") { mesh = MeshBuilder::GenerateAxes(meshName, meshVar[VAR_LENGTH], meshVar[VAR_HEIGHT], meshVar[VAR_WIDTH]); } else if (meshType == "Ray") { mesh = MeshBuilder::GenerateRay(meshName, meshVar[VAR_LENGTH]); } else if (meshType == "Quad") { mesh = MeshBuilder::GenerateQuad(meshName, meshColor, meshVar[VAR_LENGTH], meshVar[VAR_WIDTH]); } else if (meshType == "Cube") { mesh = MeshBuilder::GenerateCube(meshName, meshColor, meshVar[VAR_LENGTH]); } else if (meshType == "Circle") { mesh = MeshBuilder::GenerateCircle(meshName, meshColor, (unsigned)meshVar[VAR_SLICES], meshVar[VAR_RADIUS]); } else if (meshType == "DebugQuad") { mesh = MeshBuilder::GenerateDebugQuad(meshName, meshColor, meshVar[VAR_LENGTH]); } else if (meshType == "DebugCircle") { mesh = MeshBuilder::GenerateDebugCircle(meshName, meshColor, (unsigned)meshVar[VAR_SLICES], meshVar[VAR_RADIUS]); } else if (meshType == "DebugCube") { mesh = MeshBuilder::GenerateDebugCube(meshName, meshColor, meshVar[VAR_LENGTH]); } else if (meshType == "Sphere") { mesh = MeshBuilder::GenerateSphere(meshName, meshColor, (unsigned)meshVar[VAR_STACKS], (unsigned)meshVar[VAR_SLICES], meshVar[VAR_RADIUS]); } else if (meshType == "Skyplane") { mesh = MeshBuilder::GenerateSkyPlane(meshName, meshColor, (unsigned)meshVar[VAR_SLICES], (float)meshVar[VAR_INNER_RADIUS], (float)meshVar[VAR_OUTER_RADIUS], (float)meshTileRow, (float)meshTileCol); } else if (meshType == "Terrain") { HEIGHTMAP tempHeightmap; tempHeightmap.name = meshName; mesh = MeshBuilder::GenerateTerrain(meshName, directory, tempHeightmap.heightMap); if (this->addHeightmap(tempHeightmap.name, tempHeightmap)) { std::cout << "Successfully added new heightmap!" << std::endl; } } else if (meshType == "Obj") { mesh = MeshBuilder::GenerateOBJ(meshName, directory); } else if (meshType == "Text") { mesh = MeshBuilder::GenerateText(meshName, meshTextRow, meshTextCol); } else if (meshType == "2D") { mesh = MeshBuilder::Generate2DMesh(meshName, meshColor, (int)meshVar[VAR_WIDTH], (int)meshVar[VAR_HEIGHT]); } else if (meshType == "SpriteAnimation") { mesh = MeshBuilder::GenerateSpriteAnimation(meshName, meshSpriteRow, meshSpriteCol); SpriteAnimation *sa = dynamic_cast<SpriteAnimation*>(mesh); Branch tempBranch = *branch; // handle animations variables for (vector<Branch>::iterator childbranch = tempBranch.childBranches.begin(); childbranch != tempBranch.childBranches.end(); ++childbranch) { int id = 0; int startFrame = 0; int endFrame = 0; bool repeat = false; bool pause = false; float animationTime = 0.f; for (vector<Attribute>::iterator childAttri = childbranch->attributes.begin(); childAttri != childbranch->attributes.end(); ++childAttri) { Attribute tempAttri = *childAttri; string attriName = tempAttri.name; string attriValue = tempAttri.value; if (attriName == "ID") { id = stoi(attriValue); } else if (attriName == "StartFrame") { startFrame = stoi(attriValue); } else if (attriName == "EndFrame") { endFrame = stoi(attriValue); } else if (attriName == "Repeat") { stringToBool(attriValue, repeat); } else if (attriName == "Pause") { stringToBool(attriValue, pause); } else if (attriName == "AnimationTime") { animationTime = stof(attriValue); } } if (sa) { Animation* anime = new Animation(); anime->Set(id, startFrame, endFrame, repeat, pause, animationTime); sa->animations.push_back(anime); } } //sort (sa->animations.begin(), sa->animations.end()); } else if (meshType == "TileSheet") { mesh = MeshBuilder::GenerateTileSheet(meshName, meshTileRow, meshTileCol); } // push back mesh if (mesh != NULL) { if (textureID != 0) { mesh->textureID = textureID; } if (addMesh(branch->branchName, mesh)) { std::cout << "Successfully added new mesh!" << std::endl; } } } }