Advertisement

Engine design question

Started by November 26, 2000 04:43 PM
4 comments, last by TheGecko 24 years, 2 months ago
Hey people, OK I''m in the process of designing and programming my 3d engine.I got all the basic initialisation stuff done and all works fine so far.However,I bumped into a little problem that I don''t know how to go about it.Bare with me while I try to explain. I have an Actor class that I programmed a while ago that basically loads a mesh from my file format.This class is responsible for animating my mesh and drawing it to the back buffer.My problem now is how would a programmer using my engine go about creating an Actor using the engine and not creating an actor object directly from the main program? This needs to be designed in a way such that my engine''s Render() function is the one that calls the rendering function of the Actor object while still giving the user control over the Actor itself.(The user basically sets what type of animation to play,where the actor is located in the world,monitor health etc.) My initial thoughts were to create an array of Actor objects INSIDE my engine class and giving it a limit (64 for example) and then the programmer can call the "CreateActor()" function with a whole bunch of parameters and my engine will then assign one of the Actor objects in my array to him.This is not a very efficient design and,as you can see, has a limitation as to how many actors a programmer can create. How does ,say,the Quake3 engine handle these things? Or any other engine for that matter? Any thoughts? If you guys are still unclear about what I''m asking,I''ll try to explain it in a little bit more detail.
Basically you want to type:

lpActorEngine->CreateActor(szName, lpvec3dPosition);

...and have the engine handle it internally?

Well why not use linked lists or vectors (since vectors might be a little more memory-efficient and better for searching/sorting) to store the data dynamically? That way the limitation is based on the developer''s hardware and not some hard-code limit in the engine?

Of course if you had Shareware and Full versions of the engine, you could impose software limits for shareware, and remove the limits for full version upgraders.

Just some individual thought processes...


MatrixCubed
http://www.MatrixCubed.org
Advertisement
Yeah I''ve though about using linked lists (and most prolly I will be) but then I still have the problem of how I''m going to give a reference of the newly created actor back to the programmer.

My engine design doesn''t permit the outside programmer to access all the little engines inside my big engine.Basically the way it goes is something like this:

lpMyEngine->CreateActor();

and this will in turn will create a new actor object inside the main engine.

The one solution that I can think of is to return an integer back to the programmer (a sort of id code) so that he can from there do whatever he likes.So if the programmer created 10 actors and he wants to change the animation sequence of the third actor from say "Shoot" to "Walk",then he would do something like this:

lpMyEngine->ChangeAnimSequence(3,"Walk");

That''s my initial thought.I don''t know whether this method will be efficient or not.Time to whip out my profiler I guess Any opinions?
I''ve got an engine question as well, and I thought it might be a good idea to put it here....

Here''s my situation. I have an application class, and most of my systems need access to it (to get important system variables, such as HWNDs and timers). I want my client program to create an instance of this class.

I''m wondering if people consider it "good programming practices" to have a global pointer to this application class stored in my DLL ("extern ... Application * mApp" ). Then, in my program, I simply call "mApp = new Application(...);".

I tried using "SetApplication() / GetApplication()" functions, but I got memory errors. Or is there a better way to do this?

Any feedback is greatly appreciated!

Simon Wilson,
XEOS Digital Development
XEOS Digital Development - Supporting the independant and OpenSource game developers!
You can create the Actor object inside your engine and return a reference number to the programmer. The programmer does not need to care or even know what the reference number means. So you could return a simple index number or even return the pointer to the Actor object itself. The programmer will not know what the number means and since the programmer does not know the internal structure of the Actor object, he/she would be very stupid to attempt to modify it directly.



Steve ''Sly'' Williams
Tools Developer
Krome Studios
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Factory Method:
The engine has a CreateActor function that constructs an Actor and returns a pointer to it.

Then:
It is the main apps responsiblity to provide an efficent container, whenever you want to manipulate an actor you pass an actor pointer to the engine method. You provide an iterator to the engine to rip through all the actors for rendering.

Simplest method, main program has an Actor array, arActors, and call you would do something like engine->Render(arActors, num_of_actors);

Or you could use some STL stuff and pass a container and/or iterator pointer to the render method.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement