Show main.cpp syntax highlighted
#include "ExampleApplication.h"
/*jp*/
using namespace std;
class JPListener : public ExampleFrameListener
{
public:
JPListener(RenderWindow* win, Camera* cam, SceneNode *sn, Entity *ent, Entity *ent1) :
ExampleFrameListener(win, cam, false, false), mNode(sn), mEntity(ent), mEntity1(ent1)
{
mAnimationState = ent->getAnimationState( "Bounce" );
mAnimationState->setLoop( true );
mAnimationState->setEnabled( true );
mAnimationState1 = ent1->getAnimationState( "Action" );
mAnimationState1->setLoop( true );
mAnimationState1->setEnabled( true );
}
bool frameStarted(const FrameEvent &evt)
{
mAnimationState->addTime( evt.timeSinceLastFrame );
mAnimationState1->addTime( evt.timeSinceLastFrame );
return ExampleFrameListener::frameStarted(evt);
}
protected:
AnimationState *mAnimationState; // The current animation state of the object
AnimationState *mAnimationState1; // The current animation state of the object
Entity *mEntity; // The Entity we are animating
Entity *mEntity1; // The Entity we are animating
SceneNode *mNode; // The SceneNode that the Entity is attached to
};
/*jp*/
class liafail : public ExampleApplication
{
public:
liafail()
{
}
~liafail()
{
}
protected:
void chooseSceneManager(void)
{
mSceneMgr = mRoot->createSceneManager(ST_EXTERIOR_CLOSE);
}
virtual void createCamera(void)
{
mCamera = mSceneMgr->createCamera("Camara");
mCamera->setPosition(Vector3(0,300,0));
mCamera->lookAt(Vector3(500,50,500));
mCamera->setNearClipDistance(5);
}
virtual void createViewports(void)
{
Viewport* ventanapuerto = mWindow->addViewport(mCamera);
ventanapuerto->setBackgroundColour(ColourValue( 0.0,0.0,0.0));
mCamera->setAspectRatio(Real(ventanapuerto->getActualWidth()) / Real(ventanapuerto->getActualHeight()));
}
Entity *pera;
Entity *cubo;
void createScene(void)
{
mSceneMgr->setWorldGeometry( "playa.cfg" );
mSceneMgr->setAmbientLight( ColourValue( 0.0, 0.0, 0.0 ) );
mSceneMgr->setShadowTechnique( SHADOWTYPE_TEXTURE_MODULATIVE );
//mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_MODULATIVE );
//mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_ADDITIVE );
pera = mSceneMgr->createEntity( "pip", "pip.mesh" );
cubo = mSceneMgr->createEntity( "cubo", "Cube.mesh" );
pera->setCastShadows( true );
cubo->setCastShadows( true );
SceneNode *player = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Player");
player->translate( Vector3( 550, 100, 550 ) );
player->attachObject( pera );
player->yaw(Degree(-45));
player->scale(.5,.5,.5);
SceneNode *player2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Player2");
player2->translate( Vector3( 550, 100, 350 ) );
player2->attachObject( cubo );
player2->yaw(Degree(-45));
player2->scale(.5,.5,.5);
Light *light;
light = mSceneMgr->createLight( "sol" );
light->setType( Light::LT_SPOTLIGHT );
light->setDiffuseColour( 1.0, 1.0, 1.0 );
light->setSpecularColour( 1.0, 1.0, 1.0 );
light->setDirection( 1000, 0, 1000 );
light->setPosition( Vector3( 0, 300, 0 ) );
light->setSpotlightRange( Degree(35), Degree(60) );
}
/*jp*/
SceneNode *mNode; // The SceneNode of the object we are moving
void createFrameListener(void)
{
mFrameListener= new JPListener(mWindow, mCamera, mNode, pera, cubo);
mFrameListener->showDebugOverlay(true);
mRoot->addFrameListener(mFrameListener);
}
};
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
// Create application object
liafail app;
try{
app.go();
}
catch( Exception & e ) {
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occured: %s\n", e.getFullDescription().c_str());
#endif
}
return 0;
}
See more files for this project here