качаем Irrlicht(далее иррлихт) и IrrPhysX(далее иррфизикс) и PhysX SDK не забудьте.и не забудьте поставить сам драйвер ссылки для скачки(если всётаки ещё не скачали) http://irrphysx.at.ua/publ/1-1-0-2 качаем,архивы с иррлихт и иррфизикс распаковываем в 2 разные(!) папки качаем http://irrphysx.at.ua/load/prostoj_variant_nastrojki/1-1-0-4 распаковываем видим 2 папки - lib и include запихивает в иррлихт спросит "заменить?" надавите "да для всех" открываем любой проэкт.я ,например,открыл проэкт quake3map.он будет использоватся и модифицироватся в следующих статьях,поэтому рекомендую сделать тоже-самое. добавляем в начале кода "#include <IrrPhysx.h>" вот что должно было получится Code #include <irrlicht.h> #include <iostream> #include <IrrPhysx.h>
после добавляем ещё "using namespace IrrPhysx;" Code using namespace irr;using namespace IrrPhysx; и добавляем ещё Code #pragma comment(lib, "IrrPhysX.lib") #pragma comment(lib, "PhysXLoader.lib")
весь код - Code /** Example 002 Quake3Map
This Tutorial shows how to load a Quake 3 map into the engine, create a SceneNode for optimizing the speed of rendering, and how to create a user controlled camera.
Please note that you should know the basics of the engine before starting this tutorial. Just take a short look at the first tutorial, if you haven't done this yet: http://irrlicht.sourceforge.net/tut001.html
Lets start like the HelloWorld example: We include the irrlicht header files and an additional file to be able to ask the user for a driver type using the console. */ #include <irrlicht.h> #include <iostream> #include <IrrPhysx.h>
/* As already written in the HelloWorld example, in the Irrlicht Engine everything can be found in the namespace 'irr'. 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::'. There are 5 other sub namespaces 'core', 'scene', 'video', 'io' and 'gui'. Unlike in the HelloWorld example, we do not call 'using namespace' for these 5 other namespaces, because in this way you will see what can be found in which namespace. But if you like, you can also include the namespaces like in the previous example. */ using namespace irr; using namespace IrrPhysx;
/* Again, 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: */ #ifdef _MSC_VER #pragma comment(lib, "Irrlicht.lib") #pragma comment(lib, "IrrPhysX.lib") #pragma comment(lib, "PhysXLoader.lib") #endif
/* Ok, lets start. Again, we use the main() method as start, not the WinMain(). */ int main() { /* Like in the HelloWorld example, we create an IrrlichtDevice with createDevice(). The difference now is that we ask the user to select which video driver to use. The Software device might be too slow to draw a huge Quake 3 map, but just for the fun of it, we make this decision possible, too. */
// ask user for driver
video::E_DRIVER_TYPE driverType;
printf("Please select the driver you want for this example:\n"\ " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\ " (d) Software Renderer\n (e) Burning's Software Renderer\n"\ " (f) NullDevice\n (otherKey) exit\n\n");
char i; std::cin >> i;
switch(i) { case 'a': driverType = video::EDT_DIRECT3D9;break; case 'b': driverType = video::EDT_DIRECT3D8;break; case 'c': driverType = video::EDT_OPENGL; break; case 'd': driverType = video::EDT_SOFTWARE; break; case 'e': driverType = video::EDT_BURNINGSVIDEO;break; case 'f': driverType = video::EDT_NULL; break; default: return 1; }
// create device and exit if creation failed
IrrlichtDevice *device = createDevice(driverType, core::dimension2d<s32>(640, 480));
if (device == 0) return 1; // could not create selected driver.
/* Get a pointer to the video driver and the SceneManager so that we do not always have to call irr::IrrlichtDevice::getVideoDriver() and irr::IrrlichtDevice::getSceneManager(). */ video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* smgr = device->getSceneManager();
/* To display the Quake 3 map, we first need to load it. Quake 3 maps are packed into .pk3 files which are nothing else than .zip files. So we add the .pk3 file to our irr::io::IFileSystem. After it was added, we are able to read from the files in that archive as if they are directly stored on the disk. */ device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
/* Now we can load the mesh by calling irr::scene::ISceneManager::getMesh(). We get a pointer returned to an irr::scene::IAnimatedMesh. As you might know, Quake 3 maps are not really animated, they are only a huge chunk of static geometry with some materials attached. Hence the IAnimatedMesh consists of only one frame, so we get the "first frame" of the "animation", which is our quake level and create an OctTree scene node with it, using irr::scene::ISceneManager::addOctTreeSceneNode(). The OctTree optimizes the scene a little bit, trying to draw only geometry which is currently visible. An alternative to the OctTree would be a irr::scene::IMeshSceneNode, which would always draw the complete geometry of the mesh, without optimization. Try it: Use irr::scene::ISceneManager::addMeshSceneNode() instead of addOctTreeSceneNode() and compare the primitives drawn by the video driver. (There is a irr::video::IVideoDriver::getPrimitiveCountDrawn() method in the irr::video::IVideoDriver class). Note that this optimization with the OctTree is only useful when drawing huge meshes consisting of lots of geometry. */ scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp"); scene::ISceneNode* node = 0; if (mesh) node = smgr->addOctTreeSceneNode(mesh->getMesh(0), 0, -1, 1024); // node = smgr->addMeshSceneNode(mesh->getMesh(0));
/* Because the level was not modelled around the origin (0,0,0), we translate the whole level a little bit. This is done on irr::scene::ISceneNode level using the methods irr::scene::ISceneNode::setPosition() (in this case), irr::scene::ISceneNode::setRotation(), and irr::scene::ISceneNode::setScale(). */ if (node) node->setPosition(core::vector3df(-1300,-144,-1249));
/* Now we only need a camera to look at the Quake 3 map. We want to create a user controlled camera. There are some cameras available in the Irrlicht engine. For example the MayaCamera which can be controlled like the camera in Maya: Rotate with left mouse button pressed, Zoom with both buttons pressed, translate with right mouse button pressed. This could be created with irr::scene::ISceneManager::addCameraSceneNodeMaya(). But for this example, we want to create a camera which behaves like the ones in first person shooter games (FPS) and hence use irr::scene::ISceneManager::addCameraSceneNodeFPS(). */ smgr->addCameraSceneNodeFPS();
/* The mouse cursor needs not be visible, so we hide it via the irr::IrrlichtDevice::ICursorControl. */ device->getCursorControl()->setVisible(false);
/* We have done everything, so lets draw it. We also write the current frames per second and the primitives drawn into the caption of the window. The test for irr::IrrlichtDevice::isWindowActive() is optional, but prevents the engine to grab the mouse cursor after task switching when other programs are active. The call to irr::IrrlichtDevice::yield() will avoid the busy loop to eat up all CPU cycles when the window is not active. */ int lastFPS = -1;
while(device->run()) { if (device->isWindowActive()) { driver->beginScene(true, true, video::SColor(255,200,200,200)); smgr->drawAll(); driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps) { core::stringw str = L"Irrlicht Engine - Quake 3 Map example ["; str += driver->getName(); str += "] FPS:"; str += fps;
device->setWindowCaption(str.c_str()); lastFPS = fps; } } else device->yield(); }
/* In the end, delete the Irrlicht device. */ device->drop(); return 0; }
/* That's it. Compile and play around with the program. **/
теперь нужно указать проэкту путь к заголовочным файлам установленного вами PhysX SDK для этого давим "проэкт->свойства" в Tree-Viev контролле разворачиваем ветку "свойства конфигурации",ищем ветку "C++" давим на неё.чуть правее видим "дополнительные каталоги включения",а в поле запись "..\..\include". добавляем ";" и путь к заголовочным файлам SDK.я поставил SDK на диск C я получил строку Code ..\..\include;"C:\Program Files\NVIDIA Corporation\NVIDIA PhysX SDK\v2.8.1\SDKs\Foundation\include";"C:\Program Files\NVIDIA Corporation\NVIDIA PhysX SDK\v2.8.1\SDKs\Physics\include" теперь остаётся скомпилить полученный проэкт...выбираем в опциях построения режим "release" и нажать на зелёную стрелочку) если вы поставили себе PhysX и если вы правильно добавили все файлы и написали всё как надо,то проэкт будет успешно построен лог построения Code 1>------ Перестроение всех файлов начато: проект: 02.Quake3Map, Конфигурация: Release Win32 ------ 1>Удаление промежуточных и выходных файлов проекта "02.Quake3Map", конфигурации "Release|Win32" 1>Компиляция... 1>main.cpp 1>Компоновка... 1>Внедрение манифеста... 1>Журнал построения был сохранен в "file://h:\site articles\irrlicht-1.5\examples\02.Quake3Map\Release\BuildLog.htm" 1>02.Quake3Map - ошибок 0, предупреждений 0 ========== Перестроение всех: успешно: 1, с ошибками: 0, пропущено: 0 ==========
лог отладки Code "02.Quake3Map.exe": Загружено: "H:\site articles\irrlicht-1.5\bin\Win32-VisualStudio\02.Quake3Map.exe", Двоичный код не был построен с отладочной информацией. "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\ntdll.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\kernel32.dll" "02.Quake3Map.exe": Загружено: "H:\site articles\irrlicht-1.5\bin\Win32-VisualStudio\Irrlicht.dll", Двоичный код не был построен с отладочной информацией. "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\user32.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\gdi32.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\advapi32.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\rpcrt4.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\secur32.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\opengl32.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\msvcrt.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\glu32.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\ddraw.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\dciman32.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\winmm.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\imm32.dll" Irrlicht Engine version 1.5 Microsoft Windows XP Professional Service Pack 3 (Build 2600) "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\uxtheme.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\msctf.dll" "02.Quake3Map.exe": Загружено: "C:\Program Files\Unlocker\UnlockerHook.dll", Двоичный код не был построен с отладочной информацией. "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\shlwapi.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\shell32.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\comctl32.dll" "02.Quake3Map.exe": Загружено "C:\Program Files\Alwil Software\Avast4\AhJsctNs.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\version.dll" "02.Quake3Map.exe": Выгружено: "C:\WINDOWS\system32\version.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\msctfime.ime" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\ole32.dll" Using renderer: Direct3D 9.0 "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\d3d9.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\d3d8thk.dll" "02.Quake3Map.exe": Загружено "C:\WINDOWS\system32\version.dll" NVIDIA GeForce 8600 GTS nv4_disp.dll 6.14.11.8250 Loaded shader: scripts/common.shader for scripts/common.shader Loaded shader: scripts/models.shader for scripts/models.shader Loaded texture: textures/common/caulk Loaded texture: textures/e7/e7walldesign01b Loaded texture: textures/e7/e7steptop2 Loaded texture: noshader Loaded texture: textures/e7/e7dimfloor Loaded texture: textures/e7/e7brickfloor01 Loaded texture: textures/e7/e7bmtrim Loaded texture: textures/e7/e7sbrickfloor Loaded texture: textures/e7/e7brnmetal Loaded texture: textures/common/clip Loaded texture: textures/e7/e7beam02_red Loaded texture: textures/e7/e7swindow Loaded texture: textures/e7/e7bigwall Loaded texture: textures/e7/e7panelwood Loaded texture: textures/e7/e7beam01 Loaded texture: textures/gothic_floor/xstepborder5 Loaded texture: textures/liquids/lavahell Loaded texture: textures/e7/e7steptop Loaded texture: textures/gothic_trim/metalblackwave01 Loaded texture: textures/stone/pjrock1 Loaded texture: textures/skies/tim_hell Loaded texture: textures/common/hint Loaded texture: models/mapobjects/timlamp/timlamp Loaded texture: textures/sfx/flame1side Loaded texture: textures/sfx/flame2 Loaded texture: models/mapobjects/gratelamp/gratetorch2 Loaded texture: models/mapobjects/gratelamp/gratetorch2b Loaded shader: scripts/e7.shader for textures/e7/e7walldesign01b Loaded shader: scripts/sfx.shader for textures/sfx/flame1side Loaded texture: textures/e7/e7walldesign01b.jpg Loaded texture: textures/e7/e7steptop2.jpg Loaded texture: textures/e7/e7dimfloor.jpg Loaded texture: textures/e7/e7brickfloor01.jpg Loaded texture: textures/e7/e7bmtrim.jpg Loaded texture: textures/e7/e7sbrickfloor.jpg Loaded texture: textures/e7/e7brnmetal.jpg Loaded texture: textures/e7/e7beam02_red.jpg Loaded texture: textures/e7/e7swindow.jpg Loaded texture: textures/e7/e7bigwall.jpg Loaded texture: textures/e7/e7panelwood.jpg Loaded texture: textures/e7/e7beam01.jpg Loaded texture: textures/gothic_floor/xstepborder5.jpg Loaded texture: textures/liquids/lavahell.jpg Loaded texture: textures/e7/e7steptop.jpg Loaded texture: textures/gothic_trim/metalblackwave01.jpg Loaded texture: textures/stone/pjrock1.jpg Loaded texture: models/mapobjects/timlamp/timlamp.tga Loaded texture: models/mapobjects/gratelamp/gratetorch2.jpg Loaded texture: models/mapobjects/gratelamp/gratetorch2b.tga Loaded mesh: 20kdm2.bsp Needed 18ms to create OctTree SceneNode.(92 nodes, 10684 polys) Программа "[5212] 02.Quake3Map.exe: Машинный код" завершилась с кодом 0 (0x0).
ссылка для скачки исходников проэкта тут
|