Monday, May 22, 2017

CRUD oriented game content management : PART 2.a : Creation



PART 2.a

Game content loading and creation :

Z-GDK specifically designed for making games. It relies heavily on image file for its content, but not just an image file, there are different types of image content primarily used in games. A Single image file is the simplest form of an image content to display a static sprite or mesh texture material to be rendered on screen. Some are using multiple image files to create an animated 2D sprite or 3D billboard and particles texture material. Others are using  a single image sprite sheet file for their animated sprite characters or a single image resource file consist of tiny images are commonly used for sprite, say for tile map content or an image collection of inventory items stored in just a single image file.

The idea is to create a TextureContent  that has a definition of image animation key set, if an animated image collection, in preparation for SpriteEntity and or 3D animated texture usage, a single instance of TextureContent can be applied to multiple SpriteEntity or 3D animated texture material as a source image texture content.

Z-GDK has different kinds of direct-texture-content-loading and creation scheme as listed below without using content pipeline processors and not relying on XNB files.

A. Creating  TextureContent  from a single image source file.
B. Creating single animated  TextureContent  from multiple image source files.
C. Creating single animated TextureContent from a single sprite sheet image source file.
D. Creating multiple static or animated TextureContent from texture atlas image source file.
E. Creating TextureContent from color. 



Let's start from the basic texture content loading and creation from a single image source file :

A. Creating  TextureContent  from a single image source file:
------------------------------------------------------------------------------------------------------------------

The simplest way of creating TextureContent is by loading from a single image source file, as shown
below:

Sample of  single image file: named ZGDKLogo.jpg:














//--> Create texture content from a single image source file.
//
TextureContent m_ZgdkLogoText = _Device.Content.TextureMngr.Create("Contents/Textures/ZGDKLogo.jpg");




// From here the created texture content can be assigned to 2D-Sprite entity
// or to 3D-Model entity as texture material.


//--> CREATE 2D-SPRITE ENTITY
LayerEntity m_Layer01 = _Device.Entity2D.LayerMngr.Create("TopLayer"); SpriteEntity m_LogoSpr = _Device.Entity2D.SpriteMngr.Create( m_ZgdkLogoText, m_Layer01 ); // m_LogoSpr.Position( 0,0 ); //--> CREATE 3D-MODEL ENTITY ModelEntity m_BoxModel = _Device.Entity3D.ModelMngr.Create( MeshPrimitveType.Cube,false,false,false); // m_BoxModel.Scale( new Vector3(10,10,10) ); m_BoxModel.Position( new Vector3(0,0,0) ); // //--> Box model materials setting. // m_BoxModel.ModelGroups(0).Materials(0).textureContent0 = m_ZgdkLogoText; m_BoxModel.ModelGroups(0).Materials(0).usePerPixelLighting = true;
The output using single instance of TextContent for 2D-Sprite and 3D-Model:
Next post : B. Creating a single animated  TextureContent  from multiple image source files.

Tuesday, May 9, 2017

Added some asteriods and dust clouds on my game prototype








Managing game content can also be CRUD oriented!



PART 1

what is CRUD?

It was first reference in the article entitle “from semantic to object-oriented data modeling” by Haim Kilov in Conference: Systems Integration, 1990.  But I’m pretty sure CRUD operation was used earlier than 1990. In application development CRUD is an acronym of the four most common operation in database development where the application have the functionality to Create, Read, Update and Delete a record.

CRUD can be used not only in database application, it can also be used in game development where you can Create/Load,  Read/GetData,  Update/Modify and Delete/Remove a content or  game entity at any time anywhere in the code.

Since the time of XNA I’m already not a fond of its content pipeline’s loading and unloading of game assets, not the technology involving in it, the content pipeline processors are good, so don’t get me wrong XNA is a nice piece of game framework after Managed DirectX or MDX. But the framework’s design on how to load and unload of game content are somehow limited or restricted, unless you do some workaround. For a much more flexibility and manageability I believed it should have the ability to Create/Load, Update/Modify, Read and Delete/Remove selected or all content at any giving time, wherever you wish in the code.

MonoGame on the other adopted the loading and unloading scheme found in XNA since  I’m using MonoGame framework on my Game Development Kit I decided to create my own content manager and not using MonoGame Content Pipeline, I’m not saying it’s a bad move or one’s should not use it. But I want more control over the content I will be loading and unloading within the whole life of the game.
What I have implement in Z-GDK is the ability to create, read and remove selected or all content at any given time anywhere in the code as shown in content managers below like texture and mesh content manager :


Content Managers :


Let's take a look at Texture Content Manager :


Let's take a look at Mesh Content Manager :



In Z-GDK Content or Entity managers have a simple properties and methods layout, but have different kinds of overloads; as for example the Remove methods has an overloads to remove item by index,  by auto assigned UID(Unique ID ), by Name or by user defined Scene ID as I will be tackle on the later parts. CRUD operations was also applied in game entity managers as shown below the model entity manager:





Z-GDK sample code on how easy and simple it is to load game content and to create game entity without using content pipeline :




See you on PART 2 : CRUD : Loading and Content Creation