Yake - Community Forum
September 09, 2010, 04:33:48 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the YAKE Project Forums, the place for getting help, providing help and enjoying friendly discussions related to YAKE products.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Running Ogre Code in Yake  (Read 2136 times)
Tomen
Yake Community Support
Jr. Member
*****
Posts: 94


View Profile WWW
« on: October 28, 2008, 12:59:08 PM »

I tried to run the following code:
Code:
void TheMainState::onCreateScene()
{
YAKE_LOG_ERROR("demo","BASH 1");
CreateSphere();
YAKE_LOG_ERROR("demo","BASH 2");
Root root = Root::getSingleton();
YAKE_LOG_ERROR("demo","BASH 3");
SceneManager * SM = root.getSceneManagerIterator().getNext();
YAKE_LOG_ERROR("demo","BASH 4");
SceneNode * rootSN = SM->getRootSceneNode();
YAKE_LOG_ERROR("demo","BASH 5");
SceneNode * pSN = rootSN->createChildSceneNode("SphereNode", Ogre::Vector3(0,0,2));
YAKE_LOG_ERROR("demo","BASH 6");
Entity * pEnt = SM->createEntity("SphereEntity", "Sphere");
YAKE_LOG_ERROR("demo","BASH 7");
pSN->attachObject(pEnt);
YAKE_LOG_ERROR("demo","BASH 8");
}

It runs completely and the last line in raf.log is "BASH 8".
However, the app will crash afterwards. I figured out by commenting out several parts, that the application will also crash with only this code:

Code:
void TheMainState::onCreateScene()
{
Root root = Root::getSingleton();
}

It does not crash on this line exactly, it crashes afterwards.

Anyone has an idea on that?

Greetings,
Tomen
Logged
cdkeito
Sr. Member
****
Posts: 381


View Profile WWW
« Reply #1 on: October 28, 2008, 07:24:37 PM »

mmm....

a classic createscene is:
Code:
virtual void onCreateScene()
{
mSceneMgr = Ogre::Root::getSingleton().getSceneManager("YakeSM");
mpOgreRW = ((yake::graphics::ogre3d::GraphicalWorld *)getGraphicalWorld())->getCore()->getRenderWindow();
vp = mpOgreRW->getViewport(0);
mycamera = getDefaultCamera();

setGUI();

TargetSys = new TargetSystem();

getGraphicalWorld()->setAmbientLight(math::Color(0.1,0.1,0.1));
getGraphicalWorld()->setShadowsEnabled( true );

mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE);
//mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
mSceneMgr->setShadowTextureSelfShadow(true);
mSceneMgr->setShadowTextureSettings(1024, 3);

#ifndef _DEBUG 
Ogre::CompositorInstance* bloominst = Ogre::CompositorManager::getSingleton().addCompositor(vp, "Bloom");
Ogre::CompositorManager::getSingleton().setCompositorEnabled(vp, "Bloom", true);
#endif

...

and a classic include:
Code:
// STL
#include <iostream>
// Yake
#include <yake/base/yake.h>
#include <yake/scripting/yakeScriptingSystem.h>
#include <yake/yappbase/yapp.h>

#include <yake/audio/yakeAudio.h>
#include <yake/raf/yakeRaf.h>
#include <yake/model/model.h>
#include <yake/model/model_link.h>
#include <yake/vehicle/yakeVehicle.h>
#include <yake/input/yakeInput.h>
#include <yake/vehicle/yakeNativeOde.h>
//OGRE
#include "Ogre.h"
#include "OgreTextAreaOverlayElement.h"
#include "OgreInstancedGeometry.h"
//#include <OgreShadowCameraSetupLiSPSM.h>
//ODE
#include "ode.h"
//ODE Plugin
#include "yake/plugins/physicsODE/yakePCH.h"
#include "yake/plugins/physicsODE/PhysicsSystemODE.h"
#include "yake/plugins/physicsODE/OdeWorld.h"
#include "yake/plugins/physicsODE/OdeRay.h"
//OGRE Plugin
#include <yake/plugins/graphicsOgre/yakePCH.h>
#include <yake/plugins/graphicsOgre/yakeGraphicsSystem.h>
#include <yake/plugins/graphicsOgre/yakeGraphicsWorld.h>
#include <yake/plugins/graphicsOgre/graphicsOgreCore.h>
#include <yake/plugins/graphicsOgre/graphicsOgreEntity.h>
//#include <yake/plugins/graphicsOgre/graphicsOgreGeometryAccess.h>
//#include <yake/plugins/graphicsOgre/graphicsOgreLight.h>
//#include <yake/plugins/graphicsOgre/graphicsOgreCamera.h>
//#include <yake/plugins/graphicsOgre/graphicsOgreNode.h>
#include <yake/plugins/graphicsOgre/graphicsOgreParticleSystem.h>
//#include <yake/plugins/graphicsOgre/graphicsOgreSkeleton.h>

#include "noise/noise.h"

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif

static int trueRand(int min, int max) { return (int) ( (double)rand()/(double)RAND_MAX * (max-min) + min ); }

//quicksort
//#include <algorithm>
//#include <iterator>
//#include <functional>
//
//template <typename T>
//void sort(T begin, T end) {  // a[7] ->  sort(a, a+7)
//    if (begin != end) {
//        T middle = partition (begin, end, bind2nd(
//                less<iterator_traits<T>::value_type>(), *begin));
//        sort (begin, middle);
//        sort (max(begin + 1, middle), end);
//    }
//}
////////bool operator<(const Student& a, const Student& b) {
////////    return a.score < b.score;
////////}

if this will not help, post the log
PS: stay alert to not mix stl, ogre and yake's pieces -> unpredictable results -> random crash...
Logged

Tomen
Yake Community Support
Jr. Member
*****
Posts: 94


View Profile WWW
« Reply #2 on: October 29, 2008, 09:26:52 AM »

Thanks so far =)
All i need from Ogre is actually a SceneManager::CreateManual, which will be a manually created (geodesic) sphere.

Do you think will it be possible to only do that in Ogre and stay with Yake at all the other tasks. I think there will be a way to do this.

So far i copied all the includes and the code in a modified version:
Code:
void TheMainState::onCreateScene()
{
Ogre::SceneManager * mSceneMgr = Ogre::Root::getSingleton().getSceneManager("YakeSM");
Ogre::RenderWindow * mpOgreRW = ((yake::graphics::ogre3d::GraphicalWorld *)getGraphicalWorld())->getCore()->getRenderWindow();

getGraphicalWorld()->setAmbientLight(math::Color(0.1,0.1,0.1));
getGraphicalWorld()->setShadowsEnabled( true );

mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE);
//mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
mSceneMgr->setShadowTextureSelfShadow(true);
mSceneMgr->setShadowTextureSettings(1024, 3);
}

I removed some code parts and added the type of the objects for the upper two variables.
I got this linker errors which i am not completely sure how to handle:
Code:
1>------ Build started: Project: Geodesic Sphere, Configuration: Release Win32 ------
1>Compiling...
1>TheMainState.cpp
1>Compiling graphicsOGRE with OSM support.
1>Linking...
1>TheMainState.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class yake::graphics::ogre3d::OgreCore * __thiscall yake::graphics::ogre3d::GraphicalWorld::getCore(void)const " (__imp_?getCore@GraphicalWorld@ogre3d@graphics@yake@@QBEPAVOgreCore@234@XZ)
1>TheMainState.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static class yake::graphics::ogre3d::OgreCore * yake::graphics::ogre3d::GraphicalWorld::msCore" (__imp_?msCore@GraphicalWorld@ogre3d@graphics@yake@@0PAVOgreCore@234@A)
1>TheMainState.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class Ogre::RenderWindow * __thiscall yake::graphics::ogre3d::OgreCore::getRenderWindow(void)const " (__imp_?getRenderWindow@OgreCore@ogre3d@graphics@yake@@QBEPAVRenderWindow@Ogre@@XZ)
1>..\..\bin\\GeoSphere.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://d:\Evolving Universe\-working copy-\Moon Framework\Solution\Geodesic Sphere\Release\BuildLog.htm"
1>Geodesic Sphere - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I didn't get those when OnCreateScene was empty.

PS: I use Yake 0.7
Logged
cdkeito
Sr. Member
****
Posts: 381


View Profile WWW
« Reply #3 on: October 29, 2008, 07:54:25 PM »

each ".h" come with a ".dll"
the error its self is telling you what you need to add. (a sugg: including ogre means also linking it...)

you can do it with yake, think about it more like a glue.
only one thing, the raf class define its own scenemanager "YakeSM", over it with yours.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.066 seconds with 18 queries.