Shank_R_1254

plainspecialΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

86 εμφανίσεις

Introduction

Tell joke

Explain CS

I may call it CS in talk

Crystal Space is an open source 3D graphics engine.

Features

Portal engine

Multi
-
platform

6DOF

2D sprites

particle systems

Bezier surfaces

Lights

Static

Dynamic

Pseudo
-
dynamic

Shadowing

Colored vol
umetric fog

Transparent and semi
-
transparent textures

perspective correct texture mapping

mipmapping

GUI windowing system

Multiple camera system

Network system

Sound driver

Physics library

Scripting

Usages

Where to get CS

Crystal Space project home
--

http://crystal.linuxgames.com

The code for CS
--

www.sourceforge.net/projects/crystal/


(repeat urls)

History

Project started and still lead by Jorrit

Tyberghein

Started with his interest in games like Doom, Hexen and Duke Nukem 3D.

Tried to build his own

Very slow
-

found portal information made a better engine.

Didn’t have time for project so he emailed the source to anyone who asked for it.

Soon port
ed to MS
-
DOS

Project grew and is now great example of open source

Future

Continuing strong with great presence in the open source world.

Almost always in the top 10 of activity on Sourceforge usually at the top

There are over 50 registered developers

There

are over 500 members on the mailing lists


1.0

stable release to happen soon, API at a very stable stage

The project will continue in the future

Likely at accelerated rate since projects can be developed

Alternative to commercial engine for commercial project

Specifics

Platforms

Linux, Windows, MacOS/X, MacOS/9, OpenStep, NextStep, BeOS, OS/2, MS
-
DOS and Gaming Consoles

Supported Graphics API

OpenGL, DirectX 8.0 and Software

Color depth

8
-
bit (palette), 15/16
-
bit truecolor, 32
-
bit truecolor

Portal engine

Why a
n engine?

To manage polys, deciding what gets rendered, how, where.


A portal engine basically is taking a world, dividing it into small sections, called
sectors and dealing only with the visible sectors.

The portal is the polygon where the sectors are c
onnected.


The rendering process starts in the sector that the camera is in.

It draws the polygons in the current sector, and when a portal is encountered, the adjacent sector
is entered, and the polygons in that sector are processed.

And if a portal is n
ot visible, the sector that it links to doesn't have to be drawn.

The sectors can have additional culling in them like octree or BSP.


Portal engines don’t work well with landscapes.


Portal rendering can be perfectly combined with outdoor engines though

The outdoors would be a single ( or if large, multiple sectors )

You could place portals in entrances of caves, buildings and so on.


For large levels world can be broken down into regions that do dynamic loading

Rendering system

The engine doesn’t render
anything.

What does it do?

The engine keeps tracks of:



what objects are to be rendered



the position of the object to be rendered



when to render it

The object knows how to render and light itself


1.

Render priority queue (add if there is time)


Mesh Objects
(if there is time)

Transparent to engine

LOD reduction


PlugIn System

Why a plugin system



Pick and choose which elements you want in your application



Seamlessly add other elements and components to game



Make changes to engine without breaking it



Easier to
add changes



Flexability

Types of plugins

Drivers

Graphics Drivers

The graphics driver is a clean interface to the different graphics APIs.

“low
-
level” graphics output
-

pixels, lines and text, polygons

Sound Drivers


Network Drivers


Engine Components

3D
Engine

The control center for game

it is also loaded as a plugin allowing for different types of engines. Currently
there is a 3D engine plugin and an isometric engine plugin. It could be expanded
to a side or vertical scroller or any other style of engi
ne.


Mesh Objects


Mesh objects are 3D objects that can be used and displayed by the engine.


Motion Manager


Skeletal motion manager.


Collision Detection


currently based on the RAPID algorithm

another type of collision detection could be used

interface

could be the same


Font Server



Console

and
Console Input


These plug
-
in modules can be used for console
-
like text input and output, similar
to the console in Quake.


Scripting


The scripting plug
-
in modules allows support for scripting.

Python support
could be expanded to any type of script.

Utility PlugIns

Standard Loader


This plug
-
in will replace the
csParser

library once the engine is a plug
-
in module.
Until then, it is not helpful for your own projects.


Import/Export


Performance Statistics


This

plug
-
in helps to measure performance of the 3D engine.


Dungeon


A game specific plugin that can be used to create random levels based on simple
parts created by a level editor.


VFS

(Virtual File System)

VFS

VFS serves as the basic module for file acc
ess for all parts of Crystal Space

Make engine modular

no need for concern for how to load the dynamic module

allows access to C++ classes without having the C++ name
-
mangling problem
for modules compiled with different compilers.

Platform independent
-

s
its on top of the real file system that hides the non
-
portable aspects of file systems

It allows one to map "virtual" directories to "real" ones

to map several real directories together as a single virtual directory

treat `
.zip
' files like subdirectories.

Workings of VFS

Each "directory" on the VFS
virtual volume

is mapped to some
real
-
world

directory or ZIP archive.


Explain chart on real and mounted directories


Can be used in any project

SCF (Shared Class Facility)

Heart of the plugin system

Similar to
COM

COM was used before SCF was created



Easier to use



More lightweight



COM not cross
-
platform friendly

o

Incompatibilities with Objective
-
C on NeXT

o

Problems with native Windows types

Can be used with COM or COBRA

Interface file

This is the magic of the SCF

a

set of abstract methods that you want to access within some object

defined in a struct

Could use a class with number variables and inline methods

Future expansion

Not suggested if you want to use with COM


struct iGraphics

{


// Open the device.


virtua
l bool Open( const char *Title ) = 0;


// Close the device.


virtual void Close() = 0;



virtual void DrawPolygon( G3DPolygonDP& poly ) = 0;


virtual void DrawTriangleMesh( G3DTriangleMesh& mesh ) = 0;

};


You can have several implementations of the in
terface.

In example you could have



Software



OpenGL



DirectX



Glide

You could have implementations for various platforms



OpenGL Linux



OpenGL Windows



OpenGL Mac OS/9



OpenGL OS/2



OpenGL BeOS



OpenGL Xbox (joke)

If desired you could have even more specific implem
entations



OpenGL Linux Pentium Optimized



OpenGL Linux MMX Opt



OpenGL Linux AGP Opt



OpenGL Linux Pentium 4 Opt



OpenGL Linux PowerPC


#include “graphics.h”


class OpenGLLinuxP4 : public iGraphics

{


// Open the device.


virtual bool Open( const char *Title

);


// Close the device.


virtual void Close();



virtual void DrawPolygon( G3Dpolygon &poly );


virtual void DrawTriangleMesh( G3DtriangleMesh &mesh );

}



Implementation Source


bool OpenGLLinuxP4::Open( const char *Title )

{


// do stuff


return
true;

}


void OpenGLLinuxP4::Close()

{


// do stuff

}


void OpenGLLinuxP4::DrawPolygon( G3Dpolygon &poly )

{


// do stuff

}


void OpenGLLinuxP4::DrawTriangleMesh( G3DtriangleMesh &mesh )

{


// do stuff

}


The implementation goes into a shared library.

C
lass Factory

since the client don't have any idea how we should build an object of a class, we
also provide a function that will return a newly
-
allocated object of that class.

This is called the
class factory


static iGraphics* Create_iGraphics()

{


retu
rn new OpenGLLinuxP4();

}

There are macros that handle that, go to web site to get more info.

Client side

The client uses the class factories to create the class.

Any implementation can be used as long as the interface is the same.

Pseudo code below:


iGra
phics *pGraphics;



if ( bOpenGLMode )


iGraphics = new GraphicsOpenGL();


else


iGraphics = new GraphicsSoftware();

Demos