Building our own 3D engine

Ok, the first thing we now need is a subforum for our project, where we can create different threads for each of the major task-groups that we are facing.

Rys, could you create a subforum here under 3D Architecture and Coding called something like "Beyond3D Forum Visualisation Project?"

Or maybe you would need an additional tree called "Beyond3D Collaboration Projects", and then have a subtree in there for "3D Forum Browser" or something similar, as I think there might be other projects already proposed.

Then in there we can create threads for the 3D Engine specifics, Art Creation, Data Interfacing, User Interface design, and Business Objects, to name the most obvious ones, and discuss the relevant project topics there.

It really sounds bigger than it is, I think - as I said, I would like to get something really basic out there fast and that should only take a few days. But since we are going to collaborate and take this as a learning process, I'm expecting the project to stay around for a good while as it grows into more advanced rendering techniques and features, so it's better to start with a good structure.
 
I second the idea of using Python, just as I second the idea of using OpenGL.

Python is powerful and extremely user coder friendly, you can't go wrong with Python.

Now, about the game design I rest my case concerning the 2D gameplay. By keeping it simple, you all make the game design, level creation, artwork a lot simplier and therefore it will raise the chance of creating a game that is actually good and complete.

Now imagine that, a 2.5D (3D graphics with a 2D gameplay) game with the latest 3D features... Awesomeness. Pure awesomeness.
 
Rys, could you create a subforum here under 3D Architecture and Coding called something like "Beyond3D Forum Visualisation Project?"
Personally, I think Rys/B3D needs to be a little bit more careful and stringent if this really is to be a serious endeavour by folks here that are serious about this. What you suggest should be the preferred thing but I'd like to suggest that such a forum be limited to those that actually register for such a project (or even this new forum) and furthermore that such registrations be vetted. Otherwise such a forum will probably have a lot of posts that really either serve no purpose or simply eat up time (which is a better way of saying "a waste of time").

And I think a straight-forward forum title like "Beyond3D Game Project" would be better. Your suggestion made me think that the B3D forum itself would be in 3D :)

Just MHO.
 
I like it. Especially the bit about an intermediate shading language as part of it. Can you give us a short introduction with some code snippets and how we could make an executable with a basic scene (just some primitives) and move them around?

Applications created with the code need to extend the 'Application' class (PX2.Application).
This requires implementation of a single abstract method, 'Initialise'. In here you do your window creation, etc.
Application has a Run() method, which starts up the message pump, runs initialise and lets rip. :)

When render target is created, it needs to reference an object that implements IFrameRenderer, to control the rendering. So most applications example's I've included also implement this interface. The interface has two methods, SetupFrame and RenderFrame.

So to make an exec that just pops up a window would be the following code:
(I've snipped out the using/namespace bits to save space)

Code:
	public class MyApp : Application, IFrameRenderer
	{
		protected override void Initialise()
		{
			Window window = new Window(); // set size here in alternative constructor
			this.CreateDevice(window, this); // create device on window, set IFrameRenderer as this
			window.Show();
		}

		public void RenderFrame(State state, SceneRoot scene)
		{
		}

		public void SetupFrame(State state, SceneRoot scene, RenderTargetPresentation presentation)
		{
		}
	}

If you want, you could put the window code in a for loop and create 10,000 windows. If you want... :)

To run it, in your static Main() method (which could be in this class) simple do:

Code:
MyApp app = new MyApp();
app.Run();


As for rendering something, thats pretty simple.

I've tried to make Vertex Buffers a half-way house between the byte copying of D3D and immediate mode of openGL.

Simple triangle example:

Code:
VertexBuffer vb = new VertexBuffer();

VertexBufferBuilder bb = vb.AllocateBuffer(VB.XYZ | VB.Colour);

bb.Colour(1, 0, 0);
bb.Vertex(-1, -1, 0);

bb.Colour(0, 1.0f, 0);
bb.Vertex(1, -1, 0);

bb.Colour(0,0,1);
bb.Vertex(0, 1, 0);

vb.FinaliseBuffer();

Index buffers are pretty simple too.

Code:
IndexBuffer ib = new IndexBuffer();

ib += 0;
ib += 2;
ib += 1;

ib.FinaliseBuffer();


To render something, you use the State object in RenderFrame().
State.Renderer has a bunch of methods related to rendering,
one happens to be State.Renderer.Render().
There are about 25 overloads for this method, so lots can be passed in.
The simplest one is:

State.Renderer.Render(vb);

would draw that triangle.
You pass in materials, shader constants, matrices, etc here too.

This won't be visible though, because the camera is at 0,0,0.
So... in SetupFrame, you could use:

State.CameraMatrix = Matrix.LookAt(....);


To get input, you would use a IInputDevice object, which can either use events, or buffer the input. Currently there is only a MouseKeyboardInput object, which hooks onto winforms events.


You can also wrap up the triangle in an Entity object, which lets you put it into a scene graph, etc. Currently though there are no partitioning scene graph nodes yet. This class also allows fixed frequency updating (eg, call Update() 100 times/sec).

Naturally there are lots of subtle things I've glossed over, and a lot more depth there too. But thats the really quick overview. There is also a boat load of things that are not implemented or incomplete.

Have a look in the PX2.Examples project, which has an Examples directory filled with the code to all the example applications you see in the Applications tab when running the front end. One, SimpleRendering is pretty much exactly what I've just written :)

Currently on my todo:

- thread state objects
- starting to implent an XNA renderer
- thinking about Tao: OpenGL/OpenAL
- csvorbis for Ogg streaming (this would actually be my first code import ;-)
- need to clean up a bunch of things all over the place. Scene graph intersection, texture support, certain shader things, etc.
- more caps checking. Currently I'm assuming you have a SM2 card.

But overall it's getting there.
 
Very nice introduction, Graham!



What we need most now is an engine team. A manager and as many contributing coders as we can get. What would be the best way to make that happen?
 
Okay, don't laugh as I'm a n00b at these things ... It'll take me forever to recreate something close to what I have in mind using Blender (or anything else other than writing some code, which I sometimes think is probably easier ;) ).

This image is just intended to jumpstart people's brains for looking at a forum in 3D. There's lots to be done to make this efficient and obviously better looking, but you get the idea I hope. In the end, the power of being able to zoom in and out, rotate stuff, and have all sorts of linked icons, could help in making some kind of nice looking 3d structure. Picture the graphics the forum has now but in 3d, combine it with this structure, and animate it with rotation options, highlighting and selection effects, and we're getting there ...

screendump.jpg
 
Otherwise such a forum will probably have a lot of posts that really either serve no purpose or simply eat up time (which is a better way of saying "a waste of time").

I don't think it is necessary to assume this from the get go. This is a fairly serious forum. Let's give people the benefit of the doubt - it will be easy enough to change this later.

Your suggestion made me think that the B3D forum itself would be in 3D :)

Well, that's exactly what I suggested, really! (As the picture above very clumsily suggests)

@Graham: I like your engine, but at this point I personally wouldn't want to introduce a generic layer like that just yet. In my view, our design should be modular and flexible enough to use any render object we write for it using any kind of technology, just as long as it can understand at least a part of the xml data that our business and data components produce.

Also for educational purposes, it would be at this point more useful to focus on the initial problems required by our application only, to do so with OpenGL but with the option for people to write a compatible 3D or higher level interface when that's what they want to go into.
 
Very nice introduction, Graham!

What we need most now is an engine team. A manager and as many contributing coders as we can get. What would be the best way to make that happen?

@DiGuru, how about you and me manage the start-up of this project together, and then we will see from there who will turn out to be good leads for the different categories of problems?

I think one of the best ways to get a lot of contributing coders is simply by having an exciting project that is showing results early and often. This tends to stimulate people into contributing ideas, code and art.

@Rys, I'm about to make a number of threads for the different task-groups. I will create them here, but feel free to move them to a subforum as soon as you have one ready. I think a subforum would be a great help, so that we don't have to add extra names to the topics to identify the threads as belonging together.

I've just been scribbling on paper and thinking about this idea some more. The current idea I have is this. It is a combination of design and control.

(One of the things I want to do is make this a breeze to control. )

You start with a 3D version of the Beyond3D logo. Below that, is a 3D Forum logo (assume everything is 3D from now on ;) ). Pressing the down 'key' (i.e. key, button, mouse, movement, whatever you link to it) releases the group of forums, which come dangling below on something of a 3d rotating rack/mobile.

This rack you can rotate left and right to bring into focus (in a direct line below its parent) the forum you are interested in. The point from which the different forums connect to the single connection to the 3D Forum logo is in itself a configuration device for setting preferences, such as the sort order of the items hanging below. This we will work out in more detail later.

The forum is represented as a 3D rendering of the current board/forum icon. Once we get to that level of detail, you should be able to zoom in far enough to view the basic forum information rendered on that board, or in one way or another.

Once you found the forum you like, you press down to display the subforums in the same way. Then come the threads. Threads will indicate visually whether they have a read or new item available. How exactly we'll have to work out.

When you pess down, you will see the same kind of mobile as always, with the same configuration interlink, but this time you will by default only get the first post and the first unread post / last post in the thread. Select these and press down, and you will get the next post from the one you selected, if available. At this point you should be able to zoom in on individual posts so much that you can actually read them. But this we will get to eventually, and probably in different versions. I suggest we simply start with a more basic one that can activate a link to the specific post online and bring up the browser, and try to work in our own text-renderer (and edit box) eventually.

We will have to think of some kind of visual compression system that does something similar to page building, though I am currently more thinking also of more advanced options in the configuration device / connection point.

Similarly, going back all the way to the top, you would have a search button, and that would again build a structure like the above, but this time with the search results, mimicking the above depending on whether you selected posts or threads as a result.

From this I gather we at least need the following:

- we need to design a 3D User Interface including buttons, objects, icons and so on. They have to support certain kinds of events, have properties to set them and so on. All these will be defined in XML so we can let them support different features dynamically, and applications/renderers can support different aspects dynamically. Also, they will have to support different state changes. These state changes will be defined in xml again, but they can then separately be linked to 3D effects. For instance, a focussed object could be enlarged, brightened, lighted from within, lighted from without, have all sorts of fancy shader effects and so on. Selected objects, ditto.

I therefore invite 3D artists to start designing some nice basic 3D icons (for instance the ones I described earlier, one for a forum, one for a thread, and maybe some alternates for forums and threads with new items, etc.

Special attention should be put to how we determine the way they scale, etc.

This is going to define the basic features that our renderer should support, so for many here will definitely be the most interesting part of the project.

- we need to define a decent xml description for the kinds of objects we need, and list the features they need to support. This shouldn't be too hard, just so long as we define a basic structure that is easily expandable (I have lots of experience with this and should be a breeze)

- we need to put some sample xml structures of the basic forum structure together in a way that could resemble what we can get from the forum software eventually. I'll be happy to get something like that out there also.

Are you guys with me so far?
 
@DiGuru, how about you and me manage the start-up of this project together, and then we will see from there who will turn out to be good leads for the different categories of problems?
Ok. But we need some real 3D engine expertise as well.

Graham, do you want to spend time on this as well?
 
Ok. But we need some real 3D engine expertise as well.

Of course we do, but that's why I said: "and then we will see from there who will turn out to be good leads for the different categories of problems"

Graham has already indicated that he's limited in time especially taking into account his own engine. But when we're far enough into our system, we can of course evaluate Graham's engine for our project.
 
Go ahead with exploring that. I think it can be very useful. In the meantime though, I will be more concerned with the design and prototyping phase.
 
Go ahead with exploring that. I think it can be very useful. In the meantime though, I will be more concerned with the design and prototyping phase.
That sounds like a nice division of tasks. Feel free to include me in that picture as well. ;)
 
Believe it or not but thinking about the 3D User Interface for the 3D Forum Browser is starting to create a vision in my head of a completely 3D Desktop / Web Interface, and as scaleable and skinnable as they come to boot.

When you look at the whole collection of different user-interfaces that you are constantly dealing with, the one thing you always see coming back is hierarchy.

For instance, you have the Start button, and when you press that, it leads you to more choices, in the Launch Bar. When you choose one of those, say Control Panel, you get a Window with more options but this time shaped as large icons. When I then choose, say, Regional Settings, I get a window with 3 tabs, and on the first tab , I have 2 sections. In each section, I have a few input options, which in turn allow me to choose from a large number of additional options.

But also if I had gone from the Launch Bar to Internet Explorer, I could have gone to its main menu and choose Bookmarks, then I would have been able to select Beyond3d Forum either from a list or a sub-menu (depending on your browser), and then on Beyond3D there's the menu on the side which has a number of options from which I choose 'Forum', and from here then I can go to 3D Technology Forums, 3D Architecture and Coding, etc.

Even when you build up a forum post, it consists of paragraphs, sentences, clauses, words, characters.

And whichever way I travel through the options, I create a path of choices, right down to the next character I am going to type, or the next enemy I'm going to kill, or the next photo I'm going to copy from my digital camera.

So I'm envisioning a user interface where every starts from a 3D 'Start' button (could be anything of course, 'Home' is nice too) and becomes a path of 3D user interface items which you can choose between. Being 3D, you would be able to zoom in or out to determine your location as much as you like, or bring into focus a text-entry field like this one I'm typing in right now so I can comfortably see what I type, but then zoom out to bring other items into view where I can copy text from, for instance.

Even popup windows and their submenus fit in this structure, and could simply be a continuation of the same kind of structure with a special link to a text editing control.

When I am doing multiple tasks at once, I will be able to have (and see) multiple paths running from my Start/Home location. I can store such paths for later reuse (quick-links/shortcuts/macros all in one), or leave them open and save them for continuing after I've rebooted my computer.

I solve all useability options by being able to navigate every choice and next step using down ('enter/go into/go down one level'), left / right (select next/previous item) and up ('escape/go out of/go back up one level').

But also, I will be able to zoom in or out on any step / option as much as I want to, so I can make optimal use of the ability of both my eyes and my monitor.

And of course, the controls can make use of the fact that they are rendered completely in 3D. I'm sure we'll be able to find some use for that even beyond the aesthetics eventually. ;)

My mind and imagination is running away with inter-program communication options and stuff, but I'm going to stay focussed on this right now, and apply it to the forum for now.

Hopefully at least one other person is enthusiastic about this 'insight' (which no doubt some other people already have had too, that's in the nature of a planet with 6 billion people after all), enough at any rate to work with me in realising it. ;)

And if not, I'll just have to try to do so on my own. ;)

Please shout out if any of this isn't clear, or you can't visualise it. I can, and I'll be working on getting some of this visualised, as well as make designs that allow others to help with this.

I'll be coming up with some basic XML stuff for this soon, and I hope that I can make some kind of basic prototype for the user interface myself, so that it becomes more tangible to others. Of course, if someone sees the light here and feels up to the task, feel free to join in! ;)
 
I don't know if you guys want to use this, but I'm developing a generic way to implement interfaces via the magic of C++ template metaprogramming. The main benefit is no run-time overhead and the ability to do complex multi-step conversions between the interface an type provides and the one you want to work with. To assist with this thing, I'm working on an enhanced version of Boost::parameters to deal with the forwarding problem. It'll probably take a couple more weeks before it's really usable though, as I'm doing it in my spare time.

I also have a cool thread-safe garbage collector I wrote a while back. It also doesn't interrput your application and you can partition the memory space into groups collected at different rates or with entirely different collectors/allocators. I haven't done really strenous performance tests though, so your milage may vary but it should be reasonable. If you want to use any of this, let me know.

However, at this time I will only give a liscence for B3D and the code can't be distrubuted. This will likely be temorary, until such a time that I feel the code is good enough to make fully public.
 
Arwin, love your ideas. DiGuru... love your enthusiasm but hate your ideas. NARF! just kiddin'. ;) I was originally supposed to help write plot and dialogue for the game but as we seem to be less interested in building from the top down, and more interested in building from the bottom up (by my orientation anyway), I'll just contribute ideas where I can. Sadly, my programming skills are far too rudimentary to help much, but if we get to a well developed scripting stage, I might be able to help a bit there.

I'm pretty gungho about functionaltiy here. We are talking about spending a lot of time working on a 3d engine, time that seems wasted if it doesn't net significant functional advantages. One thing I find attractive (though perhaps visually messy) is the idea of naturally-developed cross-linking. Forgive my terminology, I'm not well-read on any of this, but as we discussed in one of the countless Vista threads, my favorite feature of XP is the "small icons" start bar. XP does the grunt work of collecting your most-used icons in a single place for you, which is pretty nice -- i rarely have to delve further into the start menu (or into my own, more colossal icon collections) to find what i want to use. What I'd like to see in b3d is some aggregation of visits and links. The Subscription folder is great for this. Even better would be, if you could view, based on the threads you subscribe to (or visit, with weighting given to those you visit often), threads other people who also subscribe to these threads subscribe to. XD did that make sense?

Similarly, I'd love to see ways to create user-specific "forums" which are ways of collecting and displaying the data found across these boards. For example, I want to know about all things "RPG", "ATi", "SEGA", "stock", "music" and "photoshop". I also want my favorite posters (those i have repped the most or friended, and perhaps also those who subscribe most to what i subscribe to most) to be prioritized, so if DiGuru and Arwin are having a great discussion about SEGA RPG soundtracks, I want it to be near the top of my subscriptions list.or perhaps glowing more brightly, if things are kept in time order, so I can see it's not new, but if I haven't visited in a couple weeks, I might want to check it out. This could also help keep multiple threads on common, identical topics to a minimum. If we're all aware that there are already six threads on Vista, we might not feel the need to add another -- but moreover, perhaps with this display system, it wouldn't matter so much if there were six similar topics on Vista in six different places. They wouldn't be squeezing out other topics so much, since only the people who wanted to see them would, and we'd all be more aware of what's being said around the board, to reduce repetitive links to external sources, and also to reduce the obligation to read a 30-page thread at once before posting on a topic. These are the things I'd be interested in seeing, functionality-wise. Even better would be if the system could determine whether DiGuru and Arwin were arguing, and repeating themselves over and over, and could label it as one to avoid, but I have my doubts about this feature's reliability... ;P

Pipe dreams, perhaps, but I do think the latter idea might be aided by a 3d/more graphically-dynamic interface. The key things I'm noticing here are that 3d isn't so much about what it can bring to us spacially, or how many things can be modelled, but just in providing us a way to render text dynamically all the time -- relatively easily providing 32-bit variations in colors and placement (perhaps lighting or shading effects?), to enhance each bit of data's significance. These things could be accomplished in 2D, too, but the exisiting 3D frameworks seem ideal for it (with perhaps one glaring excpetion -- bandwidth).
 
Last edited by a moderator:
Awesome, you completely got what it's about! That's great to hear, very motivating. :)

I'm fairly certain you'll be able to help - thinking about the functionality like this is a very important part of a project. Not only does it help you determine the scope and flexibility you want to put into the design, but it is almost like a mental beta-test. Can the design I'm thinking about deal with this? Can it deal with that? Etc.

Right now I'm in the mood for taking a week off and starting to work on this for a few days in a row, but unfortunately I have a pile of work to do in the office, so I can't. But I'm going to try to put as much work into this as possible anyway. I want to formulate some basic requirements, so that people who want to work on the 3D engine (as that's what many people here are still most interested in, and is eventually also getting the most time and energy) know where to start.
 
Ok, here’s my vision so far …

Each user interface element is going to be an independent object. At least, in principe … in practice, we are probably going to compile them in at launch time, but that also depends on what platform we are going to use. I actually encourage people to write different language versions, as with a clear specification, that should be easy enough to do. The general purpose could should be relatively small and efficient, and most of the work goes into thinking it out. Once that is done, translating it to any language C or up (bar, say, Prolog) should be a relative breeze.

A User Interface object should in fact be seen as a complete program in itself. It’s user interface rendering is also going to be its Icon, basically (should that point out not to be practical, then it will simply have to present itself as something that looks nice in ‘icon’ form, and then transfer/animate nicely from there upon activation, and back again.

To make this technically possible, the Interface will run (or at least be able to, and certainly at first) only the focused object, and that object will have its fullest attention. This also means that when not active, the object will really just be a small, static mesh. Too much animation at this point would also really create a headache, I think. ;) But I do foresee we will make exceptions later, giving an option to specifically allow certain applications to remain active (I hate it anyway when Word starts going ape using loads of processing power because it is trying to grammar and spell-check my documents in the background … ;) )

A few examples of these:

- a mini-game, like a Rubic’s Cube, will look like a 3D Rubic’s Cube. Once you activate it, you can zoom in on it and additional controls to interact might appear

- google earth, say, would look like a 3D earth, and you would just zoom in a lot, basically. ;) You get the picture.

- images, sound, movies, etc. will get some nice system defined look as you would expect them, but rather than as individual movie files, they will be presented in the form of the player they are associated with. Upon activation you will simply be able to zoom in on them. If multiple players are supported, each player will also be present as a child of this item when it is selected, so you can play the movie/sound/image with the alternative player object, or play several selected objects at once with the alternative player object.

- Links can be attempted to render the object they refer to if possible, with options to download manually or automatically, etc.

User Interface Object

So, a user interface object being an independent little animal, it has a fair deal of functions. Here are the main ones I foresee:

- output generic 3D Mesh Data

The UIO will generate its own 3D Mesh Data reflecting its status, reactions to user input and so on, that will be forwarded to the Renderer by the main application object (‘MAO’)

- subscribe to events/messages

The UIO will tell the MAO what messages it is interested in – basically info coming either from the OS (e.g. user input or data that is exposed by other Objects that this object has indicated to be interested in)

Examples of messages it may get from the MAO are ‘Focus’, ‘Start’, ‘End’, etc., as well as user-interface messages and such (key input, controller movement, etc.). Additionally, it will receive information on what effects are supported and what its resolution is. This way it can make optimal use of the available visual effects but also provide good fall-back support, and be object will then be able to display itself optimally depending on whether it has 100 pixel3 available vs 1000 pixel3 available.

- generate events/messages

Examples are ‘I’ve changed, so redraw me’ (Refresh/Redraw), ‘I’m done, so close me (Close)’, but also ‘I want to spawn child objects’ (SpawnChildren) for instance containing configuration options, or draw a new object of type x with parameters y. Or, I have obtained a certain value state or collection of values, available to objects that have subscribed to some of this data.

- accept and return configuration/state settings

Basically the object will be able to have its state loaded and saved. Take the example of the 3D Rubic’s Cube. The OS could ask it to give up its current state to save and restore the same object or a copy of it later. The state information could include the position of the individual scares on the cube, and user options like choosing to ‘light up’ the yellow squares, graying out all other squares, making all other squares transparent, and so on. A movie player object would return the position of the current movie being played, so that a user can choose to continue here later.

- publish (upon request) what kind of parents it supports (optional) and what kind of data it exposes.

This will allow other objects to see what kind of information they may be able to receive from this object, and it will allow the MAO to link this object to any supported object type (think again about the relation between a viewer and a file type)

Renderer

So, the Renderer will receive a pack of 3D Mesh information from the MAO/OS which compiles the 3D Mesh Data that the objects have exposed and information on the view settings, and the Renderer will go to work. The Mesh data is still going to be somewhat hi-level; the Mesh information will simply say ‘this poly should reflect and be transparent, bump mapped, or whatever’, and the Renderer will have to try and achieve as much of the effects as possible without taking too long.

The Main Application Object

The MAO itself will expose system messages that UIOs can subscribe to, and have a few objects of its own that you can use among others to indicate what kind of effects you want to turn on or off, the level of refreshing activity, and so on. We will also try to develop some kind of automatic load-balancing and feature detection, but at the beginning it is always better to have something fully configurable, for testing, and for later when people who prefer that kind of flexibility.

The MAO will control the overall camera / view settings for the renderer. I was thinking that by keeping the OS/CTRL or whatever key pressed (if you can overrule the Windows key to start up the start menu, of which I’m not sure at this moment), you can use the mouse to rotate the whole user interface if you so desire, while using the keyboard for going through the objects, normal key down activating the next child, while shift-down would allow you to focus onto the next object without activating it so you could run up and down the tree quickly. Once an object is activated, it will be able to take care of most input and won’t be interrupted by the MAO until it considers itself finished.

The rotation part is actually a bit complicated, as I’m thinking it will be rare for the whole scene to be rotated, and instead I would only want to rotate a certain object tree. Think here about a pole with three circular clothing racks or postcard racks, where you only want to rotate the middle rack. Also an interesting question is if you’d want the objects to keep facing the camera by default even if you rotate a structure. I’m thinking yes, but I’m also thinking, let’s keep this simple for now and stick to only zooming objects in and out. ;)

Next Up

Next up is how the 3D Forum Browser would work using the roughly outlined model described above. No doubt this will both make things a bit clearer and force us to fill in some of the details or make some adjustments. And then we should just start making it work, going for a quick win first, getting something visible done as fast as possible to start with. I may even use my simple text renderer for it, if noone else with more graphics experience chimes in. ;)
 
Back
Top