Tuesday, January 22, 2013

Listing Ogre3d Sederhana

#include "ExampleApplication.h"

class TutorialApplication : public ExampleApplication {
protected:
public:
TutorialApplication()
{
}

~TutorialApplication()
{
}
protected:

void createScene(void)
{
mSceneMgr->setAmbientLight( ColourValue( 1, 1, 1 ) );
Entity *ent1 = mSceneMgr->createEntity( "Robot", "robot.mesh" );
SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode" );
node1->attachObject( ent1 );

Entity *ent2 = mSceneMgr->createEntity( "Zombie", "zombie.mesh" );
SceneNode *node2 = mSceneMgr->getRootSceneNode()->
            createChildSceneNode( "Zombie", Vector3( 70, 70, 0 ));
node2->attachObject( ent2 );

Entity *ent3 = mSceneMgr->createEntity( "Ninja", "ninja.mesh" );
SceneNode *node3 = mSceneMgr->getRootSceneNode()->
            createChildSceneNode( "Ninja", Vector3( -70, -70, 0 ));
node3->attachObject( ent3 );

}
};

#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
TutorialApplication app;

try {
app.go();
} catch(Exception& e) {
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occurred: %s\n",
e.getFullDescription().c_str());
#endif
}

return 0;
}

tampilan outputnya :

No comments:

Post a Comment