بسم الله الرحمن الرحيم
السلام عليكم ورحمة الله وبركاته
اما بعد فقد طرح قبل ايام الاخ adelbarham محرك الIrrlicht وكافة ملحقاته وكان الموضوع مشوقا للكل وقد لاقى اقبال شديد حتى ان زواره تجاوزوا 500 شخص وقد طلبنا من الاخ adelbarham دروس سريعة ولكن قد يكون مشغول ولا نريد ان نضغط عليه فلذلك قررت انا ان اقوم بترجمة ما اقراه لكم من الامثلة الخاصة بالمحرك مع شرح مبسط لها ...
واتمنى منكم بالمقابل دعوة عن ظهر غيب لاخوكم لكي يفتح الله بوجهه ويتم الله نعمته علي
وبحمد من الله نبدا
اولا :اين اجد تلك الامثلة الTutorials ؟
ستجدها اخي في المجلد ( \examples ) الموجود في فولدر المحرك الرئيسي
ثانيا :كيف سيتم توضيح وشرح الدروس ؟
اخي العزيز ساقوم انا بتجزئة الكود الخاص بالدرس وترجمة التعليقات ال comment الخاصة بكل درس للعربي مع شرح مبسط ان استوجب الامر وعلى النحو التالي
1- ساقوم بنقل الكود باللون الازرق الغامق للتعليقات والفاتح للكود
2- ساقوم بترجمة التعليقات باللون الاخضر الفاتح
3- ساقوم باضافة شرح مبسط باللون البرتقالي الفاتح
طبعا الترجمة ليست حرفية للاختصار والان فالنبدا بالدرس الاول الموجود في المجلد ( 01.HelloWorld ) في داخل المجلد الخاص بالامثلة
قم بفتح الملف example.cbp لتجد الكود التالي
يتبع
السلام عليكم ورحمة الله وبركاته
اما بعد فقد طرح قبل ايام الاخ adelbarham محرك الIrrlicht وكافة ملحقاته وكان الموضوع مشوقا للكل وقد لاقى اقبال شديد حتى ان زواره تجاوزوا 500 شخص وقد طلبنا من الاخ adelbarham دروس سريعة ولكن قد يكون مشغول ولا نريد ان نضغط عليه فلذلك قررت انا ان اقوم بترجمة ما اقراه لكم من الامثلة الخاصة بالمحرك مع شرح مبسط لها ...
واتمنى منكم بالمقابل دعوة عن ظهر غيب لاخوكم لكي يفتح الله بوجهه ويتم الله نعمته علي
وبحمد من الله نبدا
اولا :اين اجد تلك الامثلة الTutorials ؟
ستجدها اخي في المجلد ( \examples ) الموجود في فولدر المحرك الرئيسي
ثانيا :كيف سيتم توضيح وشرح الدروس ؟
اخي العزيز ساقوم انا بتجزئة الكود الخاص بالدرس وترجمة التعليقات ال comment الخاصة بكل درس للعربي مع شرح مبسط ان استوجب الامر وعلى النحو التالي
1- ساقوم بنقل الكود باللون الازرق الغامق للتعليقات والفاتح للكود
2- ساقوم بترجمة التعليقات باللون الاخضر الفاتح
3- ساقوم باضافة شرح مبسط باللون البرتقالي الفاتح
طبعا الترجمة ليست حرفية للاختصار والان فالنبدا بالدرس الاول الموجود في المجلد ( 01.HelloWorld ) في داخل المجلد الخاص بالامثلة
قم بفتح الملف example.cbp لتجد الكود التالي
كود:
[COLOR=RoyalBlue]/* This Tutorial shows how to set up the IDE for using the Irrlicht Engine and how to write a simple HelloWorld program with it. The program will show how to use the basics of the VideoDriver, the GUIEnvironment and the SceneManager. [COLOR=PaleGreen] يقوم هذا المثال بتوضيح كيفية اعداد بيئة البرمجة لاستخدام المحرك وكيفية كتابة برنامج ترحيبي بسيط حيث سوضح هذا البرنامج كيف تستخدم مبادئ الفيديو VideoDriver والواجهة الرسومية لبيئة البرمجة و مدير الشاشة [/COLOR] Microsoft Visual C++ 6.0 and .NET is used as example IDE, but you will also be able to understand everything if you are using a different one or even another operating system than windows. [COLOR=PaleGreen]يستخدم فجوال سي بلس بلس او الدوت نت كمثال لبيئة البرمجة المتكاملة ولكنك ستستطيع ان تفهم اي شيء اذا اردت استخدام بيئة اخرى او حتى نظام تشغيل اخر [/COLOR] To use the engine, we will have to include the header file irrlicht.h, which can be found in the Irrlicht Engine SDK directory \include. [COLOR=PaleGreen]لكي تستخدم المحرك يجب عليك ان تقوم باضافة الهيدر فايل irrlicht.h والذي ستجده في عدة التطوير الخاصة بالمحرك في المجلد include\ [/COLOR] [COLOR=SandyBrown]وتعني عدة تطوير البرنامجSDK Software Development Kit [/COLOR] To let the compiler find this header file, the directory where it is located should be specified somewhere. This is different for every IDE and compiler you use. I explain shortly how to do this in Microsift Visual Studio C++ 6.0 and .NET: [COLOR=PaleGreen]لجعل المترجم يجد الهيدر فايل يجب تحديد المكان الذي يوجد فيه الفايل في مكان ما وهذا الشيء يختلف من بيئة لاخرى ومن مترجم لاخر ولكني ساشرح ذلك على بيئة الفجوال سي بلس بلس والدوت نت [/COLOR] - If you use Version 6.0, select the Menu Extras -> Options. Select the directories tab, and select the 'Include' Item in the combo box. Add the \include directory of the irrlicht engine folder to the list of directories. [COLOR=PaleGreen]اذا كنت تملك الاصدا السادس فقم بالذهاب الى [/COLOR][/COLOR][COLOR=PaleGreen]enu Extras -> Options[/COLOR][COLOR=RoyalBlue][COLOR=PaleGreen] واختر التبويب directory واختر include من القائمة المنسدلة وقم باضافة مسار ال( include\ ) الخاص بالمحرك لقائمة المسارات[/COLOR] Now the compiler will find the Irrlicht.h header file. We also need the irrlicht.lib to be found, so stay in that dialog, select 'Libraries' in the combo box and add the \lib\VisualStudio directory. [COLOR=PaleGreen]والان سيعرف المترجم اين يجد الهيدر فايل ولكننا نحتاج ايضا لربط مكتبة المحرك وهي الفايل [/COLOR][/COLOR][COLOR=PaleGreen]irrlicht.lib فلذلك اختر [/COLOR][COLOR=RoyalBlue][COLOR=PaleGreen]'Libraries' من نفس القائمة المنسدلة اعلاه وضف مسار تلك المكتبة[/COLOR] [COLOR=Wheat][COLOR=SandyBrown]يمكن الاستعاضة عن الخطوة الاخيرة وربط المكتبة باستخدام الpragma comment في داخل الكود كما سنلاحظ بعد قليل[/COLOR] [/COLOR] [/COLOR][COLOR=RoyalBlue] - If your IDE is Visual Studio .NET, select Tools -> Options. Select the projects entry and then select VC++ directories. Select 'show directories for include files' in the combo box, and add the \include directory of the irrlicht engine folder to the list of directories. Now the compiler will find the Irrlicht.h header file. We also need the irrlicht.lib to be found, so stay in that dialog, select 'show directories for Library files' and add the \lib\VisualStudio directory. [COLOR=SandyBrown]لن اشرح الفقرة السابقة لانها لبيئة الدوت نت والتي لا افضلها برمجيا لانها لا تعمل الا بوجود مايكروسوفت فريم ورك[/COLOR] That's it, with your IDE set up like this, you will now be able to develop applications with the Irrlicht Engine. [COLOR=PaleGreen]والان هذا كل ما نحتاجه من اعداد لبيئة البرمجة لانشاء تطبيقات باستخدام هذا المحرك[/COLOR] [COLOR=SandyBrown]والان نبدا بضم الهيدر فايل للمحرك[/COLOR] */[/COLOR] [COLOR=DeepSkyBlue]#include <irrlicht.h>[/COLOR] [COLOR=RoyalBlue]/* In the Irrlicht Engine, everything can be found in the namespace 'irr'. So if you want to use a class of the engine, you have to write an irr:: before the name of the class. For example to use the IrrlichtDevice write: irr::IrrlichtDevice. To get rid of the irr:: in front of the name of every class, we tell the compiler that we use that namespace from now on, and we will not have to write that 'irr::'. [COLOR=PaleGreen]في هذا المحرك فان كل شيء يقع ضمن فضاء الاسم [/COLOR][/COLOR][COLOR=PaleGreen]'irr' لذلك فاذا اردت ان تستخدم فصيل او كلاس المحرك فيجب ان تبدا بالكلاس الاساس عن طريق كتابة [/COLOR][COLOR=PaleGreen]irr:: قبل اسم اي كائن او فصيل فرعي فمثلا لاستخدام الكلاس [/COLOR][COLOR=PaleGreen]IrrlichtDevice فاننا سنكتب [/COLOR][COLOR=PaleGreen]irr::IrrlichtDevice واذا اردنا الاستعاضة عن البدا بالفضاء [/COLOR][COLOR=RoyalBlue][COLOR=PaleGreen]irr:: فاننا نستطيع اخبار المترجم بان يضعها لنا في بداية كل كلاس من خلال الامر التالي [/COLOR] [/COLOR][COLOR=RoyalBlue]*/ [COLOR=DeepSkyBlue]using namespace irr;[/COLOR] /* There are 5 sub namespaces in the Irrlicht Engine. Take a look at them, you can read a detailed description of them in the documentation by clicking on the top menu item 'Namespace List' or using this link: http://irrlicht.sourceforge.net/docu/namespaces.html. Like the irr Namespace, we do not want these 5 sub namespaces now, to keep this example simple. Hence we tell the compiler again that we do not want always to write their names: [COLOR=PaleGreen]اضافة لفضاء الاسم الرئيسي لكلاس المحرك فهناك خمس فضاءات ثانوية حيث تستطيع التعرف عليها من خلال المقال [/COLOR][/COLOR][COLOR=RoyalBlue][COLOR=PaleGreen]http://irrlicht.sourceforge.net/docu/namespaces.html وكما في الفضاء الرئيسي فنحن لا نريد ان نكرر كتابة كل من هذه الفضاءات قبل الكلاسات الفرعية التي تحتويها في كل مرة نستخدم بها تلك الكلاسات الفرعية فاننا سنخبر المترجم بضرورة ضم هذه الفضاءات لنا من جديد وكما يلي [/COLOR] [/COLOR][COLOR=RoyalBlue]*/ [COLOR=DeepSkyBlue]using namespace core; using namespace scene; using namespace video; using namespace io; using namespace gui; [/COLOR] /* To be able to use the Irrlicht.DLL file, we need to link with the Irrlicht.lib. We could set this option in the project settings, but to make it easy, we use a pragma comment lib: [COLOR=SandyBrown]والان سناتي للطريقة الثانية لربط مكتبة المحرك [/COLOR][/COLOR][COLOR=RoyalBlue][COLOR=SandyBrown]Irrlicht.DLL[/COLOR] [COLOR=PaleGreen]ولكي نستطيع ربط [/COLOR][/COLOR][COLOR=PaleGreen]Irrlicht.DLL نحتاج للربط من خلال اما الخيارات المتاحة في اعدادات المشروع في ال IDE او من خلال الموجه [/COLOR][COLOR=RoyalBlue][COLOR=PaleGreen]pragma comment وكما يلي[/COLOR] [/COLOR][COLOR=RoyalBlue]*/ [COLOR=DeepSkyBlue]#ifdef _IRR_WINDOWS_ #pragma comment(lib, "Irrlicht.lib") #endif[/COLOR][/COLOR][COLOR=RoyalBlue] /* This is the main method. We can use int main() on every platform. On Windows platforms, we could also use the WinMain method if we would want to get rid of the console window, which pops up when starting a program with main(), but to keep this example simple, we use main(). */ [COLOR=DeepSkyBlue]int main() {[/COLOR] /* The most important function of the engine is the 'createDevice' function. The Irrlicht Device can be created with it, which is the root object for doing everything with the engine. createDevice() has 7 paramters: deviceType: Type of the device. This can currently be the Null-device, the Software device, the second software renderer, D3D8, D3D9, or OpenGL. In this example we use EDT_SOFTWARE, but to try out, you might want to change it to EDT_BURNINGSVIDEO, EDT_NULL, EDT_DIRECT3D8 , EDT_DIRECT3D9, or EDT_OPENGL. windowSize: Size of the Window or FullscreenMode to be created. In this example we use 640x480. bits: Amount of bits per pixel when in fullscreen mode. This should be 16 or 32. This parameter is ignored when running in windowed mode. fullscreen: Specifies if we want the device to run in fullscreen mode or not. stencilbuffer: Specifies if we want to use the stencil buffer for drawing shadows. vsync: Specifies if we want to have vsync enabled, this is only useful in fullscreen mode. eventReceiver: An object to receive events. We do not want to use this parameter here, and set it to 0. */ [COLOR=DeepSkyBlue]IrrlichtDevice *device = createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16, false, false, false, 0);[/COLOR] /* Set the caption of the window to some nice text. Note that there is a 'L' in front of the string. The Irrlicht Engine uses wide character strings when displaying text. */ [COLOR=DeepSkyBlue]device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo"); [/COLOR] /* Get a pointer to the video driver, the SceneManager and the graphical user interface environment, so that we do not always have to write device->getVideoDriver(), device->getSceneManager() and device->getGUIEnvironment(). */ [COLOR=DeepSkyBlue]IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); [/COLOR] /* We add a hello world label to the window, using the GUI environment. */ [COLOR=DeepSkyBlue]guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!", rect<int>(10,10,260,22), true);[/COLOR] /* To display something interesting, we load a Quake 2 model and display it. We only have to get the Mesh from the Scene Manager (getMesh()) and add a SceneNode to display the mesh. (addAnimatedMeshSceneNode()). Instead of writing the filename sydney.md2, it would also be possible to load a Maya object file (.obj), a complete Quake3 map (.bsp) or a Milshape file (.ms3d). By the way, that cool Quake 2 model called sydney was modelled by Brian Collins. */ [COLOR=DeepSkyBlue]IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2"); IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );[/COLOR] /* To let the mesh look a little bit nicer, we change its material a little bit: We disable lighting because we do not have a dynamic light in here, and the mesh would be totally black. Then we set the frame loop, so that the animation is looped between the frames 0 and 310. And at last, we apply a texture to the mesh. Without it the mesh would be drawn using only a color. */ [COLOR=DeepSkyBlue]if (node) { node->setMaterialFlag(EMF_LIGHTING, false); node->setMD2Animation ( scene::EMAT_STAND ); node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") ); }[/COLOR] /* To look at the mesh, we place a camera into 3d space at the position (0, 30, -40). The camera looks from there to (0,5,0). */ [COLOR=DeepSkyBlue]smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); [/COLOR] /* Ok, now we have set up the scene, lets draw everything: We run the device in a while() loop, until the device does not want to run any more. This would be when the user closed the window or pressed ALT+F4 in windows. */ [COLOR=DeepSkyBlue]while(device->run()) {[/COLOR] /* Anything can be drawn between a beginScene() and an endScene() call. The beginScene clears the screen with a color and also the depth buffer if wanted. Then we let the Scene Manager and the GUI Environment draw their content. With the endScene() call everything is presented on the screen. */ [COLOR=DeepSkyBlue]driver->beginScene(true, true, SColor(255,100,101,140)); [/COLOR] [COLOR=DeepSkyBlue]smgr->drawAll(); guienv->drawAll(); driver->endScene(); }[/COLOR] /* After we are finished, we have to delete the Irrlicht Device created before with createDevice(). In the Irrlicht Engine, you will have to delete all objects you created with a method or function which starts with 'create'. The object is simply deleted by calling ->drop(). See the documentation at http://irrlicht.sourceforge.net//docu/classirr_1_1IUnknown.html#a3 for more information. */ [COLOR=DeepSkyBlue]device->drop(); return 0;[/COLOR] [COLOR=DeepSkyBlue]}[/COLOR] [/COLOR]
يتبع
تعليق