Click here to Skip to main content
14,454,989 members

Kigs Framework Introduction (1/8)

Rate this:
4.70 (7 votes)
Please Sign up or sign in to vote.
4.70 (7 votes)
21 Feb 2020MIT
A multi purpose, cross-platform, free and Open Source C++ framework
Kigs framework a lightweight, fast, scalable framework that was ported to different platforms. We used it as a base to build Assoria projects from Nintendo DSi games to industrial robots simulator. This entry is a basic introduction of the series which will go over: Core Features, Prerequisites, Creating a New Project, and how to Build and Run the New Project.

Kigs Logo

Table of Contents

Introduction

Today, it is possible to develop 3D mobile applications, multi platform games ... quite simply thanks to commercial (Unreal, Unity ...) or open source (OpenSceneGraph, Ogre3D ...) 3D engines.

These engines obviously have all their advantages, but also their disadvantages:

  • Some are not free.
  • Some are black boxes and you only have access to exposed functionality.
  • Some are very scene graph / rendering oriented and not really multi purpose.

We developed the Kigs framework because we wanted a lightweight, fast, scalable framework that we could port to different platforms (that's why we used C++, available on almost all platforms), and we could use as a base to build all our projects from Nintendo DSi games:

Rollway Puzzle

to industrial robots simulator (have a look here: https://kigs-framework.org/Projects). We also wanted to remain totally independent, and keep full control over all our projects code.

Kigs framework gives access to high level architecture and functionalities while maintaining low level control (optimizations, platform specific customization, easy C/C++ extern libraries usage ...).

We decided some weeks ago to open source (MIT licence) the main modules of our framework for Windows (x86, x64, for openGL and D3D, WUP D3D), and HTML5/Web Assembly (Emscripten) platforms. Here is the GitHub repository:

Why Use the Kigs Framework?

  • You are a C++ developer and want to have access to high level functionality such as serialization, instance factory, signals / slots management, scenegraph / rendering, lua scripting ...
  • You want to learn game development using C++ and lua scripting.
  • You want to experiment with new ideas without starting from scratch.
  • You are curious to see how we implemented this or that feature and perhaps want to help improve the framework.

We would be happy if others take over our framework, improve it and adapt it to their desires and their needs.

General Architecture

The Kigs framework is divided into different modules, each grouping functionalities in a particular domain (Input, Rendering, GUI...). There are two main module types: Generic and Specific.

Generic Modules

A generic module defines API/SDK/System independent classes, and/or base classes (interface) for API/SDK/System dependent classes.

Specific Modules

Of course, specific modules do the exact opposite: they define API/SDK/System dependent classes, often inheriting from generic classes.

Base Modules

The main modules are Core, FileManager, Timer, XML. Then Input (with specific InputWindows, InputWUP...), GUI (GuiWindows, GUIWUP...), SceneGraph, Renderer (RendererOpenGL3, RendererDirectX11)...

Core Features

Core features are mainly supported by KigsCore and CoreModifiable classes.

Instance Factory

Classes with CoreModifiable inheritance can be registered to instance factory. Ask KigsCore to create a new instance of the wanted class is then easy:

// Ask for an instance of class Timer called "localtimer" 
CMSP localtimer = KigsCore::GetInstanceOf("localtimer", "Timer");

CoreModifiable Trees

CoreModifiable instances can be organized in parent/sons trees like this:

// add localtimer instance to this (this must inherit CoreModifiable too of course)
addItem(localtimer);

addItem adds a reference to the reference count of the instance. localtimer instance will be destroyed when its references count reach 0, so in our case when parent class is destroyed.

CoreModifiable should be initialized before use:

// init localtimer (timer is started)
localtimer->Init();

Then localtimer can then be retrieved in another part of the code with different kind of research functions:

// search son with given name
Timer* localtimer=GetFirstSonByName("Timer", "localtimer")->as<Timer>();

or:

// search first instance found with given name
CoreModifiable* localtimer = GetFirstInstanceByName("Timer", "localtimer");

All instances of a given type can also be retrieved in one call:

// search all instances of Timer
std::set<CoreModifiable*> alltimers;
GetInstances("Timer", alltimers);

CoreModifiable Attributes

CoreModifiable can have "compile time" attributes that can be get or set by their names:

// retrieve "Sample1Value" value on this
int _value;
testInstance->getValue("Sample1Value", _value);
_value = 4 * _value - 12;
// change "Sample1Value" value with _value
testInstance->setValue("Sample1Value",  _value);

Attributes can also be added or removed at runtime:

// add a dynamic attribute on instance of localtimer
localtimer->AddDynamicAttribute(ATTRIBUTE_TYPE::FLOAT, "floatValue", 12.0f);
// retrieve dynamic attribute value on localtimer
float timervalue=localtimer->getValue<float>("floatValue");
// set dynamic float attribute with string
localtimer->setValue("floatValue","24");

Serialization

CoreModifiable trees with all their attributes can be exported in XML files:

// export this and its sons in "Sample1.xml" file
CoreModifiable::Export("Sample1.xml", this, true);

And of course, import CoreModifiable trees from an XML file is also possible:

// import instances from file "Sample1.xml"
CMSP imported=CoreModifiable::Import("Sample1.xml");

CoreModifiable Methods

Methods can be added to CoreModifiable and then accessed at runtime only by their names (without knowing the exact type of the instance the method is called on).

The easy way to call such a method is:

// call SimpleSampleClass AddValue method directly on CoreModifiable
float result = simpleclass->SimpleCall<float>("AddValue", 10, 12.0f);
printf("result of calling AddValue = %f\n", result);

Find all the sample code from this introduction in the "Sample1" project on GitHub (browse the code).

Getting Started

Prerequisites

We will focus on the main development platform we have used: Windows.

Our scripts need Visual Studio C++ 2019 (Community edition is OK).

A recent version of CMake (3.15.5 is setup in our case).

Creating a New Project

After cloning the repository, go to the kigs\projects folder.

Launch one of the two present scripts: CreateNewConsoleProject.vbs (for a command line type project) or CreateNewDDProject.vbs (for a graphical data driven project).

Enter a name for the project: a new folder with this name will be created. For example "SimpleTest" and press OK.

Now open "kigs\projects\CMakeLists.txt" file in a text editor and add the line:

add_subdirectory(MyProjectName)

replacing "MyProjectName" by the name of the project (SimpleTest in our example).

Save and close "CMakeLists.txt" file.

Then go to kigs\scripts folder and launch one of the following scripts:

  • generateWinCMake.bat for a win32 (opengl) application
  • generateWinCMake64.bat for a win64 (opengl) application
  • generateWinD3DCMake.bat for a win32 (D3D) application
  • generateWinD3DCMake64.bat for a win64 (D3D) application
  • generateWUPD3DCMake.bat for a Universal Windows Platform D3D application (only for graphical data driven project)

A new Build\[solutionType] folder is created at the same level as kigs folder.

Build and Run the New Project

Browse in this folder to reach Build\[solutionType]\kigs\projects\"MyProjectName" and choose "MyProjectName".sln to open it in Visual Studio.

Once the solution is loaded in Visual Studio, set "MyProjectName" as your startup project, choose the build configuration you want: StaticDebug (for a compilation with full debug info), StaticReleaseTools (for a compilation with optimization, but keeping all the export functionalities), StaticRelease (for full optimization but no export functionality).

Build, launch. That's it!

What's Next

In the next articles of this series, we will explore the advanced features of the framework:

  • CoreModifiable class details
  • CoreModifiable attributes
  • CoreModifiable methods
  • CoreItem
  • Signal / slot / notification
  • Lua binding
  • Data driven application
  • ...

Already Published in this Series

  1. Kigs Framework Introduction (1/8) - Overview
  2. Kigs Framework Introduction (2/8) - CoreModifiable
  3. Kigs Framework Introduction (3/8) - Attributes
  4. Kigs Framework Introduction (4/8) - Methods
  5. Kigs Framework Introduction (5/8) - CoreItem

History

  • 24th January, 2020: Initial version
  • 29th January, 2020: Added Table of Contents
  • 1st February, 2020: Added Already Published in this Series
  • 7th February, 2020: Article (3/8) added to the series
  • 8th February, 2020: Added screenshot from Rollway Puzzle and fixed link to Projects page
  • 14th February, 2020: Article (4/8) added to the series
  • 21st February, 2020: Article (5/8) added to the series and small bug fix in code

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

Stephane Capo
Chief Technology Officer Assoria
France France
I created Assoria company in 2007.
I supervise and participate in the development of Kigs framework, projects realized by Assoria as well as NEXT-BIM software.

Comments and Discussions

 
PraiseMy vote of 5 Pin
Guirec14-Feb-20 6:10
professionalGuirec14-Feb-20 6:10 
GeneralRe: My vote of 5 Pin
Stephane Capo14-Feb-20 8:28
MemberStephane Capo14-Feb-20 8:28 
QuestionMessage Closed Pin
8-Feb-20 23:37
MemberMember 147391748-Feb-20 23:37 
GeneralMy vote of 4 Pin
KarstenK28-Jan-20 23:11
mveKarstenK28-Jan-20 23:11 
GeneralRe: My vote of 4 Pin
Stephane Capo29-Jan-20 0:33
MemberStephane Capo29-Jan-20 0:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Article
Posted 24 Jan 2020

Tagged as

Stats

59.6K views
13 bookmarked