chameleon game engine

12
Chameleon 3D game engine Tuesday, January 18, 2011

Upload: victor-porof

Post on 07-Nov-2014

4.506 views

Category:

Technology


5 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Chameleon game engine

Chameleon3D game engine

Tuesday, January 18, 2011

Page 2: Chameleon game engine

Overview

•OpenGL 2.0+ (desktop), ES 1.1, 2.0 (mobile)

•DirectX support (windows)

•C based•Platform independent•Lightweight, easy syntax•Complex API•Easily scalable•Tons of built-in features

Tuesday, January 18, 2011

Page 3: Chameleon game engine

OpenGL ES

•OpenGL API subset•Designed for embedded devices•Perfect for 3D on the iPhone/iPod touch & iPad•Also perfect for Android•Hardware accelerated rendering on the GPU•CPU should do almost no work•...but it’s pretty complicated!•...quite hard to find the perfect optimizations•...inexperienced programmers will make games 50x slower

Tuesday, January 18, 2011

Page 4: Chameleon game engine

•Renderer abstraction•Works on iOS, Android, Mac, Linux, Windows•Advanced 2D functions (arc, shape, bezier, catmull etc.)

•Eye-candy effects (blend, glow, diffuse, tint etc.)

•Fast image loading/compression (to 2 bits per pixel)

•Lights (ambient, point, spot) and materials•Shadows, reflections•Shape primitives (cube, sphere, cylinder, torus etc.)

Chameleonfeatures

Tuesday, January 18, 2011

Page 5: Chameleon game engine

Featuresfeatures (continued)

•3D model loading (geometry, textures)

•Skybox, sphere map•Particle system emitters (fire, explosions etc.)

•Imposters, billboard nodes (vegetation, trees etc.)

•Camera (yaw, pitch, roll: position, rotation)

•Camera controllers (arcball, fps, rpg, etc.)

•Offscreen canvas•...plus, many others•...optimized for each platform

Tuesday, January 18, 2011

Page 6: Chameleon game engine

Architecture

•Window engine context setup

‣Position on screen (or parent view) - x, y, width, height‣Fullscreen (or not)‣Display refresh rate, bits per pixel‣Input and mouse (touch) position, state, gestures

•Renderer hardware accelerated

‣Built-in capabilities abstraction layer‣Around 20 extremely low level drawing functions‣Entire engine relies only on them‣Easily scalable on any hardware

Tuesday, January 18, 2011

Page 7: Chameleon game engine

Architecture

•Canvas drawing layer

‣Coordinate system functions (translate, rotate, scale, transform)‣Styles (fill, stroke, tint, blend, alpha, add, mask etc.)‣Pixels, points, lines, n-sided polygons (rectangle, ellipse etc.)‣Convex/ concave shapes, bezier curves, cubic hermite splines‣Images, sprites, animations‣3D primitives (cube, sphere, cylinder, capsule, torus etc.)‣Lights, shadows, materials, reflections setup

+ Core extensions the user friendly high-level interface

+ Utilities the must-have game API (resource locator, image loader, files, sound, xml etc.)

Tuesday, January 18, 2011

Page 8: Chameleon game engine

Snippets

•CImage *img = loadImage("test.jpg", kSmooth)•image(img, 0, 0, img->width, img->height);

•CColor color;•getImagePixel(img, &color, 100, 100);•setImagePixel(img, initColor(255, 0, 0, 128), 100, 100);

•CModel *model = loadModel("fighter.3ds");•geometryRotation(model->geometry, PI, -HALF_PI, 0);•drawModel(model);

•pointLight(0, initVector3(5, -2, 0), initAmbient(192, 192, 128), ! ! ! initDiffuse(192, 192, 192),! ! ! initSpecular(255, 128, 64));

•materialSpecular(255, 255, 255);•materialShininess(128);

•translate(5, 2, -6);•rotate(radians(60), 1, 1, 0);•scale(2, 3, 1);

Tuesday, January 18, 2011

Page 9: Chameleon game engine

ExampleLenna

float frameCount;

CArcball *arcb;CColor *col;CImage *img;

#define step 2

- (void)setup {! defaults();! optimize3D();! noPointSmooth();! createPrimitives();!! perspective(45, (float)e.width / e.height, 1, 100);!! arcb = initArcball(e.width / 2, e.height / 2, e.height);! col = initColor(0, 0, 0, 0);! img = loadImage("lenna320.jpg", kSmooth);}

- (void)draw {! clear();! origin();!! translateZ(-4);!! rotateScene(arcb);!! noFill();! whiteStroke();! cube(0, 0, 0, img->width, img->height, img->width);! ellipse(0, 0, e.width, e.width);!! beginPixels();! for (float i = 0; i < img->width; i += step) {! ! for (float j = 0; j < img->height; j += step) {! ! ! getImagePixel(img, col, i, j);! ! ! float br = brightness(col->r, col->g, col->b);! ! ! pixelColor(i - img->width / 2, ! ! ! ! ! j - img->height / 2, ! ! ! ! ! br * fastsin(frameCount) / 2,! ! ! ! ! col->r, col->g, col->b, 255);! ! }! }! endPixels();

! frameCount += .1;!! gl.present(self.view);}

Tuesday, January 18, 2011

Page 10: Chameleon game engine

ExampleLenna

float frameCount;

CArcball *arcb;CColor *col;CImage *img;

#define step 2

- (void)setup {! defaults();! optimize3D();! noPointSmooth();! createPrimitives();!! perspective(45, (float)e.width / e.height, 1, 100);!! arcb = initArcball(e.width / 2, e.height / 2, e.height);! col = initColor(0, 0, 0, 0);! img = loadImage("lenna320.jpg", kSmooth);}

- (void)draw {! clear();! origin();!! translateZ(-4);!! rotateScene(arcb);!! noFill();! whiteStroke();! cube(0, 0, 0, img->width, img->height, img->width);! ellipse(0, 0, e.width, e.width);!! beginPixels();! for (float i = 0; i < img->width; i += step) {! ! for (float j = 0; j < img->height; j += step) {! ! ! getImagePixel(img, col, i, j);! ! ! float br = brightness(col->r, col->g, col->b);! ! ! pixelColor(i - img->width / 2, ! ! ! ! ! j - img->height / 2, ! ! ! ! ! br * fastsin(frameCount) / 2,! ! ! ! ! col->r, col->g, col->b, 255);! ! }! }! endPixels();

! frameCount += .1;!! gl.present(self.view);}

Tuesday, January 18, 2011

Page 11: Chameleon game engine

Live coding/deployment!ghter aircraft - model loading, environment, lighting, shadows

Tuesday, January 18, 2011

Page 12: Chameleon game engine

?

Tuesday, January 18, 2011