#import "WWSViewController.h"
@implementation WWSViewController {
IrrlichtDevice *device;
}
- (void)viewDidLoad
{
[super viewDidLoad];
device = createDevice( video::EDT_OGLES1, dimension2d<u32>(640, 480), 16, false, false, false, 0);
NSString *oBunPath = [[NSBundle mainBundle] bundlePath];
device->getFileSystem()->changeWorkingDirectoryTo([oBunPath cStringUsingEncoding:NSASCIIStringEncoding]);
}
- (void)clickedFirstScene:(id)sender
{
if (!device)
return;
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);
IAnimatedMesh* mesh = smgr->getMesh("Ressources/media/sydney.md2");
if (!mesh) {
device->drop();
return;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node) {
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("Ressources/media/sydney.bmp") );
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
CADisplayLink *displayLink = [[UIScreen mainScreen] displayLinkWithTarget:self selector:@selector(updateDisplay)];
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
}
- (void)updateDisplay
{
if (device != nil) {
SExposedVideoData viewData((__bridge void*)firstSceneView);
device->getVideoDriver()->beginScene(true, true, SColor(255, 100, 101, 140), viewData);
device->getSceneManager()->drawAll();
device->getGUIEnvironment()->drawAll();
device->getVideoDriver()->endScene();
}
}
I2ltcG9ydCAiV1dTVmlld0NvbnRyb2xsZXIuaCIKCkBpbXBsZW1lbnRhdGlvbiBXV1NWaWV3Q29udHJvbGxlciB7CiAgICBJcnJsaWNodERldmljZSAqZGV2aWNlOwp9CgotICh2b2lkKXZpZXdEaWRMb2FkCnsKICAgIFtzdXB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