struct VertexDeclaration
{
// |- RKVertex (RKBuffer containing RKVertexDeclaration - describes channels: pos,norm,texcoord,skinning,color + sizes: float,short etc)
// (up to 12 channels)
};
struct Buffer
{
size_t size;
void* data;
};
struct Shader
{
const char* text;
uint32_t state;
uint32_t shaderId;
};
struct Material
{
vec4f color;
uint32_t flags;
float diffuseCoefficient;
float specularCoefficient;
float refractiveIndex; // fresnel ratio is calculated from angle and refractiveIndexes
//parameters: lighting, uv anim/env mapping params, blending
struct
{
Shader* shader;
Shader* shadowShader;
Texture* textures[6];
} doubleBuffered[2];
};
struct Camera
{
mat4f matrix;
};
struct RenderLayer
{
std::vector<GeometryChunk> chunks;
// chunk buffer
Texture targetTexture;
Texture inputTextures[16];
Camera customCamera;
};
struct GeometryChunk
{
vec4f position; // relative to model
vec4f quaterinon; // relative to model
Material* material;
Buffer* indexBuffer;
Buffer* vertexBuffer;
// Render Layer pointer
// Type - tri strip, lines, tris etc
// Light info, sort priority, custom data
};
// Levels contain Objects
// Objects are in a hierarchy (parent and list of children)
// Objects contain a Renderable, also collision volumes
// Objects are RKTransformObjects which are RKPersistentBases, which are serializable/de-serializable named things
// A Renderable can be a model, sprite, anim, text, batched model, billboard, image, particle emitter etc
// Assume everything here is in a local coordinate system centered at 0,0,0
struct Model
{
float radius; // radius of bounding sphere
vec4f size; // bounds w,h,d (ie: center.x - w/2 -> center.x + w/2)
std::vector<GeometryChunk> chunks;
};
// SceneObject could contain higher level things which have position
// GameObject, Actor, Component, Entity
// SceneObject -> SpatialObject (object with position and occupies space)
// (occupies space -> implies only one object in a given pieces of space)
struct SpatialObject
{
vec4f position; // center of object
vec4f quaterinon; // object's orientation
float scale; // uniform scale
Model* model; // model data
};
// Instead of storing vectors of objects
// Sparse pointer based octree
struct SceneOctree // SceneGraph
{
struct SceneNode
{
union {
SceneNode* children[8] = { nullptr },
SpatialObject* objects[8] = { nullptr },
};
};
SceneNode rootNode;
float resolution;
};