newspeoplefor developersdocumentationdownloads

Nebula Kernel


Detailed Description

Overview

As a kernel is core part of an operating system, you can consider the kernel of the Nebula as similar thing.

The followings are most important tasks what the Nebula kernel does:

  • handle modules
  • create Nebula objects

One of the great feature of the Nebula is that it has modular architecture. The Nebula engine consists of sperated parts of the packages and it makes easy to maintain the whole system. Commonly a module is defined that code which can be loaded or unloaded to the kernel as its necessary. Therefore, there should be something which loads modules and that is the kernerl. Whereas the kernel of an operating system loads modules when it needs, the Nebula kernel loads all its necessary modules at the startup of the application. See the following section Creating Kernel to know the way to add packages to the kernel server.

Second, the Nebula kernel responds to a creation of the Nebula objects. As an operating system creates a process to do something for user tasks, Nebula does that with 'Nebula Object' for its specific tasks. For an example, rendering a static mesh can be done with nShapeNode. The nShapeNode is the Nebula object and nKernelServer creates it. As the nShapeNode, all Nebula objects (aka. nRoot derived classes) are created by calling nKerenelServer::New(). See Object System for more details about the Nebula object.

On the other hands, there are also many other tasks what the Nebula kernel modules do like memory management, file system, IPC handling, threading support and so on. See the corresponding documents of modules and classes for more details.

Creating Kernel

The first thing to use Nebula in your application is to create a kernel. The creation of the kernel of Nebula is done by creating nKernelServer class intance.

    // Create kernel server instance
    nKernelServer kernelServer;

The next thing to do after creating kernel server instance is to add packages which are used in the application.

    // Add packages to use
    kernelServer.AddPackage(nnebula);
    ...

Before adding package to the kernel server, the package should be defined with provided nNebulaUsePackage macro.

    nNebulaUsePackage(nnebula);
    // Add other packages as its necessary
    ...

See src/tools/nviewer.cc file as fully detailed working example of it.

A Folding Object System

What a folding object is?
You can see $parser and $class tag in torus.n2 script file.

    # ---
    # $parser:ntclserver$ $class:ntransformnode$
    # ---

    ...

This code means that 'Create nTransformNode object for it's name with filename of script file' by nTclServer. Other object which are created by next to be a child node of a folding object. A folding object at this is a nTransformNode object and the object name of it is script filename.

So it's identical to this

    new ntransformnode torus
        sel torus
        ...
    
        new ntransformanimator rot
            sel rot
            ...
            sel ..

        new nshapenode shape0
            sel shape0
            sel ..
        sel ..

How to use a folding object?
There's a easy way to load whole resources using folding object system.

Consider that you have a directory for a character. The directory consists of a mesh file(.n3d2), some animation files (.nanim2), texture files(.dds and a script file (.n2)

Let's consider a directory like this one:

    /mycharacter.n2 - the directory which contains resource files 
        /_main.n2 - script file
        /body.dds  - texture for character 
        /walk.nanim2  - animation data file 
        /body.n3d2 - mesh data file 

And you can load all resources in the directory with the given directory name;

    ...
    kernelServer->PushCwd(this->refRootNode.get());
    kernelServer->Load("mycharacter.n2"); // just pass the directory name.
    kernelServer->PopCwd();
    ...

If you use folding object system, it is good to use .n2 for a postfix of the directory name but it's not crucial. But the script file which exist in the directory should be _main.n2 for it's name. nKernelServer looks up _main.n2 when loading object as a folding object.


Files

file  ncmdargtypes.h

Modules

 File I/O and File System Access
 A cross platform set of file I/O and file system objects that also support access to virtualized file systems.
 Inter-Process Communication
 Logging
 Memory Management
 Object System
 Nebula provides an object system to provide metadata for the scripting system. This is a key part that allows Nebula to support object persistence and multiple scripting languages with relative ease.
 Scripting Support
 Threading Support
 Nebula provides basic support for threading along with integration into some of the Core Nebula systems.
 Time Management
 Nebula provides a single realtime time source to assist in decoupling simulation speed from the frame rate.
 Signal System
 The signal system for Nebula. It allows native and script code to get called in a flexible way.

Classes

class  nArg
class  nAtomTable
class  nCRC
class  nGuid
 Wraps a Globally Unique Identifier. The actual GUID data is hidden inside the object and only accessible as string. More...
class  nObject
class  nPersistServer
class  nRefCounted
class  nReferenced
class  nRoot
class  nStackTrace
class  nWin32Wrapper

Copyright © 1999-2005 by the contributing authors. Ideas, requests, problems: Send feedback.