bool OgreKit::init(const gkString& blend) { gkPrintf("----------- OgreKit Android Demo init -----------------"); LOG_FOOT; gkString cfgfname; // Parse command line m_blend = gkDefaultBlend; if (!blend.empty()) m_blend = blend; getPrefs().debugFps = true; getPrefs().wintitle = gkString("OgreKit Demo (Press Escape to exit)[") + m_blend + gkString("]"); getPrefs().blendermat=true; //getPrefs().shaderCachePath="/sdcard/gamekit"; getPrefs().enableshadows=false; getPrefs().viewportOrientation="portrait"; // m_prefs.disableSound=false; gkPath path = cfgfname; LOG_FOOT; // overide settings if found if (path.isFileInBundle()) getPrefs().load(path.getPath()); LOG_FOOT; m_inited = initialize(); LOG_FOOT; //gkMessageManager::getSingleton().addListener(this); return m_inited; }
int GuiDemo::setup(int argc, char** argv) { int winsize_x = 800; int winsize_y = 600; m_prefs.wintitle = gkString("OgreKit GuiDemo (Press Escape to exit)[") + m_blend + gkString("]"); //m_prefs.grabInput = false; return 0; }
bool gkAndroidApp::init(AConfiguration* config, const gkString& file) { m_blend = file; getPrefs().debugFps = true; getPrefs().wintitle = gkString("OgreKit Demo [") + file + gkString("]"); getPrefs().blendermat=true; getPrefs().enableshadows=false; getPrefs().viewportOrientation="portrait"; getPrefs().extWinhandle = Ogre::StringConverter::toString((int)m_state->window); getPrefs().androidConfig = Ogre::StringConverter::toString((int)config); return initialize() && m_engine->initializeStepLoop(); }
void gkBlenderSceneConverter::convertObjectProperties(gkGameObject* gobj, Blender::Object* bobj) { // Attach variables to object ( used in game logic ) for (Blender::bProperty* prop = (Blender::bProperty*)bobj->prop.first; prop; prop = prop->next) { gkVariable* gop = 0; if (prop->type == GPROP_BOOL) { gop = gobj->createVariable(prop->name, prop->flag != 0); gop->setValue(prop->data != 0); } else if (prop->type == GPROP_INT) { gop = gobj->createVariable(prop->name, prop->flag != 0); gop->setValue((int)prop->data); } else if (prop->type == GPROP_FLOAT) { gop = gobj->createVariable(prop->name, prop->flag != 0); gop->setValue(*((gkScalar*)&prop->data)); } else if (prop->type == GPROP_STRING) { gop = gobj->createVariable(prop->name, prop->flag != 0); gop->setValue(gkString((char*)prop->poin)); } else if (prop->type == GPROP_TIME) { gop = gobj->createVariable(prop->name, prop->flag != 0); gop->setValue(*((gkScalar*)&prop->data)); } if (gop) gop->makeDefault(); } }
gkGameObjectInstance::gkGameObjectInstance(gkInstancedManager* creator, const gkResourceName& name, const gkResourceHandle& handle) : gkInstancedObject(creator, name, handle), m_parent(0), m_scene(0), m_owner(0), m_uidName(gkString("/UID{" + gkToString((int)handle) + "}")), m_layer(0xFFFFFFFF) { }
gkProcess* gsProcessManager::createOrientation(gsGameObject* obj, float time, const gsVector3& to) { if (obj) { gkOrientationProcess* orientationProcess = new gkOrientationProcess(obj->cast<gkGameObject>(),time,gkVector3(to)); return orientationProcess; } RETURN_DEFAULTPROCESS(gkString("Problem creating Orientation-Process!")) }
gkProcess* gsProcessManager::createTranslation(gsGameObject* obj, float time, const gsVector3& from, const gsVector3& to) { if (obj) { gkTranslationProcess* translationProcess = new gkTranslationProcess(obj->cast<gkGameObject>(),time,gkVector3(from),gkVector3(to)); return translationProcess; } RETURN_DEFAULTPROCESS(gkString("Problem creating Translation-Process!")) }
gkProcess* gsProcessManager::createSound(const gkString& soundName) { #ifdef OGREKIT_OPENAL_SOUND if (!soundName.empty()) { gkSoundProcess* sound = new gkSoundProcess(soundName); if (!sound || !sound->hasValidSound()) RETURN_DEFAULTPROCESS(gkString("Problem creating Sound-Process with name:"+soundName)) return sound; }
for (int i=0;i<processes.size();i++) { gkProcess* proc = processes.at(i); if (proc) seqProcesses->append(proc); } return seqProcesses; } gkProcess* gsProcessManager::createSound(const gkString& soundName) { #ifdef OGREKIT_OPENAL_SOUND if (!soundName.empty()) { gkSoundProcess* sound = new gkSoundProcess(soundName); if (!sound || !sound->hasValidSound()) RETURN_DEFAULTPROCESS(gkString("Problem creating Sound-Process with name:"+soundName)) return sound; } RETURN_DEFAULTPROCESS(gkString("Problem creating Sound-Process with empty name")) #else // return null-pointer so you can check for nil in lua return 0; #endif }
void gkBlenderSceneConverter::convertGroups() { gkGroupManager* mgr = gkGroupManager::getSingletonPtr(); // This is a complete list of groups & containing objects. // The gkGameObjectGroup is a containter, the gkGameObjectGroupInstance // is where the object should be added / removed from the scene. // for (Blender::Group* bgrp = (Blender::Group*)m_file->_getInternalFile()->m_group.first; bgrp != 0; // bgrp = (Blender::Group*)bgrp->id.next) gkBlendListIterator iter = m_file->_getInternalFile()->getGroupList(); while (iter.hasMoreElements()) { Blender::Group* bgrp = (Blender::Group*)iter.getNext(); const gkResourceName groupName(GKB_IDNAME(bgrp), m_groupName); if (mgr->exists(groupName)) { // Can most likely assert here continue; } gkGameObjectGroup* group = (gkGameObjectGroup*)mgr->create(groupName); for (Blender::GroupObject* bgobj = (Blender::GroupObject*)bgrp->gobject.first; bgobj; bgobj = bgobj->next) { if (bgobj->ob) { Blender::Object* bobj = bgobj->ob; if (!validObject(bobj)) continue; // is object a group-instance? if ( (bobj->transflag& OB_DUPLIGROUP) && bobj->dup_group != 0) { gkGameObject* gobj = m_gscene->createObject(gkString(GKB_IDNAME(bobj))+"_grproot"); convertObject(bobj,gobj); // Owning group Blender::Group* bgobj = bobj->dup_group; const gkString instGroupName(GKB_IDNAME(bgobj)); if (gobj) group->addGroup(instGroupName,gobj); } else { gkGameObject* gobj = m_gscene->getObject(GKB_IDNAME(bobj)); // add it to the list if (gobj) group->addObject(gobj); } } } // Destroy if empty if (group->isEmpty()) mgr->destroy(group); else mgr->attachGroupToScene(m_gscene, group); } }
int OgreKit::setup(int argc, char** argv) { int winsize_x = 800; int winsize_y = 600; m_prefs.wintitle = gkString("OgreKit Demo (Press Escape to exit)[") + m_blend + gkString("]"); gkString cfgfname; // Parse command line try { TCLAP::CmdLine cmdl("Ogrekit", ' ', "n/a"); cmdl.setExceptionHandling(false); //cfg arguments TCLAP::ValueArg<std::string> rendersystem_arg ("r", "rendersystem", "Set rendering system. (gl, d3d9, d3d10, d3d11)", false, "", "string"); //default GL TCLAP::ValueArg<std::string> viewportOrientation_arg ("", "viewportorientation", "Set viewport orientation.", false, m_prefs.viewportOrientation, "string"); TCLAP::ValueArg<std::string> log_arg ("", "log", "Set log file name.", false, m_prefs.log, "string"); TCLAP::ValueArg<bool> verbose_arg ("v", "verbose", "Enable verbose log.", false, m_prefs.verbose, "bool"); TCLAP::ValueArg<int> winsize_x_arg ("", "width", "Set window width.", false, winsize_x, "int"); TCLAP::ValueArg<int> winsize_y_arg ("", "height", "Set window height.", false, winsize_y, "int"); TCLAP::ValueArg<std::string> wintitle_arg ("", "wintitle", "Set window title.", false, m_prefs.wintitle, "string"); TCLAP::ValueArg<bool> fullscreen_arg ("f", "fullscreen", "Enable fullscreen mode.", false, m_prefs.fullscreen, "bool"); TCLAP::ValueArg<std::string> framingType_arg ("", "framingtype", "Set viewport framing type. (extend, crop, letterbox)", false, "", "string"); TCLAP::ValueArg<std::string> resources_arg ("", "resources", "Set resouces.", false, m_prefs.resources, "string"); TCLAP::ValueArg<bool> blendermat_arg ("", "blendmat", "Convert meshes using blender materials.", false, m_prefs.blendermat, "bool"); TCLAP::ValueArg<bool> matblending_arg ("", "matblending", "Enable material pass blending mode.", false, m_prefs.matblending, "bool"); TCLAP::ValueArg<bool> grapInput_arg ("g", "grabinput", "Grap mouse input.", false, m_prefs.grabInput, "bool"); TCLAP::ValueArg<bool> debugFps_arg ("d", "debugfps", "Display debug fps.", false, m_prefs.debugFps, "bool"); TCLAP::ValueArg<bool> vsync_arg ("", "vsync", "enable vertical-sync.", false, m_prefs.vsync, "bool"); TCLAP::ValueArg<int> vsyncrate_arg ("", "vsync-rate", "Set vsync-rate ", 0, m_prefs.vsyncRate, "int"); TCLAP::ValueArg<bool> debugPhysics_arg ("p", "debugphysics", "Display debug physics.", false, m_prefs.debugPhysics, "bool"); TCLAP::ValueArg<bool> debugPhysicsAabb_arg ("a", "debugphysicsaabb", "Display debug physics aabb.", false, m_prefs.debugPhysicsAabb, "bool"); TCLAP::ValueArg<bool> buildStaticGeometry_arg ("", "buildinstances", "Build Static Geometry.", false, m_prefs.buildStaticGeometry, "bool"); TCLAP::ValueArg<bool> useBulletDbvt_arg ("", "frustumculling", "Enable view frustum culling by dbvt.", false, m_prefs.useBulletDbvt, "bool"); TCLAP::ValueArg<bool> showDebugProps_arg ("t", "showdebugprops", "Show debug props.", false, m_prefs.showDebugProps, "bool"); TCLAP::ValueArg<bool> debugSounds_arg ("", "debugsounds", "Debug sounds.", false, m_prefs.debugSounds, "bool"); TCLAP::ValueArg<bool> disableSound_arg ("s", "disablesound", "Disable sounds.", false, m_prefs.disableSound, "bool"); TCLAP::ValueArg<bool> fsaa_arg ("", "fsaa", "Enable fsaa.", false, m_prefs.fsaa, "bool"); TCLAP::ValueArg<int> fsaaSamples_arg ("", "fsaasSamples", "Set fsaa samples.", false, m_prefs.fsaaSamples, "int"); TCLAP::ValueArg<bool> enableshadows_arg ("", "enableshadows", "Enable Shadows.", false, m_prefs.enableshadows, "bool"); TCLAP::ValueArg<int> defaultMipMap_arg ("", "defaultmipmap", "Set default mipMap.", false, m_prefs.defaultMipMap, "int"); TCLAP::ValueArg<std::string> shadowtechnique_arg ("", "shadowtechnique", "Set shadow technique.", false, m_prefs.shadowtechnique, "string"); TCLAP::ValueArg<std::string> colourshadow_arg ("", "colourshadow", "Set shadow colour.", false, "", "string"); TCLAP::ValueArg<float> fardistanceshadow_arg ("", "fardistanceshadow", "Set far distance shadow.", false, m_prefs.fardistanceshadow, "float"); TCLAP::ValueArg<std::string> shaderCachePath_arg ("", "shadercachepath", "RTShaderSystem cache file path.", false, m_prefs.shaderCachePath, "string"); cmdl.add(rendersystem_arg); cmdl.add(viewportOrientation_arg); cmdl.add(log_arg); cmdl.add(verbose_arg); cmdl.add(winsize_x_arg); cmdl.add(winsize_y_arg); cmdl.add(wintitle_arg); cmdl.add(fullscreen_arg); cmdl.add(framingType_arg); cmdl.add(resources_arg); cmdl.add(blendermat_arg); cmdl.add(matblending_arg); cmdl.add(grapInput_arg); cmdl.add(debugFps_arg); cmdl.add(debugPhysics_arg); cmdl.add(vsync_arg); cmdl.add(vsyncrate_arg); cmdl.add(debugPhysicsAabb_arg); cmdl.add(buildStaticGeometry_arg); cmdl.add(useBulletDbvt_arg); cmdl.add(showDebugProps_arg); cmdl.add(debugSounds_arg); cmdl.add(disableSound_arg); cmdl.add(fsaa_arg); cmdl.add(fsaaSamples_arg); cmdl.add(enableshadows_arg); cmdl.add(defaultMipMap_arg); cmdl.add(shadowtechnique_arg); cmdl.add(colourshadow_arg); cmdl.add(fardistanceshadow_arg); cmdl.add(shaderCachePath_arg); //input file arguments TCLAP::ValueArg<std::string> cfgfname_arg("c", "config-file", "Startup configuration file (.cfg) to use.", false, gkDefaultConfig, "string"); TCLAP::UnlabeledValueArg<std::string> bfname_arg("blender-file", "Blender file to launch as game.", false, gkDefaultBlend, "string"); cmdl.add(cfgfname_arg); cmdl.add(bfname_arg); cmdl.parse( argc, argv ); cfgfname = cfgfname_arg.getValue(); m_blend = bfname_arg.getValue(); m_prefs.rendersystem = gkUserDefs::getOgreRenderSystem(rendersystem_arg.getValue()); m_prefs.viewportOrientation = viewportOrientation_arg.getValue(); //m_prefs.sceneManager = sceneManager_arg.getValue(); m_prefs.log = log_arg.getValue(); m_prefs.verbose = verbose_arg.getValue(); m_prefs.winsize = gkVector2(winsize_x_arg.getValue(), winsize_y_arg.getValue()); m_prefs.wintitle = wintitle_arg.getValue(); m_prefs.fullscreen = fullscreen_arg.getValue(); m_prefs.framingType = gkUserDefs::getViewportFramingType(framingType_arg.getValue()); m_prefs.resources = resources_arg.getValue(); m_prefs.blendermat = blendermat_arg.getValue(); m_prefs.matblending = matblending_arg.getValue(); m_prefs.grabInput = grapInput_arg.getValue(); m_prefs.debugFps = debugFps_arg.getValue(); m_prefs.debugPhysics = debugPhysics_arg.getValue(); m_prefs.debugPhysicsAabb = debugPhysicsAabb_arg.getValue(); m_prefs.buildStaticGeometry = buildStaticGeometry_arg.getValue(); m_prefs.useBulletDbvt = useBulletDbvt_arg.getValue(); m_prefs.showDebugProps = showDebugProps_arg.getValue(); m_prefs.debugSounds = debugSounds_arg.getValue(); m_prefs.disableSound = disableSound_arg.getValue(); m_prefs.vsync = vsync_arg.getValue(); m_prefs.vsyncRate = vsyncrate_arg.getValue(); m_prefs.fsaa = fsaa_arg.getValue(); m_prefs.fsaaSamples = fsaaSamples_arg.getValue(); m_prefs.enableshadows = enableshadows_arg.getValue(); m_prefs.defaultMipMap = defaultMipMap_arg.getValue(); m_prefs.shadowtechnique = shadowtechnique_arg.getValue(); m_prefs.fardistanceshadow = fardistanceshadow_arg.getValue(); m_prefs.shaderCachePath = shaderCachePath_arg.getValue(); if (colourshadow_arg.isSet()) m_prefs.colourshadow = Ogre::StringConverter::parseColourValue(colourshadow_arg.getValue()); #ifdef __APPLE__ if (m_blend.find("-psn") != gkString::npos) m_blend = gkDefaultBlend; #endif } catch (TCLAP::ArgException& e) { std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; return -1; } catch (TCLAP::ExitException&) { // just return and exit app return -1; } catch (...) { std::cerr << "Unknown exception." << std::endl; return -1; } gkPath path = cfgfname; // overide settings if found if (path.isFile()) m_prefs.load(path.getPath()); return 0; }
gkString gsLogicObject::getUniqueName(void) { if (m_link) return gkString("Brick #") + Ogre::StringConverter::toString(++m_incr); return "Null"; }
void gkFontManager::parseScript(utMemoryStream* buffer) { utScript script; script.parseBuffer("FontManager:parseScript", gkString((const char*)buffer->ptr())); utScriptTree* treePtr = script.getTreePtr(); if (treePtr->getNodes().empty()) return; utScriptTree::Nodes::Iterator niter = treePtr->getNodes().iterator(); while (niter.hasMoreElements()) { utScriptNode* tree = niter.getNext(); if (!tree->hasAttribute("source")) { gkLogMessage("FontManager: Missing font script attribute 'source'"); continue; } const gkString src = tree->getAttribute("source")->getValue(); if (!exists(src)) { gkLogMessage("FontManager: Missing internal font " << src); continue; } const gkString name = tree->getType(); Ogre::FontPtr fp = Ogre::FontManager::getSingleton().getByName(name); if (!fp.isNull()) { // use it return; } gkFont* gkf = (gkFont*)getByName(src); int size = 0, res = UT_NPOS; if (tree->hasAttribute("size")) gkFromString(tree->getAttribute("size")->getValue(), size); if (tree->hasAttribute("resolution")) gkFromString(tree->getAttribute("resolution")->getValue(), res); try { gkFont::Loader* fl = gkf->addLoader(size > 0 && size != UT_NPOS ? size : 12, res != UT_NPOS ? res : 55); fp = Ogre::FontManager::getSingleton().create(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true, fl); fl->setFont(fp.getPointer()); } catch (Ogre::Exception& e) { gkLogMessage("FontManager::parseScript: " << e.getDescription()); } } }