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.

No comments:

Post a Comment