static void se_inflateResource(JNIEnv* env, jobject obj, jint resource, jstring objName, jint objIndex, jstring nodeName, jint nodeIndex, jboolean removeTopNode) { //Invoke by gl thread jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID); const char* sceneName8 = env->GetStringUTFChars(sceneName, 0); const char* nodeName8 = env->GetStringUTFChars(nodeName, NULL); const char* objName8 = env->GetStringUTFChars(objName, NULL); SE_Scene* scene = SE_Application::getInstance()->getSceneManager()->getScene(SE_FRAMEBUFFER_SCENE, SE_StringID(sceneName8)); SE_Spatial* node = SE_Application::getInstance()->getSceneManager()->findSpatialByName(nodeName8, nodeIndex); SE_Spatial* s = (SE_Spatial*)resource; if (!node) { env->ReleaseStringUTFChars(sceneName, sceneName8); env->ReleaseStringUTFChars(nodeName, nodeName8); env->ReleaseStringUTFChars(objName, objName8); return; } if (s) { SE_ResourceManager* m = SE_Application::getInstance()->getResourceManager(); SE_ResourceManager* loader = s->getCBFLoader(); m->copy(loader); s->deleteCBFLoader(); if (removeTopNode) { s->getChildByIndex(0)->setSpatialName(objName8); s->getChildByIndex(0)->setCloneIndex(objIndex); s->replaceChildParent(node); node->setCloneIndex(objIndex); scene->inflate(); node->updateWorldTransform(); node->updateBoundingVolume(); node->updateWorldLayer(); delete s; } else { s->setSpatialName(objName8); s->setCloneIndex(objIndex); std::string modelName = objName8; modelName = modelName + "_model"; s->getChildByIndex(0)->setSpatialName(modelName.c_str()); s->getChildByIndex(0)->setCloneIndex(objIndex); scene->addSpatial(node, s); scene->inflate(); node = scene->getRoot(); node->updateWorldTransform(); node->updateBoundingVolume(); node->updateWorldLayer(); } } env->ReleaseStringUTFChars(sceneName, sceneName8); env->ReleaseStringUTFChars(nodeName, nodeName8); env->ReleaseStringUTFChars(objName, objName8); }
static void se_createScene(JNIEnv* env, jobject obj) { jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID); const char* sceneName8 = env->GetStringUTFChars(sceneName, 0); SE_Scene* scene = findScene(sceneName8); if (!scene) { scene = new SE_Scene(sceneName8); SE_Application::getInstance()->getSceneManager()->pushBack(SE_FRAMEBUFFER_SCENE, scene); SE_Camera* camera = new SE_Camera(); scene->inflate("assets/base/scene_resource.xml"); scene->setCamera(camera); } env->ReleaseStringUTFChars(sceneName, sceneName8); }