itsalamanca
18-10-2008 18:40:18
hi, my parter and I have a big problem,
first of all my code is this:
We use buffered imput and we are starting to use mygui.
We put de funcion new delegates and it is problematic, we obtend the next mistake:
i probe a lot things and i have not idea.
Somebody can help me????
thanks.
first of all my code is this:
#include <MyGUI.h>
#include <Windows.h>
#include "Ogre.h"
#include "OgreConfigFile.h"
#include "ExampleFrameListener.h"
//#include "ExampleApplication.h"
#include "OgreStringConverter.h"
#include "OgreException.h"
#define OIS_DYNAMIC_LIB
#include <OIS/OIS.h>
#include "OIS/OIS.h"
#if OGRE_COMPILER == OGRE_COMPILER_MSVC
#ifdef _DEBUG
#pragma comment(lib,"OgreMain_d.lib")
#pragma comment(lib,"MyGUI_d.lib")
#pragma comment(lib,"OIS_d.lib")
#else
#pragma comment(lib,"OgreMain.lib")
#pragma comment(lib,"MyGUI.lib")
#pragma comment(lib,"OIS.lib")
#endif
#endif
#ifndef _DEBUG
#define RENDERSYSTEM_D3D "RenderSystem_Direct3D9"
#define RENDERSYSTEM_GL "RenderSystem_GL"
#else
#define RENDERSYSTEM_D3D "RenderSystem_Direct3D9_D"
#define RENDERSYSTEM_GL "RenderSystem_GL_D"
#endif
#define RENDERSYSTEM_D3D_NAME "Direct3D9 Rendering Subsystem"
#define RENDERSYSTEM_GL_NAME "OpenGL Rendering Subsystem"
#include <OIS/OIS.h>
#include <OgreCEGUIRenderer.h>
#define MAX_LONG 0.3
#define MAX_ALTURA 0.4
float longitud;
float altura;
int alto=1;
int pasado=1;
MyGUI::ButtonPtr button;//esto hay que quitarlo de aki.
///////////////////////////////////////////////////////////////////////////////////////////
using namespace Ogre;
class MiFrameListener : public ExampleFrameListener, public OIS::MouseListener, public OIS::KeyListener
{
public:
SceneNode *nodo;
MiFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr, SceneNode *node2)
: ExampleFrameListener(win, cam, true, true, true)
{
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
mDirection = Vector3::ZERO;
}
bool frameStarted(const FrameEvent &evt)
{
if(mMouse)
mMouse->capture();
if(mKeyboard)
mKeyboard->capture();
return mContinue;
}
// MouseListener
bool mouseMoved(const OIS::MouseEvent &e)
{
return true;
}
bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
{
return true;
}
bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
// KeyListener
bool keyPressed(const OIS::KeyEvent &e)
{
return true;
}
bool keyReleased(const OIS::KeyEvent &e)
{
return true;
}
protected:
Real mRotate; // The rotate constant
Real mMove; // The movement constant
SceneManager *mSceneMgr; // The current SceneManager
SceneNode *mCamNode; // The SceneNode the camera is currently attached to
bool mContinue; // Whether to continue rendering or not
Vector3 mDirection; // Value to move in the correct direction
};
class Myclass
{
public:
Root *mRoot;
Camera* mCamera;
SceneManager* mSceneMgr;
ExampleFrameListener* mFrameListener;
RenderWindow* mWindow, *mWindow2;//ver si dos ventanas
Ogre::String mResourcePath;
SceneNode* thisSceneNode;
SceneNode *hijo1;
SceneNode *hijo2, *hijo3, *hijo4, *hijo5, *hijo6, *hijo7;
MyGUI::Gui* mGUI;
Myclass(){}
~Myclass(){}
virtual bool inicializar(void)
{
String pluginsPath;
#ifndef OGRE_STATIC_LIB
pluginsPath = mResourcePath + "plugins.cfg";
#endif
mRoot = new Root(pluginsPath,
mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");
setupResources();
bool carryOn = configure();
if (!carryOn) return false;
chooseSceneManager();
createCamera();
createViewports();
TextureManager::getSingleton().setDefaultNumMipmaps(5);
createResourceListener();
loadResources();
creaMiMenu();
createScene();
createFrameListener();
return true;
}
virtual bool configure(void)
{
if(mRoot->showConfigDialog())
{
mWindow = mRoot->initialise(true);
//mWindow=mRoot->createRenderWindow("general", 400, 300, false,0);
//mWindow->_setPrimary();
//mWindow2=mRoot->createRenderWindow("secundaria",200,300, false,0); //con esta funcion solo creo las dos funciones, ver el uso ke le puedo dar.
return true;
}
else
{
return false;
}
}
virtual void chooseSceneManager(void)
{
mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "ExampleSMInstance");
}
virtual void createCamera(void)
{
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Vector3(0,0,500));
mCamera->lookAt(Vector3(0,0,-300));
mCamera->setNearClipDistance(5);
}
virtual void createFrameListener(void)
{
mFrameListener= new MiFrameListener(mWindow, mCamera, mSceneMgr, hijo4);
mFrameListener->showDebugOverlay(true);
mRoot->addFrameListener(mFrameListener);
}
virtual void createScene(void) {
Light *light;
//mSceneMgr->setAmbientLight( ColourValue( 0, 0, 0 ) );
mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_ADDITIVE );
Entity* ent;
Entity* entidad1= mSceneMgr->createEntity("Cil_base", "Cil_base.mesh");
Entity *entidad2=mSceneMgr->createEntity("Cil_pieza1", "Cil_pieza1.mesh");
Entity *entidad3=mSceneMgr->createEntity("Cil_pieza2", "Cil_pieza2.mesh");
Entity *entidad4=mSceneMgr->createEntity("Cil_pieza3", "Cil_pieza3.mesh");
thisSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
hijo1=thisSceneNode->createChildSceneNode();
entidad1->setCastShadows(true);
hijo1->attachObject(entidad1);
hijo1->setScale(10, 10, 10);
hijo2=hijo1->createChildSceneNode();
entidad2->setCastShadows(true);
hijo2->attachObject(entidad2);
hijo2->pitch(Degree(-90));
hijo2->translate (0, 0.5,0,Ogre::Node::TS_PARENT);
hijo3=hijo2->createChildSceneNode();
entidad3->setCastShadows(true);
hijo3->attachObject(entidad3);
hijo4=hijo3->createChildSceneNode();
entidad4->setCastShadows(true);
hijo4->attachObject(entidad4);
hijo4->translate (0.1, 0,0,Ogre::Node::TS_PARENT);
hijo4->roll(Degree(-180));
Plane plane(Vector3::UNIT_Y, 0);
MeshManager::getSingleton().createPlane("ground",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);
ent = mSceneMgr->createEntity("GroundEntity", "ground");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
ent->setMaterialName("Examples/Rockwall");
ent->setCastShadows(false);
/*
light = mSceneMgr->createLight("Light1");
light->setType(Light::LT_POINT);
light->setPosition(Vector3(0, 150, 250));
light->setDiffuseColour(1, 1.0, 1.0);
light->setSpecularColour(1, 1.0, 1.0);
light = mSceneMgr->createLight("Light3");
light->setType(Light::LT_DIRECTIONAL);
light->setDiffuseColour(1, 1.0, 1.0);
light->setSpecularColour(1, 1.0, 1.0);
light->setDirection(Vector3( 0, -1, 1 ));
light = mSceneMgr->createLight("Light2");
light->setType(Light::LT_SPOTLIGHT);
light->setDiffuseColour(1, 1.0, 1.0);
light->setSpecularColour(1, 1.0, 1.0);
light->setDirection(-1, -1, 0);
light->setPosition(Vector3(0, 300, 0));
light->setSpotlightRange(Degree(35), Degree(50));
*/ //esto solo cuando tenga puesto los fondos.
this->mCamera->lookAt(thisSceneNode->getPosition());
this->mCamera->setPosition(45, 45, 45);
}
virtual void destroyScene(void){}
virtual void createViewports(void)
{
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));
mCamera->setAspectRatio(
Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
virtual void setupResources(void)
{
ConfigFile cf;
cf.load(mResourcePath + "resources.cfg");
ConfigFile::SectionIterator seci = cf.getSectionIterator();
String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
// OS X does not set the working directory relative to the app,
// In order to make things portable on OS X we need to provide
// the loading with it's own bundle path location
ResourceGroupManager::getSingleton().addResourceLocation(
String(macBundlePath() + "/" + archName), typeName, secName);
#else
ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
#endif
}
}
}
virtual void creaMiMenu(void)
{
//ExampleFrameListener *menu;;
mGUI = new MyGUI::Gui();
mGUI->initialise(mWindow,"core.xml","General");
button = mGUI->createWidget<MyGUI::Button>("Button", 100, 100, 300, 26, MyGUI::ALIGN_RIGHT, "Main");
button->eventMouseButtonClick = MyGUI::newDelegate(&mFrameListener, &ExampleFrameListener::mousePressed);
}
virtual void createResourceListener(void)
{
}
virtual void loadResources(void)
{
// Initialise, parse scripts etc
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
virtual void go(void)
{
if (!inicializar())
return;
mRoot->startRendering();
// clean up
destroyScene();
}
};
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow)
{
Myclass app=Myclass();
app.go();
}
We use buffered imput and we are starting to use mygui.
We put de funcion new delegates and it is problematic, we obtend the next mistake:
c:\documents and settings\jose\mis documentos\visual studio 2005\projects\mygui3\main.cpp(326) : error C2780: 'MyGUI::delegates::IDelegate1<TP1> *MyGUI::delegates::newDelegate(void (__cdecl *)(TP1))' : se esperan 1 argumentos; 2 proporcionados
c:\mygui\myguiengine\include\mygui_delegateimplement.h(63) : vea la declaración de 'MyGUI::delegates::newDelegate'
c:\documents and settings\jose\mis documentos\visual studio 2005\projects\mygui3\main.cpp(326) : error C2782: 'MyGUI::delegates::IDelegate1<TP1> *MyGUI::delegates::newDelegate(TObj *,void (__thiscall TObj::* )(TP1))' : el parámetro de plantilla 'TObj' es ambiguo
c:\mygui\myguiengine\include\mygui_delegateimplement.h(72) : vea la declaración de 'MyGUI::delegates::newDelegate'
puede ser 'ExampleFrameListener'
o 'ExampleFrameListener *'
c:\documents and settings\jose\mis documentos\visual studio 2005\projects\mygui3\main.cpp(326) : error C2780: 'MyGUI::delegates::IDelegate2<TP1,TP2> *MyGUI::delegates::newDelegate(void (__cdecl *)(TP1,TP2))' : se esperan 1 argumentos; 2 proporcionados
c:\mygui\myguiengine\include\mygui_delegateimplement.h(63) : vea la declaración de 'MyGUI::delegates::newDelegate'
c:\documents and settings\jose\mis documentos\visual studio 2005\projects\mygui3\main.cpp(326) : error C2782: 'MyGUI::delegates::IDelegate2<TP1,TP2> *MyGUI::delegates::newDelegate(TObj *,void (__thiscall TObj::* )(TP1,TP2))' : el parámetro de plantilla 'TObj' es ambiguo
c:\mygui\myguiengine\include\mygui_delegateimplement.h(72) : vea la declaración de 'MyGUI::delegates::newDelegate'
puede ser 'ExampleFrameListener'
o 'ExampleFrameListener *'
c:\documents and settings\jose\mis documentos\visual studio 2005\projects\mygui3\main.cpp(326) : error C2780: 'MyGUI::delegates::IDelegate3<TP1,TP2,TP3> *MyGUI::delegates::newDelegate(void (__cdecl *)(TP1,TP2,TP3))' : se esperan 1 argumentos; 2 proporcionados
c:\mygui\myguiengine\include\mygui_delegateimplement.h(63) : vea la declaración de 'MyGUI::delegates::newDelegate'
c:\documents and settings\jose\mis documentos\visual studio 2005\projects\mygui3\main.cpp(326) : error C2782: 'MyGUI::delegates::IDelegate3<TP1,TP2,TP3> *MyGUI::delegates::newDelegate(TObj *,void (__thiscall TObj::* )(TP1,TP2,TP3))' : el parámetro de plantilla 'TObj' es ambiguo
c:\mygui\myguiengine\include\mygui_delegateimplement.h(72) : vea la declaración de 'MyGUI::delegates::newDelegate'
puede ser 'ExampleFrameListener'
o 'ExampleFrameListener *'
c:\documents and settings\jose\mis documentos\visual studio 2005\projects\mygui3\main.cpp(326) : error C2780: 'MyGUI::delegates::IDelegate4<TP1,TP2,TP3,TP4> *MyGUI::delegates::newDelegate(void (__cdecl *)(TP1,TP2,TP3,TP4))' : se esperan 1 argumentos; 2 proporcionados
c:\mygui\myguiengine\include\mygui_delegateimplement.h(63) : vea la declaración de 'MyGUI::delegates::newDelegate'
c:\documents and settings\jose\mis documentos\visual studio 2005\projects\mygui3\main.cpp(326) : error C2782: 'MyGUI::delegates::IDelegate4<TP1,TP2,TP3,TP4> *MyGUI::delegates::newDelegate(TObj *,void (__thiscall TObj::* )(TP1,TP2,TP3,TP4))' : el parámetro de plantilla 'TObj' es ambiguo
c:\mygui\myguiengine\include\mygui_delegateimplement.h(72) : vea la declaración de 'MyGUI::delegates::newDelegate'
puede ser 'ExampleFrameListener'
o 'ExampleFrameListener *'
i probe a lot things and i have not idea.
Somebody can help me????
thanks.