From 3db24e81311bf522b29f4de6b4694dfcc61b7b88 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Thu, 31 Mar 2022 18:56:47 +0300 Subject: [PATCH] updated morph animation sample --- morphAnimationSample.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/morphAnimationSample.cpp b/morphAnimationSample.cpp index 48e525e..de57d47 100644 --- a/morphAnimationSample.cpp +++ b/morphAnimationSample.cpp @@ -6,6 +6,8 @@ #include "animationController.h" #include "animationChannel.h" #include "box.h" +#include "assetManager.h" + #include #include FT_FREETYPE_H @@ -14,7 +16,9 @@ using namespace vb01; int main(){ const string PATH = "../", TEX_PATH = PATH + "samples/textures/", MODEL_PATH = PATH + "samples/models/"; - string skyboxTextures[] = { + + const int numTextures = 6; + string skyboxTextures[numTextures] = { TEX_PATH + "top.jpg", TEX_PATH + "bottom.jpg", TEX_PATH + "left.jpg", @@ -23,6 +27,10 @@ int main(){ TEX_PATH + "back.jpg" }; + //Loads the assets to be stored and retrievable at a later time + for(int i = 0; i < numTextures; i++) + AssetManager::getSingleton()->load(skyboxTextures[i]); + /* * Gets Root object to start the sample, * also passes the base path for asset retrieval. @@ -39,20 +47,22 @@ int main(){ cam->setPosition(Vector3(-1, 0.25, .2) * 20); cam->lookAt(Vector3(1, 0, 0).norm(), Vector3(0, 1, 0).norm()); - Model *model = new Model(MODEL_PATH + "kek.vb"); + string modelPath = MODEL_PATH + "kek.xml"; + AssetManager::getSingleton()->load(modelPath); + Model *model = new Model(modelPath); + Material *mat = new Material(PATH + "texture"); mat->addBoolUniform("lightingEnabled", false); mat->addBoolUniform("texturingEnabled", true); + string images[] = {TEX_PATH + "defaultTexture.jpg"}; + AssetManager::getSingleton()->load(images[0]); Texture *texture = new Texture(images, 1, false); mat->addTexUniform("textures[0]", texture, true); + model->setMaterial(mat); rootNode->attachChild(model); - - int numChildren = model->getNumChildren(); - Node *node = model->getChild(1); - Mesh *mesh = node->getMesh(0); - Skeleton *skeleton = mesh->getSkeleton(); + Skeleton *skeleton = model->getChild(0)->getSkeleton(0); /* * The AnimationController plays the animations set in the AnimationChannel objects.