1 / 29

Programming Basics

Programming Basics. Tae Soo, Yun Division of Internet Engineering Dongseo University. Introduction to NetImmerse. NetImmerse is an object-oriented C++ 3D game engine for the following platforms: Windows(9x, Me,NT,2000,XP) Playstation2, Xbox, GameCube

noreen
Download Presentation

Programming Basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Basics Tae Soo, Yun Division of Internet Engineering Dongseo University

  2. Introduction to NetImmerse • NetImmerse is an object-oriented C++ 3D game engine for the following platforms: • Windows(9x, Me,NT,2000,XP) • Playstation2, Xbox, GameCube • NetImmerse consists of 3 main component: • A set of plugins • A set of tools • C++ run-time library

  3. Introduction to NetImmerse • Functions • Hierarchical scene graph representaion • Integration with major 3D modeling tools • Efficient visible object culling • Support for advanced 3D h/w acceleration on all platforms • High-end texturing and rendering effects • Integration with the Havok physics engine • Dynamic collision detection • Support for 3D Audio • LOD representation • Flexible rendering, sorting, and culling methods

  4. Introduction to Object Systems • NiRefObject is a base class • The [derived] classes support smart pointers, RTTI, cloning, streaming and viewer string, names, extra data, and time controllers • The hierarchy of NiObject-derived classes

  5. Inheritance Structure

  6. Inheritance Structure • Most of classes are inherited form NiObject • NiObject supports referencing counting • Allows NetImmerse to use a hierarchical scene graph,which allows app. to create nested coordinate sys.(for articulated objects,etc) and specify rendering properties(e.g. texture mapping, fogging) • The HSG allows NetImmerse to do automatic run-time culling of geometry

  7. Object System: RTTI • RTTI: runtime type information • determine the exact type(e.g. given type or any subclass) of object that is referenced by a given pointer. • The RTTI Information for each class is stored as static data which includes a pointer to the RTTI data for the class’s based class or the name of the class.

  8. Object System: RTTI(2) • Basic Operations • Testing if an object’s class is exactly a specified class is accomplished by a macro “NiIsExactKindOf” • Testing if an object’s class is derived from a specified class, “NiIsKindOf” • Dynamic typecasting

  9. Object System: RTTI(3) NiNode* pkNode = new NiNode; bool bResult; bResult = NiIsExactKindOf(NiNode, pkNode); // bResult is true bResult = NiIsExactKindOf(NiAVObject, pkNode); // bResult is false bResult = NiIsKindOf(NiAVObject, pkNode); // bResult is true bResult = NiIsKindOf(NiSwitchNode, pkNode); // bResult is false NiObject* pkObject = pkNode; NiAVObject* pkDynAVObj = NiDynamicCast(NiAVObject, pkObject); // pkDynAVObj == pkNode NiNode* pkDynNode = NiDynamicCast(NiNode, pkObject); // pkDynNode == pkNode NiSwitchNode* pkDynSw = NiDynamicCast(NiSwitchNode, pkObject); // pkDynSw == 0

  10. Object System: Smart pointers • maintains a count of the # of reference to object. • They automatically increment and decrement the reference counts of objects • All NetImmerse Objects derived from NiRefObject are reference-counted. • Declaration of sp(smart pointer) : ??Ptr

  11. Object System: Smart pointers(2)A simple example: NiNodePtr spParent = <some node>; NiNodePtr spChild = new NiNode;  // spChild points to new object. Reference count is 1. spParent->AttachChild(spChild);  // Reference count of object pointed to by spChild is now // 2, since NiNode objects use smart pointers to refer their children. spParent->DetachChild(spChild);  // Reference count of object pointed to by spChild decreases to 1. spChild = 0;  // Reference count of object decreases to 0. Object is deleted.

  12. Object System : Streaming • Streaming provides a way of saving and loading scene graphs and other Ni Object to and from disk or memory buffers. • File streams support standard load and save op. • Memory streams support loading of files and transfer of content across networks • It can provides a streaming with a Stream group

  13. Object System : Streaming(2) • Stream Saving void InsertObject(NiObject* pkObject); void RemoveObject(NiObject* pkObject); void RemoveAllObjects(); NiObject* GetObjectAt(unsigned int i) const; unsigned int GetObjectCount() const; NiCamera* pkCamera = <some camera>; NiLight* pkLight = <some light>; NiNode* pkScene = <some scene graph>; NiStream kStream; kStream.InsertObject(pkCamera); kStream.InsertObject(pkLight); kStream.InsertObject(pkScene); kStream.Save(“myfile.nif”);

  14. Object System : Streaming(3) • Stream Loading NiTArray<NiObjectPtr> kObjects; NiStream kStream; kStream.Load(“myfile.nif”); for (unsigned int i = 0; i < kStream.GetObjectCount(); i++) {     NiObject* pkObject = kStream.GetObjectAt(i);     kObjects.Add(pkObject); }

  15. Object System: Cloning • Is a method by which copies of objects are made. • An app. Calls the funtions • NiObject* NiObject::Clone();

  16. Object System : Extra data • NiObjectNet class support for attaching extra data. • It supports RTTI and streaming • NiObjectNET support for NiTimeControllers

  17. Object System : Extra data(2) The relevant member functions ofNiObjectNETare void PrependExtraData(NiExtraData* pkExtra); void SetExtraData(NiExtraData* pkExtra); NiExtraData* GetExtraData() const; void RemoveExtraData(NiExtraData* pkExtra); void RemoveAllExtraData();

  18. Static NetImmerse Objects& Object Lifetime • App. should avoid creating statically NetImmerse objects. • Smart pointers declared statically are fine, (but it must be set to null prior to the end of the app)

  19. Naming Conventions • All NI class type names are prefaced with the Ni prefix and use capitalization to separate words (e.g. NiSwitchNode ) • Avoids using global-scope constants and enumerated types, prefer to use class-local enumerated types • (e.g. NiAlphaProperty::ALPAH_SRCALPHA)

  20. Naming conventions : Variable prefixes • Type Prefix Example Float f fValue (unsigned) int (u)i (u)iValue (unsigned) short (u)s (u)sValue (unsigned) long (u)l (u)lValue Enum e eFlag Class k kWorld Pointer(+type) p piValue Pointer to pointer pp ppkWorld Pointer to void pv pvData Smart pointer sp spValue Function pointer pfn pfnCallback Double d dValue Array( +type) a aiValue Member data m_ m_fValue Static member data ms_ ms_kSingleton

  21. Template Classes • List : NiTLists. • SimpleList : NiTSimpleLists • Array : NiTArrays • Map : NiTMaps, NiTStringMaps • Queue : NiTQueue • Set : NiTSet

  22. Programming with VC++ • NetImmerse Lib are shipped with VC++6.0 dws files • All of the NetImmerse Lib are compiled with VC++ and Visual Studio SP #5( it is available athttp://msdn.microsoft.com/visualc/downloads/updates.asp)

  23. Application Build Settings (1) • Link Object Library Modules • NiMain.lib NiSystem.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib • The library search path for the project file should include the path to the NetImmerse libraries, including thesdk\Win32\ReleaseLib, sdk\Win32\ReleaseDLL, etc.

  24. Application Build Settings (2) • C/C++ Preprocessor Definitions • NetImmerse applications must also define STRICT ( + WIN32, NDEBUG or _DEBUG, _WINDOWS ) • C/C++ Code Generation and Choosing the Right Set of NetImmerse Libraries • Processor: Pentium • Use Runtime Library: Multithreaded DLL • Calling Convention: __cdecl • Struct Member Alignment: 8 Bytes

  25. Application Build Settings (3) • Renderer • the Link Object Library Modules setting of applications using the DX8 renderer should include: NiDX8Renderer.lib • Applications using the DX7 renderer should include: NiDX7Renderer.lib ddraw.lib dxguid.lib • Applications using the OpenGL renderer should include: NiOglRenderer.lib opengl32.lib glu32.lib • Miles Sound Module • NiAudio.lib mss32.lib

  26. Application Build Settings (4) • Havok Physics Module • hkactions.lib hkdefaultvehicle.lib hkdisplayclasses.lib hkdisplayobject.lib hkdisplay.lib hkbase.lib hkdynamics.lib hkexport.lib hkgeometry.lib hkmath.lib hktoolkit.lib hkvehicle.lib hkcollide.lib NiHavokImportKit.lib NiHavok.lib • Please note that currently, only the Havok physics demo (Samples\NiHavokImporter) and the MaxImmerse plug-in (PlugIns\MaxImmerse) actually link these libraries.

  27. Dir Structure of NetImmerse

More Related