I'm commenting my questions, I'm asking about what he did, not what he's about to do, I know you normally comment the other way, but these aren't comments.
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
// I know what he did here, and recognize what it did, I'm just not familiar with programmer comments, I'll just learn it eventualy I suppose.
int main()
{
IrrlichtDevice *device =
#ifdef _IRR_OSX_PLATFORM_
createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#else
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#endif
if (!device)
return 1;
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
//There seem to be allot of commands just thrown at you, so, trying to understand, device is the irrlicht device (the highest class?) and it has a sub command to set the window caption?
IVideoDriver* driver = device->gtVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
//I don't understand pointers quite yet, let me see, so, it's part of the IVideoDriver class and it assigns device->gtVideoDriver(); to driver?
//If this is the case why is IVideoDriver and the astrix needed, I'm not very familiar with pointers.
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);
IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
if (!mesh)
return 1;
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
//Again he's using the pointers, I suppose it's assigning the word mesh the model of sydney? (what does IAnimatedMesh do?) then he creates a node for the mesh and assigns it to the word node?
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
// If there were things from other classes I assume you would have to initiate those too?
driver->endScene();
}
device->drop();
return 0;
}
Understanding Hello World (questions comented)
The Irrlicht device is the device that runs everything. This is the main class of it all. Irrlicht is unusable without the device being initiated.There seem to be allot of commands just thrown at you, so, trying to understand, device is the irrlicht device (the highest class?) and it has a sub command to set the window caption?
setWindowCaption is a function of the Irrlicht device.
You set a variable name (ie, IVideoDriver *driver) so you can simply call driver->doThisFunction() instead of device->getVideoDriver()->doThisFunction().I don't understand pointers quite yet, let me see, so, it's part of the IVideoDriver class and it assigns device->getVideoDriver(); to driver?
device->getVideoDriver() returns type IVideoDriver, of course.
IAnimatedMesh is a mesh, yes. And it cannot do world-specific things like rotate or move. It only contains mesh data.Again he's using the pointers, I suppose it's assigning the word mesh the model of sydney? (what does IAnimatedMesh do?) then he creates a node for the mesh and assigns it to the word node?
IAnimatedMeshSceneNode is the actual world object, and it loads the mesh data from the IAnimatedMesh that gets passed to it. It can do world-specific functions. This is mainly for animated meshes.
IMeshSceneNode handles non-animated meshes.
Those update the visuals of both the user interface and the scene every frame. Anything that would need to be called every frame is put in the mainloop. So yes, if you wanted to do something else like draw2dLine, you would need to call it every frame like he does here.If there were things from other classes I assume you would have to initiate those too?
I hope that helps you some. I explained it the best and simplest way I could, and from what I know. I might have been wrong on some points because I'm programming and was trying to hurry.
Re: Understanding Hello World (questions comented)
You should use the code tag for code in the forum to make it more readable (list of tags is directly above the editfield when writing in the forum).
Check the FAQ in this forum to get links to some webpages which can help you learning c++.
Check the FAQ in this forum to get links to some webpages which can help you learning c++.
The device is the main interface for Irrlicht. setWindowCaption is one of its memberfunctions. You can always check the documenation for what they do (for IrrlichtDevice it is: http://irrlicht.sourceforge.net/docu/cl ... evice.html)namespace wrote: device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
//There seem to be allot of commands just thrown at you, so, trying to understand, device is the irrlicht device (the highest
class?) and it has a sub command to set the window caption?
Well, you better learn about pointers then :-). As short introduction: All variables in c++ have types. That is why you need the IVideoDriver* to tell the compiler the type of the variable driver. The asterisk behind the type declaration tells that you want a special type called "pointer" which can contain the address of an object of the type which is in front of the asterisk. The assignment is just that - wouldn't even have to be in the same line.namespace wrote: IVideoDriver* driver = device->gtVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
//I don't understand pointers quite yet, let me see, so, it's part of the IVideoDriver class and it assigns device->gtVideoDriver(); to driver?
//If this is the case why is IVideoDriver and the astrix needed, I'm not very familiar with pointers.
Yeah - mesh contains the model data and is loaded here from a file. Every SceneNode contains a 3D position and rotation and AnimatedMeshSceneNode is a special node which also can contains an animated mesh which will be displayed at the given position.namespace wrote: IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
if (!mesh)
return 1;
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
//Again he's using the pointers, I suppose it's assigning the word mesh the model of sydney? (what does IAnimatedMesh do?) then he creates a node for the mesh and assigns it to the word node?
Not sure what you mean. If you refer to the mainloop - it already does most of the stuff you will need for a while.namespace wrote: // If there were things from other classes I assume you would have to initiate those too?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Actually it returns type IVideoDriver*cobra wrote: device->getVideoDriver() returns type IVideoDriver, of course.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Understanding texture mapping
Does anyone knows a good tutorial (possibly for GIMP) for understanding how to create BMP textures and bind them to 3d objects? I mean.. lookin at the file sydney.bmp i can't uderstand how the texture pieces are assigned tho the meshes when loaded in Irrlicht.
ty
ty
Re: Understanding texture mapping
google for UV Mappingmarmz wrote:Does anyone knows a good tutorial (possibly for GIMP) for understanding how to create BMP textures and bind them to 3d objects? I mean.. lookin at the file sydney.bmp i can't uderstand how the texture pieces are assigned tho the meshes when loaded in Irrlicht.
ty
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info