Original Post
Hello everyone! I have been working on a graphics engine from scratch (that I call AliquiX. I'm bad at names...). See details below. AliquiX Engine (Visual Studio 2003) Sample AliquiX App (Visual Studio 2003) The point of this post: That scene creates a line of twisting boxes with a light rotating around the first one (the light is rotating because of code in a listener not listed here). Screenshot (not too exciting, but just an example):
Thanks for everything. Edit: Fixed a lot of things with lighting, it's pretty much implemented now (besides optimizing and such) Yay, fun!
[Edited by - okonomiyaki on June 2, 2006 3:28:01 AM]
- I am asking experienced developers to look at my source code and help me code better. I am looking for constructive criticism. "Never do this...", "That's awful!", etc. I have been programming for several years but only recently have I been serious about C++ and graphical development. There is quite a bit of code here and you can look through it as deep as you like.
- I would also like comments on general design. How I manage entities, the scene, system components, vertex data and uploading buffers, lights, etc.
- I hope that people new to this area of development can use my source code to learn how to solve certain problems and see how something might work. Feel free to PM me or message here to ask any questions about it.
- Manage core components like the renderer, input, clock, scene, etc.
- A scene manager handles scene nodes that define hierarchal relationships as well as hierarchal transformations for objects.
- Entities define that objects that have some action to be taken each frame. Entities are added to the scene by attaching them to a scene node. Example entities: Mesh, Light, Camera.
- Shaders are written separately and meshes can be assigned any shader at any time. I will extend this to more an "effect" system where effects may run through multiple shaders for one object.
- Meshes are divided into chunks, and these chunks automatically manage their vertex data and give functions to deal with the data easily. When a shader is run, it requests that the chunk upload the streams it needs to run (if not already uploaded). The meshes can also interleave the data if it's not interleaved, or generate a new chunk to render its normals, etc.
- A resource manager deals with resources and re-uploading when needed. Vertex and index buffers are dealt with abstractly by pre-allocating space on the video card and managing the space with the resource manager.
- The whole engine is written abstractly. As of now there is only a DirectX renderer, but an OpenGL renderer is possible (though would be kind of difficult because the engine is similar to DX). I wanted to write it abstractly to make things clear and easy, but I'm not really going for full cross-platform/cross-API support.
AXScene *Scene = AXBaseSystem::GetSceneMgr();
Scene->AddSceneListener(new InputListener);
AXSceneNode *Root = Scene->GetRoot();
Root->CreateChildWithEntity(Scene->CreateEntity("Mesh", "Axes", "Axes"));
AXEntity *Box = Scene->CreateEntity("Mesh", "RootBox", "Box");
AXSceneNode *BoxNode = Root->CreateChildWithEntity(Box);
AXLightEntity *Light1 = Scene->CreateLight("Light1");
Light1->Type = AX_LIGHT_POINT;
Light1->Dynamic = 1;
AXSceneNode *LightNode = BoxNode->CreateChildWithEntity(Light1);
LightNode->Translate(0.0f, 5.0f, 0.0f);
AXSceneNode *LastBox = BoxNode;
LastBox->Translate(0.0f, 0.0f, 5.0f);
for(unsigned int i=0; i<50; i++) {
std::string Name = "Box" + AXStringConvertFromInt(i);
AXEntity *Box = Scene->CreateEntity("Mesh", Name, "Box");
AXSceneNode *RotatingBox;
RotatingBox = LastBox->CreateChildWithEntity(Box);
RotatingBox->Rotate(AX_PI/15.0f, AXVector3(1.0f, 0.0f, 0.0f));
RotatingBox->Translate(5.0f, 0.0f, 0.0f);
LastBox = RotatingBox;
}
AXEntity *Camera = Scene->CreateCamera("Player", 50.0f);
AXSceneNode *CameraNode = Root->CreateChildWithEntity(Camera);
CameraNode->Translate(0.0f, 0.0f, -5.0f);
Scene->ActivateCamera("Player");
Thanks for everything. Edit: Fixed a lot of things with lighting, it's pretty much implemented now (besides optimizing and such) Yay, fun!
[Edited by - okonomiyaki on June 2, 2006 3:28:01 AM]