#include "ExampleApplication.h"
class TutorialApplication : public ExampleApplication
{
protected:
public:
TutorialApplication()
{
}
~TutorialApplication()
{
}
protected:
virtual void createCamera(void)
{
//membuat kamera
mCamera = mSceneMgr->createCamera("PlayerCam");
//posisi dan arah kamera
mCamera->setPosition(Vector3(0,10,500));
mCamera->lookAt(Vector3(0,0,0));
//mengatur jarak kliping terdekat
mCamera->setNearClipDistance(10);
}
virtual void createViewports(void)
{
//membuat satu viewport untuk seluruh window
Viewport* vp = mWindow->addViewport(mCamera);
//mengatur warna background viewport
vp->setBackgroundColour(ColourValue(1.0,1.0,1.0));
//mengatur rasio kamera
mCamera->setAspectRatio(Real (vp->getActualWidth()) / Real (vp->getActualHeight()));
}
void createScene(void)
{
//mSceneMgr utk manage semua semua yg tampil pd screen
mSceneMgr->setAmbientLight(ColourValue(1,1,1));
//Entity ad objek yg bs dirender discene
Entity *nin1 = mSceneMgr->createEntity("house","tudorhouse.mesh");
SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("node1",Vector3(0, 43, 0));
node1->attachObject(nin1);
node1->setScale(0.08, 0.08, 0.08);
Entity *nin2 = mSceneMgr->createEntity("house2","tudorhouse.mesh");
SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("node2",Vector3(100, 43, 0));
node2->attachObject(nin2);
node2->setScale(0.08, 0.08, 0.08);
Entity *nin3 = mSceneMgr->createEntity("house3","tudorhouse.mesh");
SceneNode *node3 = mSceneMgr->getRootSceneNode()->createChildSceneNode("node3",Vector3(200, 43, 0));
node3->attachObject(nin3);
node3->setScale(0.08, 0.08, 0.08);
Entity *nin4 = mSceneMgr->createEntity("ninja","ninja.mesh");
SceneNode *node4 = mSceneMgr->getRootSceneNode()->createChildSceneNode("node4",Vector3(0, 0, 30));
node4->attachObject(nin4);
node4->yaw(Degree(180));
node4->setScale(0.05, 0.05, 0.05);
Entity *nin5 = mSceneMgr->createEntity("ninja2","ninja.mesh");
SceneNode *node5 = mSceneMgr->getRootSceneNode()->createChildSceneNode("node5",Vector3(100, 0, 30));
node5->attachObject(nin5);
node5->yaw(Degree(180));
node5->setScale(0.05, 0.05, 0.05);
Entity *nin6 = mSceneMgr->createEntity("ninja3","ninja.mesh");
SceneNode *node6 = mSceneMgr->getRootSceneNode()->createChildSceneNode("node6",Vector3(200, 0, 30));
node6->attachObject(nin6);
node6->yaw(Degree(180));
node6->setScale(0.05, 0.05, 0.05);
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);//plane selebar w=1500 h=1500
Entity *rumput = mSceneMgr->createEntity("GroundEntity","ground");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(rumput);
rumput->setMaterialName("Examples/GrassFloor");
rumput->setCastShadows(false);
mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000);
ParticleSystem *power = mSceneMgr->createParticleSystem ("Power", "Examples/Snow");
SceneNode *powerNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
powerNode->attachObject(power);
powerNode->setPosition(100,50,50);
ParticleSystem *back = mSceneMgr->createParticleSystem ("Back", "Examples/Snow");
SceneNode *backNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
backNode->attachObject(back);
}
};
#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
MessageBox( 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;
}
outputnya kayak gini :
0 komentar:
Posting Komentar