Listing memasukan 2 object melalui ogre
/*
* belajarOgre.cpp
*
* Created on: Mar 13, 2011
* Author: Cahyo
*/
#include "ExampleApplication.h"
class BelajarOgre : public ExampleApplication {
public:
BelajarOgre(){
}
~BelajarOgre(){
}
protected:
virtual void createCamera(void)
{
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Vector3(500,250,50));
mCamera->lookAt(Vector3(0,0,80));
mCamera->setNearClipDistance(5);
}
virtual void createViewports(void)
{
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(1,1,1));
mCamera->setAspectRatio(Real(vp->getActualWidth()) /
Real(vp->getActualHeight()));
}
void createScene(void){
//Light *light;
//mSceneMgr utk manage semua semua yg tampil pd screen
mSceneMgr->setAmbientLight(ColourValue(1,1,1));
mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_ADDITIVE );
//Entity ad objek yg bs dirender discene
Entity *ent1 = mSceneMgr->createEntity("Robot","robot.mesh");
Entity *ent2 = mSceneMgr->createEntity("Robot2","robot.mesh");
ent2->setCastShadows(true);
SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("RobotNode");
SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Robot2Node");
//attach entity ke scenenode ut beri lokasi render robot
node1->attachObject(ent1);
node2->attachObject(ent2);
node2->translate(100,0,0);
}
};
#if 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
{
//bikin objek aplikasi
BelajarOgre app;
try {
app.go();
} catch (Exception e) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox(NULL,e.what(),"Terjadi Error!",MB_OK | MB_ICONERROR |MB_TASKMODAL);
#else
fprintf(stderr,"Terjadi Error = %s\n",e.what());
#endif
}
return 0;
}
Tidak ada komentar:
Posting Komentar