Render

After not a such long study of the engine I was quite favorably impressed by it.
Although there has been some disappointment. Unfortunately, it is lacking possibility to create objects not from the ini files, but in the code. It is not possible to draw triangles. The majority of third-party GUI libraries and PARTITSLES require such a possibility. This also prevents you from creating such objects as DistortionMesh

Comments

  • edited January 2011
    ret wrote:
    After not a such long study of the engine I was quite favorably impressed by it.
    Although there has been some disappointment. Unfortunately, it is lacking possibility to create objects not from the ini files, but in the code. It is not possible to draw triangles. The majority of third-party GUI libraries and PARTITSLES require such a possibility. This also prevents you from creating such objects as DistortionMesh
    I made a editor before for orx , using imgui which doesn't render by orx. besides, another android demo I made for a lib named recastnavigation also use some 3d features.

    Rendering some 3d feature is not as hard as what you said. you are able to draw whatever you want include the triangles, or other gui rendering in the eventHandler of orxRENDER_EVENT_VIEWPORT_START.
    if it is 3d, depth buffer is needed, depth is needed to set in the .ini config.

    If you need, I could send you my work related to this feature. Any details are shown in it.
  • retret
    edited January 2011
    Thank you, please, send it to me.
    [email protected]
  • edited January 2011
    Yep, as laschweinski said, you can do 3D rendering by listening to the render events.

    If you want to implement a 3D distorsion mesh, you can simply render your viewport to a texture and reuse that texture with your 3D mesh.

    Finally you can also create objects programmatically and completely bypass the config system. That will require a lot more code and is less handy. If you want to do so, have a look at the code of orxObject_CreateFromConfig(). It only calls other public functions to create and setup and object. You can do the same in your code.
  • retret
    edited January 2011
    3d does not interest me.

    I watched a function orxObject_CreateFromConfig () and it has created the following code
    orxOBJECT * orxObjectHelper:: Create (const std:: string & textureName, const RectF & rect)
    {
    orxGRAPHIC * graph = orxGraphicHelper:: Create (textureName, rect);
    
    orxOBJECT * obj = orxObject_Create ();
    orxObject_LinkStructure (obj, orxSTRUCTURE (graph));
    
    return obj;
    }
    
    orxGRAPHIC * orxGraphicHelper:: Create (const std:: string & textureName, const RectF & rect)
    {
    orxTEXTURE * texture = orxTexture_CreateFromFile (textureName.c_str ());
    orxGRAPHIC * graph = orxGraphic_Create ();
    
    orxGraphic_SetData (graph, (orxSTRUCTURE *) texture);
    
    orxGraphic_SetOrigin (graph, & (orxVECTOR) rect.GetOrigin ());
    orxGraphic_SetSize (graph, & (orxVECTOR) Vec3F (rect.GetSize ()));
    
    return graph;
    }
    
    unfortunately it did not work. maybe you give me for my mistake.
    but the next version was operational
    orxOBJECT * orxObjectHelper:: Create (const std:: string & textureName, const RectF & rect)
    {
    orxGRAPHIC * graph = orxGraphicHelper:: Create (textureName, rect);
    
    orxConfig_ClearSection ("ObjectTemp");
    orxConfig_SelectSection ("ObjectTemp");
    orxConfig_SetString ("Graphic", "GraphicTemp");
    
    return orxObject_CreateFromConfig ("ObjectTemp");
    }
    
    orxGRAPHIC * orxGraphicHelper:: Create (const std:: string & textureName, const RectF & rect)
    {
    orxConfig_ClearSection ("GraphicTemp");
    
    orxConfig_SelectSection ("GraphicTemp");
    orxConfig_SetString ("Texture", textureName.c_str ());
    orxConfig_SetVector ("TextureCorner", & (orxVECTOR) rect.GetOrigin ());
    orxConfig_SetVector ("TextureSize", & (orxVECTOR) Vec3F (rect.GetSize ()));
    return NULL;
    
    }
    
    but that option was not very happy because it is not easy.
  • edited January 2011
    If you're not interested in 3D, shaders is also a possibility for writing deformation effects.

    As for the code, it looks ok (beside lacking an orxFRAME which is the "coordinate" structure)
    However it's 5:40 AM right now so I'll give it another look tomorrow after getting some sleep! ;)

    EDIT: What is the main reason why you don't want to use the config system, btw? I mean, not in code as shown above, but by writing an actual .ini config file?
  • retret
    edited January 2011
    Your ini format is very flexible but it seemed to me cumbersome (take the creation of animations).

    ini:
    [RotatePizzaSign]
    DefaultKeyDuration = 0.1
    KeyData1 		= FramePizzaSign01
    KeyData2        = FramePizzaSign02
    KeyData3        = FramePizzaSign03
    KeyData4        = FramePizzaSign04
    KeyData5        = FramePizzaSign05
    KeyData6        = FramePizzaSign06
    KeyData7        = FramePizzaSign07
    KeyData8        = FramePizzaSign08
    KeyData9		= FramePizzaSign09
    KeyData10		= FramePizzaSign10
    KeyData11		= FramePizzaSign11
    KeyData12		= FramePizzaSign12
    KeyData13		= FramePizzaSign13
    KeyData14		= FramePizzaSign14
    KeyData15		= FramePizzaSign15
    KeyData16		= FramePizzaSign16
    
    [GraphicPizzaSign]
    Pivot		= center
    Texture		= ../data/buildings/infrastructure/infrastructure_pizza_sign.png
    TextureSize	= (128, 64, 0)
    
    [FramePizzaSign01@GraphicPizzaSign]
    TextureCorner = (0, 0, 0)
    [FramePizzaSign02@GraphicPizzaSign]
    TextureCorner = (128, 0, 0)
    [FramePizzaSign03@GraphicPizzaSign]
    TextureCorner = (256, 0, 0)
    [FramePizzaSign04@GraphicPizzaSign]
    TextureCorner = (384, 0, 0)
    [FramePizzaSign05@GraphicPizzaSign]
    TextureCorner = (512, 0, 0)
    [FramePizzaSign06@GraphicPizzaSign]
    TextureCorner = (640, 0, 0)
    [FramePizzaSign07@GraphicPizzaSign]
    TextureCorner = (768, 0, 0)
    [FramePizzaSign08@GraphicPizzaSign]
    TextureCorner = (896, 0, 0)
    [FramePizzaSign09@GraphicPizzaSign]
    TextureCorner = (1024, 0, 0)
    [FramePizzaSign10@GraphicPizzaSign]
    TextureCorner = (1152, 0, 0)
    [FramePizzaSign11@GraphicPizzaSign]
    TextureCorner = (1280, 0, 0)
    [FramePizzaSign12@GraphicPizzaSign]
    TextureCorner = (1408, 0, 0)
    [FramePizzaSign13@GraphicPizzaSign]
    TextureCorner = (1536, 0, 0)
    [FramePizzaSign14@GraphicPizzaSign]
    TextureCorner = (1664, 0, 0)
    [FramePizzaSign15@GraphicPizzaSign]
    TextureCorner = (1792, 0, 0)
    [FramePizzaSign16@GraphicPizzaSign]
    TextureCorner = (1920, 0, 0)
    
    

    xml:
    <Animation name="PizzaSign" texture="pizzaSign.png" delay="0.0666667" reverse="false" grid="0 0 128 64 16 1">
                <frame rect="0 0 128 64"/>
                <frame rect="128 0 128 64"/>
                <frame rect="256 0 128 64"/>
                <frame rect="384 0 128 64"/>
                <frame rect="512 0 128 64"/>
                <frame rect="640 0 128 64"/>
                <frame rect="768 0 128 64"/>
                <frame rect="896 0 128 64"/>
                <frame rect="1024 0 128 64"/>
                <frame rect="1152 0 128 64"/>
                <frame rect="1280 0 128 64"/>
                <frame rect="1408 0 128 64"/>
                <frame rect="1536 0 128 64"/>
                <frame rect="1664 0 128 64"/>
                <frame rect="1792 0 128 64"/>
                <frame rect="1920 0 128 64"/>
            </Animation>
    
    

    Those are two animations of the same object. It looks obvious that ini format is more heavy. Moreover, XML format is created in the animation editor and it's unnacessary to create it manually unlike in ini format.

    Also one often has to use third-party libraries, and often they use xml files. It is not reasonable to write a converter of their format into yours (this situation reminds me of XNA with its Content Processor). It's easier to write a parser for the engine
  • edited February 2012
    ret wrote:
    Your ini format is very flexible but it seemed to me cumbersome (take the creation of animations).

    You chose the perfect example as animations are the most annoying piece of config to write. I still hope a community-driven editor will be created at some point (Eyecreate and Laschweinski both started to make efforts in that direction). But that doesn't solve our issue for now.

    However there's something you can do to make your life better: use the config module to create the data at runtime (or to preprocess them offline and save them in a config file).

    After a discussion I had with Laschweinski a couple of weeks ago, I wanted to write a small tip-tutorial on the wiki but didn't have the occasion yet. Here's the basic idea.

    Instead of writing the full-fledged config info, consider something like this:
    [RotatePizzaSign]
    FrameTexture = path/to/your/texture
    FrameDuration = 0.1
    FrameTextureCorner = (0, 0, 0); ie top left corner where our anim is starting
    FrameTextureGrid = (4, 2, 0); ie 4 columns, 2 rows
    FrameSize = (128, 64, 0)
    FramePivot = center
    
    [Main]
    AnimationList = RotatePizzaSign # ...
    

    There you have all the informations you need! :)

    Now, at init, you can preprocess all your animation found in the AnimationList of the section Main.

    Your code will then:
    - loop through the list of animation and gets the string value
    - push it as a config section
    - create the associated texture (orxTexture_CreateFromFile(orxConfig_GetString("FrameTexture"), ...), don't worry, no duplicate will be hold in memory)
    - gets its size
    - store DefaultKeyDuration from FrameDuration with orxConfig_SetFloat() (yeah, it could have been done directly manually but I like having the same prefix for all the values I write as a human ;))
    - gets the frame counter (counter = frameTextureGrid.x * frameTextureGrid.y) and add as many keys with a name base on the anim (such as RotatePizzaSign_Frame##)
    - for all the frames above, we push its section, sets its texture, pivot, size and corner coordinate based on its index and the texture grid + corner (pos starts at frameTextureCorner, for i = 0 to frameTextureGrid.y, y += frameSize.y and for j = 0 to frameTextureGrid.x, x += frameSize.x), pops from its section
    - pops from the anim section

    You can of course create a base texture section and set the frames to inherit from it for the texture name, pivot and size as you'd do it if you had to write manually the config file. The code for the logic above shouldn't take long to write and should only be pretty small in the end.

    There you go, you have all the information you need to be able to create your animation/object from config now. You can either do that when loading your game, shouldn't be long to process as everything happens in memory, or you can choose to preprocess offline and save the config data to a file with orxConfig_Save() and use that file normally in your game.

    Also you can use XML as input and do the same piece of code, of course. I'm just using .ini as the input data here as it's what orx supports natively (and I don't care much for XML myself). You can expand this example with new information as you see fit, of course, such as using Reverse to set a Flip property or anything else you'd like.

    Hope this helps.
  • edited January 2011
    It's totally unrelated to your config issue, but you should consider not storing your frames horizontally as every horizontal line of a single frame won't be consecutive to the previous and next one. This will affect performances, both for sequential accesses and cached ones. You can find more info about this in the GPU gems #2.
  • edited January 2011
    yeah I made something to simplify the config for anim graphs.

    the attachment is the code. I believe it is simple to combine with your code, no other dependency is called in it.

    the modification I do in .ini is as follows:

    [NormalTanksGraphSet]
    Row = 2
    Column = 5
    Size = (26,32,0)
    CornerBegin = (0,0,0)
    Texture = BattleMapRes/normalTanks.png
    PrefixName = NormalTanksGraph
    Pivot = center
    ;Flip = y

    Here the origin graph's size is (26*5, 32*2)

    another orx based app I made is an tmx, it parse a tmx map to a config node stored in memory, which the dependend lib I use is tinyxml. it may be useful for you.
    Comparing with xml, I feel .ini format is somewhat more explicit for me. https://forum.orx-project.org/uploads/legacy/fbfiles/files/GraphSetLoader.zip
  • edited January 2011
    the dobulex parser is here orx and tmx both end with x B)

    There are some bugs please forgive me, https://forum.orx-project.org/uploads/legacy/fbfiles/files/doublexParser.zip
Sign In or Register to comment.