reprap: Delete mongoose
[simavr] / examples / board_reprap / src / c3 / README.md
1 libc3 - No frill 'scene' graph library in C
2 =====
3 (C) 2012 Michel Pollet <buserror@gmail.com>
4
5 **WARNING** This API is not your nanny. It is made to be lean, mean, efficient
6 with no frill, no asserts, no bounds checking, no sugar coating.
7
8 On the other hand it's fast, reasonably clean and is a micro-fraction of the
9 other giganormous 'scene graphs' or 'game engine' libraries around.
10
11 It's vaguely inspired by THREE.js funnily enough, because it allows you to
12 hack around and quickly get stuff on screen with the minimal amount of 
13 effort.
14
15 The API has various bits:
16 * c3algebra: C derivative of an old C++ piece of code I had lying around and that has
17 been present in my toolset for a long time. It gives you *vectors* (c3vec2, c3vec3, c3vec4)
18 and *matrices* (c3mat3, c3mat4) with various tools to manipulate them.
19 * c3quaternion: Quaternion implementation using c3algebra
20 * c3camera/c3arcball: camera manipulation, not perfect
21
22 The basic data structure is as follow:
23 * *c3context*:
24         Mostly placeholder for now, hosts a "root" object, can reproject the
25         objects & geometry, and call the callbacks to draw them.
26 * *c3object*: 
27         * Has a list of (sub) c3objects
28         * Has a list of c3transforms (ie matrices)
29         * Has a list of c3geometry (ie real vertices and stuff)
30   The object is a container for other objects, and for geometry itself. Objects don't
31   necessary have geometry and/or sub objects, and don't even need transforms if their
32   vertices are already projected.
33 * *c3geometry*:
34         * Has a 'type' (raw for simple vertices, texture, triangles etc)
35         * Has a 'subtype' (mostly can be used to draw GL types)
36         * Has a 'material' (ie color, texture... to be completed)
37         * Has a list of vertices
38         * Has a list of texture coordinates (optional)
39         * Has a list of vertices colors (optional)
40         * Has a cached copy of a vertices when it has been 'projected'
41 * *c3transform*:
42         Is just a sugar coated matrix, with an optional name.
43
44 Also there are:
45 * *c3pixels*:
46         Is just a wrapper/holder for some pixels, either allocated, or inherited, 
47         it's mostly used for *c3texture*
48 * *c3texture*:
49         Associates a *c3geometry* with a *c3pixels* and has a standard Quad
50         for vertices. The OpenGL drawing is not done there, it's done by the application using
51         the generic *c3context* driver.
52 * *c3cairo*:
53         Placeholder for now, inherits from *c3texture* and will contain a
54         cairo surface mapped to a GL texture.
55 * *c3pango*:
56         A text label, inherits from *c3cairo*
57
58 Draw Drivers "Inheritance"
59 ------------
60 Various object uses static tables of callbacks to implement their behaviours
61 it's kinda cheap c++ inheritance, without the usual bloat.
62
63 There just a couple macros to call the driver chain for a particular function call.
64 The relevant bits are in c3driver*.h.
65
66 Mostly the code looks for a matching callback in a static table, and call it if found.
67 If that callback wants, it can also call the inherited object callback too.
68
69 Dirtyness
70 ---------
71 There is a notion of 'dirtyness' in the tree, when you touch a *c3transform*, and/remove
72 objects and geometry, a dirty bit is propagated up the tree of object. This tells the
73 rendering it needs to reproject the dirty bits and repopulate the projected vertice
74 cache.
75
76 The 'dirty' bit moves both ways, when setting a dirty bit to true, it propagates upward,
77 when you set it to false, it propagates downward in the tree.