Kigs框架介绍(1/8)

Kigs Logo

目录 (Table of Contents)

介绍 (Introduction)

Kigs is a basement framework for rapid application development. It gives access to high-level architecture and functionalities ( modules, serialization, reflection, instances factory, upgradors, aggregates... ) while maintaining low-level control (optimizations, platform-specific customization, easy C/C++ extern libraries usage ...).

Kigs是用于快速应用程序开发的基础框架。 它可以访问高层体系结构和功能(模块,序列化,反射,实例工厂,升级器,聚合...),同时保持低层控制(优化,特定于平台的自定义,易于使用的C / C ++ extern库)。 )。

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

今天,有可能开发2D或3D移动应用程序,多平台游戏...非常简单,这要归功于商业(Unreal,Unity ...)或开源(OpenSceneGraph,Ogre3D ...)3D引擎。

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 basement to build all our projects from Nintendo DSi games:

我们开发Kigs框架是因为我们想要一个轻量级,快速,可扩展的框架,可以将其移植到不同的平台(这就是为什么我们使用几乎所有平台上都可用的C ++的原因),并且可以将其用作从Nintendo构建所有项目的基础DSi游戏:

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.

工业机器人模拟器(请在此处查看: https//kigs-framework.org/Projects )。 我们还希望保持完全独立,并完全控制所有项目代码。

We decided some weeks ago to open source (MIT license) the main modules of our framework for Windows (x86, x64, for OpenGL and D3D, WUP D3D), and HTML5/Web Assembly (Emscripten) platforms. A functional Android version and an unmaintained iOS version are now also available. Here is the GitHub repository:

几周前,我们决定开放源代码(MIT许可证),以用于Windows框架(x86,x64,用于OpenGL和D3D,WUP D3D)和HTML5 / Web Assembly(Emscripten)平台的主要模块。 现在还提供功能性的Android版本和未维护的iOS版本。 这是GitHub存储库:

为什么要使用Kigs框架? (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 ...

    您是C ++开发人员,想访问高级功能,例如序列化,实例工厂,信号/插槽管理,场景图/渲染,Lua脚本...
  • You want to learn game development using C++ and Lua scripting.

    您想学习使用C ++和Lua脚本进行游戏开发。
  • 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.

Kigs框架分为不同的模块,每个模块在特定领域(输入,渲染,GUI ...)中对功能进行分组。 有两种主要模块类型:通用和特定。

通用模块 (Generic Modules)

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

通用模块定义API / SDK / System无关的类,和/或API / SDK / System相关类的基类(接口)。

特定模块 (Specific Modules)

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

当然,特定模块的作用恰恰相反:它们定义了API / SDK / System依赖的类,通常是从通用类继承的。

基本模块 (Base Modules)

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

主要模块是CoreFileManagerTimerXML 。 然后Input (使用特定的InputWindowsInputWUP ...), GUI ( GuiWindowsGUIWUP ...), SceneGraphRenderer ( RendererOpenGL3RendererDirectX11 )...

核心功能 (Core Features)

Core features are mainly supported by KigsCore and CoreModifiable classes.

核心功能主要受KigsCoreCoreModifiable类支持。

实例工厂 (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:

具有CoreModifiable继承的类可以注册到实例工厂。 让KigsCore创建想要的类的新实例非常简单:

// 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:

可以在父/子树中组织CoreModifiable实例,如下所示:

// 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.

addItem将引用添加到实例的引用计数。 localtimer引用实例的引用计数达到0localtimer实例将被销毁,因此在本例中,父类被销毁。

CoreModifiable should be initialized before use:

CoreModifiable应该在使用前初始化:

// 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:

然后可以使用不同类型的研究功能在代码的另一部分中检索localtimer

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

or:

要么:

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

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

给定类型的所有实例也可以在一个调用中检索:

// search all instances of Timer
std::vector<CMSP> alltimers = GetInstances("Timer");

CoreModifiable属性 (CoreModifiable Attributes)

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

CoreModifiable可以具有“编译时”属性,这些属性可以通过其名称来获取或设置:

// 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:

具有所有属性的CoreModifiable树可以导出为XML文件:

// 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:

当然,也可以从XML文件导入CoreModifiable树:

// 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).

可以将方法添加到CoreModifiable ,然后在运行时仅按其名称访问(不知道调用该方法的实例的确切类型)。

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).

在GitHub上的“ Sample1”项目中找到此介绍中的所有示例代码( 浏览代码 )。

入门 (Getting Started)

先决条件 (Prerequisites)

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

我们将专注于我们使用的主要开发平台:Windows。

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

我们的脚本需要Visual Studio C ++ 2019(社区版本可以)。

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

CMake的最新版本(在本例中为3.15.5)。

创建一个新项目 (Creating a New Project)

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

克隆存储库后,转到kigs \ projects文件夹。

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

启动两个当前脚本之一: CreateNewConsoleProject.vbs (用于命令行类型的项目)或CreateNewDDProject.vbs (用于图形数据驱动的项目)。

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

输入项目的名称:将使用该名称创建一个新文件夹。 例如“ SimpleTest ”,然后按OK

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

现在,在文本编辑器中打开“ kigs \ projects \ CMakeLists.txt ”文件并添加以下行:

add_subdirectory(MyProjectName)

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

用项目名称替换“ MyProjectName ”(在我们的示例中为SimpleTest )。

Save and close "CMakeLists.txt" file.

保存并关闭“ CMakeLists.txt ”文件。

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

然后转到kigs \ scripts文件夹并启动以下脚本之一:

  • generateWinCMake.bat for a win32 (opengl) application

    用于Win32(opengl)应用程序的generateWinCMake.bat

  • generateWinCMake64.bat for a win64 (opengl) application

    用于win64(opengl)应用程序的generateWinCMake64.bat

  • generateWinD3DCMake.bat for a win32 (D3D) application

    用于Win32(D3D)应用程序的generateWinD3DCMake.bat

  • generateWinD3DCMake64.bat for a win64 (D3D) application

    为win64(D3D)应用程序generateWinD3DCMake64.bat

  • generateWUPD3DCMake.bat for a Universal Windows Platform D3D application (only for graphical data driven project)

    用于通用Windows Platform D3D应用程序的generateWUPD3DCMake.bat (仅适用于图形数据驱动的项目)

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

在与kigs文件夹相同的级别上创建一个新的Build \ [solutionType]文件夹。

生成并运行新项目 (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.

在此文件夹中浏览以访问Build \ [solutionType] \ kigs \ projects \“ MyProjectName”,然后选择“ MyProjectName ” .sln以在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).

在Visual Studio中加载解决方案后,将“ MyProjectName ”设置为启动项目,选择所需的生成配置: StaticDebug (用于具有完整调试信息的编译), StaticReleaseTools (用于具有优化的编译,但保留所有导出功能) ), StaticRelease (用于全面优化,但没有导出功能)。

Build, launch. That's it!

构建,启动。 而已!

下一步是什么 (What's Next)

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

在本系列的下一篇文章中,我们将探索框架的高级功能:

已在本系列中发布 (Already Published in this Series)

  1. Kigs Framework Introduction (1/8) - Overview

    Kigs框架简介(1/8)-概述

  2. Kigs Framework Introduction (2/8) - CoreModifiable

    Kigs框架简介(2/8)-CoreModifiable

  3. Kigs Framework Introduction (3/8) - Attributes

    Kigs框架简介(3/8)-属性

  4. Kigs Framework Introduction (4/8) - Methods

    Kigs框架简介(4/8)-方法

  5. Kigs Framework Introduction (5/8) - CoreItem

    Kigs框架简介(5/8)-CoreItem

  6. Kigs Framework Introduction (6/8) - Signal, Slot, Notification

    Kigs Framework简介(6/8)-信号,插槽,通知

  7. Kigs Framework Introduction (7/8) - Lua Binding

    Kigs框架介绍(7/8)-Lua绑定

  8. Kigs Framework Introduction (8/8) - Data Driven Application

    Kigs Framework简介(8/8)-数据驱动的应用程序

历史 (History)

  • 24th January, 2020: Initial version

    2020年1月24 :初始版本

  • 29th January, 2020: Added Table of Contents

    2020年1月29 :添加了目录

  • 1st February, 2020: Added Already Published in this Series

    2020年2月1 已在本系列中发布

  • 7th February, 2020: Article (3/8) added to the series

    2020年2月7 :第(3/8)条添加到该系列中

  • 8th February, 2020: Added screenshot from Rollway Puzzle and fixed link to Projects page

    2020年2月8 :添加了Rollway Puzzle的屏幕截图,并修复了指向“项目”页面的链接

  • 14th February, 2020: Article (4/8) added to the series

    2020年2月14 :第(4/8)条添加到该系列中

  • 21st February, 2020: Article (5/8) added to the series and small bug fix in code

    2020年2月21 :在系列文章中添加了文章(5/8),并在代码中修复了一些小错误

  • 2nd March, 2020: Article (6/8) added to the series

    3月2日,2020年加入该系列文章(6/8)

  • 6th March, 2020: New Android/iOS platforms released and article (7/8) added to the series

    2020年3月6 :发布了新的Android / iOS平台,并在该系列中添加了文章(7/8)

  • 19th March, 2020: all GetInstances methods now returns CMSP or std::vector<CMSP> 

    2020年3月19 :所有GetInstances方法现在都返回CMSP或std :: vector <CMSP>

  • 1st May, 2020 : GitHub repository moved.

    2020年5月1 :GitHub存储库移动。

  • 17th June, 2020 : Added final article of the series 

    2020年6月17 :添加了该系列的最后一篇文章

  • 19th June, 2020 : Changed introduction to make it clearer 

    2020年6月19 :更改了引文,使内容更清晰

翻译自: https://www.codeproject.com/Articles/5253209/Kigs-Framework-Introduction-1-8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值