• Content count

  • Joined

  • Last visited

Community Reputation

138 Neutral

About corliss

  • Rank
  1.   Can you tell any 'tellable' explanations about this ? Is the API/SDK/code bad in some ways ? Code spaghetti maybe ?     I would recommend downloading the Lumberyard Engine from Amazon* ( see what some of the CryEngine code looks like. Lumberayrd is based on a recent version of CryEngine but has also been modified by Amazon as well. The download contains the source code for the entire engine, hence how it provides a view into what some of the CryEngine code looks like.   * disclaimer, I work for Amazon and on the Lumberyard Engine but what I write is my personal opinion and does not represent Amazon in any way, shape, or form. :)
  2. Game Engine Layout

      Basically people do this to separate difference concerns in the engine to make things more modular by reducing the dependencies between things. In the long run this helps with maintainability of the code base and the ability to swap things in and out based on different platforms the game is running on. In general the concerns about loading a resource are: How does an asset get loaded from disk  How is the asset data from disk transformed into something the engine can use (lets call the end result a resource) How are resources aggregated together   Most people will put #1 and #2 together, and some put all three together. At my job #1 and #2 are separate but #2 and #3 are sometimes put together.   For #1 we have an asset loading system that handles the platform specifics of loading things off of disk/disc/memory cards/etc. It also tracks if we already loaded the resource, how many references there are to the asset, etc. It does not know how to take the raw asset data and convert it to something use-able by the game.   For #2 there is the idea of a translator that gets called by the asset loading system that will get the raw asset data and translates/transforms the raw data into the actual item that was being requested (a texture, a mesh, a scene, etc). The translator can ask the graphics system to create the resource or could pass the data to a factory object that can then build the requested resource. The translators are separate from the asset loading system and are registered with it.   The factory system we use for scenes, materials, models and meshes do both #2 and #3. Once they have the raw data given to them by the translator the factories go about parsing the data and asking the graphics system to create the necessary resources (mainly buffers) or requesting the asset system to load the asset for it (such as textures and shaders), which is handling question/concern #2. Then the factory will call setters on the appropriate class (a Mesh, Model, Material, Scene class) to store the resources, handling #3.   The translator does not reference a factory directly but instead will create a class of the given type (a Scene for example) and will call a method on that class to load itself using the raw data passed in. The class internally uses the factory to do the work of parsing the data and everything else.   Here is an example flow for loading a material.   A scene will have in its binary data the material definitions it uses. So the scene factory will get the material chunk and ask the material factory to handle it. The material factory will parse the material data and figure out the names of the textures that the material is using along with the various parameters that will be set on the shader. To load the texture the material factory will request the asset system to load the texture by name and gets a handle to the asset in return. The material can wait for the material to be loaded by checking the asset handle (bad idea) or check it periodically until it is loaded (which we do).   In the meantime the asset loading system is getting the data and calls the texture translator. The texture translator will request the graphics system to create the texture (which returns an interface to a texture so that we can hide differences between different graphics APIs behind it) from the raw binary data and then puts a reference to the texture interface into the asset handle. This is the same handle that the material has a reference to.   When the material sees that the asset has been loaded, it gets the texture interface from the handle and adds it to its internal structure that holds references to the textures it needs.   Not all of our assets use factories. Textures and shaders are two examples where the translator will ask the graphics system to create the requested type instead of going through a factory. So the flow for loading these items is slightly different than the example. For example a render object that wants to use a particular shader will ask the asset loading system to load the shader. The render object will then periodically check if the shader is loaded by asking the asset handle. Once it is loaded and translated the render object  will get the shader from the asset handle and use it. No factories involved in this case.   So that is one way of putting things together without having the graphics system put it all together and associate it with the scene objects. I hope this gives you a different perspective on how things can be loaded and associated together in a game engine.   Not saying this is the best or right way, just a different way. :)
  3. Segmentation fault!

    Try initializing the array to all zeros before using it. This might be your problem. char filename[15] = {0}; I have a feeling that it is full of junk and when you do the strcpy into it for the NULL value that it does not termiante at the end of the NULL, though the printf should reveal this as the problem. You could also change strcpy to: strcpy(filename, "NULL\0") to force the placement of the null character at the end of the string.
  4. I would have to agree with hplus0603. The multiple derived classes can make the system more brittle and cause maintenance costs to increase, let alone updating the engine to handle new techniques in the future. [Edited by - corliss on January 10, 2005 11:14:50 AM]
  5. Direct3D 9: Transparent Surfaces?

    Not sure about getting the front buffer and storing it in the surface. Most of the books that I have seen have their own StretchRect code that handles transparency for them. Chris
  6. Direct3D 9: Transparent Surfaces?

    StretchRect has the same issue as CopyRect, which is a major bummer. I will take a look at the source files to confirm what I am thinking. [edit] So I looked at the sourec files and it will not work setting the color fill to be transparent or loading a transparent image onto the surface. What you will get is a black box. As a side note, I am not completely sure you need the BeginScene and EndScene calls since all you are doing is calling StrecthRect and not setting up texture stages, vertex buffers, and everything else dealing with 3D. Chris
  7. Direct3D 9: Transparent Surfaces?

    If you are copying the surfaces around then no, there is no transparency. If you define a surface with alpha and use CopyRect to copy it onto the back buffer all transparent areas will be painted black. To my knowledge the only way to get transparency when directly modifying the back buffer is to do it your self, i.e. traverse through the surface, one pixel at a time, and do a check to see if it is opaque or not. Chris
  8. Save a class to file, and later load it.

    Try using google with the word C++ Serialize. This is basically what you want to do: serialize the object to some persisent store. This may give you some ideas on how to do it. Chris
  9. I have wonered about this for awhile. At the moment my, possibly wrong, conclussion is that the order is still the same. Actually thinking bout it I think OpenGL has the order in reverse. So to create the modelview matrix you have to do view then model as you suggested in your post where as with DirectX it is model then view. Chris, another confused person.
  10. Directing obects after collision detection

    Here is how Torque does it: Vector3 bounceVel = currVelocity - normal * (Dot( currVelocity, normal ) * 2.0); Basically it works like this: Measure the angle between the velocity vector of the object and the normal of the object it is colliding with. Multiply the normal vector by that amount * 2. You have to do the *2 otherwise the new vector will not have the correct angle of reflection. Then subtract this vector from the velocity vector of the object that is moving around. This will give you the new direction the object should be going in. Simply find the point of collision and from there move the object in the new direction. Of course, it is not as simple as this as you have to deal with corners and other fun things. Since you are only dealing with 2D, you can simply drop out computations for z. Hope this makes sense. Chris
  11. OpenGL Engine question

    I am basically doing what mldaalder suggested. I have a CRenderer interface that describes the basic functionality of a renderer. Then I use class inheritance to buidl a DX renderer and an OpenGL renderer. I use DLL's so that I can in the future switch between renderers and have everything work. At the moment I am working on the DX side of things since that is what I am most familiar with and will then move to openGL later. To make this all work though I had to basically extract out the abstract ideas about rendering such as texture stages and different operations that could be applied to them so that the renderers can massage the information into the format they like.
  12. Shader Math Dyslexia

    OpenGL is column major. Seems like Microsoft decided to go a different directino for unknown reasons to me and made direct X row major.
  13. Singleton woes

    If you include a getSingleton method in the CLogger class it is not overriding but hiding the Singleton's method since you can not override static methods. In this case it may not be too bad but something to look out for.
  14. My guess would be that it would fail since the format of the image is different than the format that you specified. I do not think DirectX will do the conversion of formats for you. Anyone else feel free to correct me if I am wrong. Chris
  15. "you don't want to be creating class Avatar, class ServerAvatar, class PilotedClientAvatar, class RemoteClientAvatar, class ServerShadowAvatar,..." Another possible way around this is to do a policy based design as approached in the Modern C++ Design book. I am just looking into this style of programming and it could solve this particular problem: You have a template Avatar class and it takes in as a template parameter a policy on who is controlling it. Just something to consider when designing the engine. Chris