12.07.2015 Views

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

API IntroductionThis section briefly introduces the Irrlicht C++ API. As this is only an overview, it is recommended<strong>to</strong> refer <strong>to</strong> the complete API 4 for detailed descriptions. The Irrlicht API classes are assigned <strong>to</strong> severalnamespaces. All parts <strong>of</strong> Irrlicht are in the <strong>to</strong>p level namespace irr which has the sub-namespacesirr::core, irr::gui, irr::io, irr::scene and irr::video. In the following, there will be no references<strong>to</strong> the namespaces <strong>of</strong> the particular classes; again, refer <strong>to</strong> the complete documentation for anydetails.The core class <strong>of</strong> the Irrlicht API is IrrlichtDevice. Each application using Irrlicht usually creates oneinstance <strong>of</strong> that class. Instances are created using the function createDevice. createDevice has severaloptional parameters <strong>of</strong> which the most important allow specifying the 3D device type (i.e., whether <strong>to</strong>use s<strong>of</strong>tware rendering, Direct3D, OpenGL or none), window size and color depth. An IrrlichtDeviceobject holds a video driver (IVideoDriver) and a scene manager (ISceneManager) object.The ISceneManager object represents the virtual scene that is <strong>to</strong> be rendered. A scene containsany number <strong>of</strong> scene nodes (ISceneNode). Subclasses <strong>of</strong> ISceneNode implement the various scenenode specializations, e.g., meshes, animated meshes, terrain, text, light sources and cameras. A newscene node is added using one <strong>of</strong> many corresponding ISceneManager methods <strong>of</strong> which most arenamed add...SceneNode. For instance, ISceneManager::addMeshSceneNode adds a mesh scene nodefrom a mesh (IMesh) that can easily be loaded from a file using ISceneManager::getMesh. Differentkinds <strong>of</strong> animations (e.g., movements, rotations or delayed deletes) can be realized by assigningISceneNodeAnima<strong>to</strong>rs <strong>to</strong> scene nodes.To be able <strong>to</strong> render the scene, it is necessary <strong>to</strong> have a camera scene node. Such is added usingaddCameraSceneNode or one <strong>of</strong> the two specialized versions addCameraSceneNodeFPS and addCamera-SceneNodeMaya which already support basic user control.IVideoDriver is used <strong>to</strong> control anything related <strong>to</strong> the screen. For rendering the scene, you first have<strong>to</strong> call IVideoDriver::beginScene, then ISceneManager::drawAll and finally IVideoDriver::endScenewhich results in the presentation <strong>of</strong> the rendered image on the screen. Besides drawing the whole scene,it is also possible <strong>to</strong> perform direct 2D or 3D drawing <strong>to</strong> the video driver object between the beginSceneand endScene calls. Loading textures is also done via the video driver.For processing 3D geometry, Irrlicht provides an extensive library <strong>of</strong> optimized geometric functions.One important exemplary structure is the (3D) vec<strong>to</strong>r. The vec<strong>to</strong>r3d class (T is the element datatype, ususally float or double) provides various methods including simple addition, multiplication,length and distance, but also some angle computation.User input is passed <strong>to</strong> the application through the IEventReceiver interface. An application implementsthat interface and registers itself using IrrlichtDevice::setEventReceiver. There are differentevent categories: GUI events (e.g., a but<strong>to</strong>n is clicked), joystick events, key input events, log events,mouse input events, and user events. So for example processing mouse events allows the application <strong>to</strong>react on mouse input.Finally, Irrlicht provides a simple GUI environment for creating dialogs etc. The predefined controlsinclude but<strong>to</strong>ns, check boxes, lists, combo boxes and scroll bars. The GUI API also includes 2D imageand text rendering functionality.2.5.2 CUSPCUSP (Channel-based Unidirectional Stream Pro<strong>to</strong>col) [33] is a transport pro<strong>to</strong>col initially developed forBubbleS<strong>to</strong>rm but available for any application. BubbleS<strong>to</strong>rm originally used TCP as its transport pro<strong>to</strong>colbut TCP has soon shown <strong>to</strong> be <strong>to</strong>o far from optimal for BubbleS<strong>to</strong>rm. Firstly, BubbleS<strong>to</strong>rm requires amessage passing pro<strong>to</strong>col. But unlike plain UDP, messages have <strong>to</strong> be delivered reliably, and UDP does4 http://irrlicht.sourceforge.net/docu/32 2.5 <strong>Implementation</strong>-relevant Technologies

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!