Tagged: Ogre3D Toggle Comment Threads | Keyboard Shortcuts

  • frankiezafe 19:45 on 2017-04-24 Permalink | Reply
    Tags: , Ogre3D, , ,   

    Long time no see, but polymorph engine development is back on track!

    The XML describing a polymorph’s project is now able to configure the Ogre’s compositor, understand the post-processing module.

    The first screenshot is using a custom compositor with this configuration:

    <workspace name="TuningScoreWS">
      <script group="General" workspace="CustomCompositor" />
      <colors>
        <color name="background_center" value="0,1,0" node="0" pass="1" index="4"/>
        <color name="background_border" value="1,0,0" node="0" pass="1" index="8"/>
      </colors>
      <variables>
        <variable name="centerx" value="0.5" node="0" pass="1" index="0"/>
        <variable name="centery" value="0.5" node="0" pass="1" index="1"/>
        <variable name="radius" value="0.9" node="0" pass="1" index="2"/>
        <variable name="ratio" value="1.777777778" node="0" pass="1" index="3"/>
      </variables>
    </workspace>
    

    The required files for this compositor (shaders & nodes) can be found in the samples example.compositor.

    The second screenshot is using a default compositor, where only the background color can be modified.

    <workspace name="Default">
      <colors>
        <color name="background" value="1,0,0"/>
      </colors>
    </workspace>
    

    The documentation about the XML is here: https://bitbucket.org/polymorphteam/pe.2.0/wiki/xml-specifications

     
  • frankiezafe 21:10 on 2017-02-22 Permalink | Reply
    Tags: , , , Ogre3D   

    Several hours of work later, the class PMaterial is fully integrated to PNode. This part has been tricky: materials and textures are shared objects, managed by managers below the objects.

    The approach is to create PMaterial on demand, when you call pnode.getMaterial, for instance. Once created, it stays in the pnode until you destroy it or overwrite the material with another.

    This limits the memory consumption and force the coder to always retrieve the material pointer from the pnode, and not to store it.

    Another cool feature of the pnode.getMaterial is that the material can be created RT if the mesh doesn’t specify one.

    On the PMaterial level, it is becoming very easy to add the methods to access the different layers of the Ogre material.

    For instance, here is the code used to create the 2 materials applied on the balls in the image above:

    pmat_even.create( "Test", "Nice material" );
    pmat_even.diffuse( 1, 0, 0 );
    // activation of fog
    pmat_even.fogMode( Ogre::FOG_EXP );
    pmat_even.fogDensity( 0.1 );
    pmat_even.fogDistance( 10, 15 );
    pmat_even.fogColor( 0.4, 0.4, 0.4 ); // same as background
    // cloning pmat_even in pmat_odd
    pmat_odd.clone( &pmat_even );
    pmat_odd.fogColor( 0.8, 0.8, 0.8 );
    pmat_odd.shading( Ogre::SO_FLAT );
    // adding a pass on the material
    pmat_odd.addPass();
    // there are now 2 passes in technique 0 of this material
    uint tid = 0;
    uint pid = 1;
    pmat_odd.emissive( 1,0,1, tid,pid );
    pmat_odd.shading( Ogre::SO_FLAT, tid,pid );
    pmat_odd.polygon( Ogre::PM_WIREFRAME, tid,pid );
    

    It’s super easy to clone a material, at creation or via the clone method. The second pass of the odd material have to be set manually. Passes are not cloneable (yet?).

    As you may notice, mentioning the technique or pass to attack is optional. If your material has only one technique and one pass, the call is very short. Once you beginning to build a more complex material, adding 2 uint at the end of your arguments should not be too difficult…

    The material of the cube is also created manually:

    PMaterial pmat2( pmat_even );
    // disabling the fog
    pmat2.fogMode( Ogre::FOG_NONE );
    pmat2.diffuse( 1, 1, 1 );
    // checking the number of textures
    if ( pmat2.getTextureUnitCount( ) == 0 ) {
    	// adding one 
    	pmat2.addTexture( "General", "child-computer.jpg" );
    } else {
    	// modifying the first one
    	pmat2.setTexture( "General", "child-computer.jpg" );
    }
    cube.material( &pmat2, true );
    

    More, soon!

     
  • frankiezafe 13:38 on 2017-02-17 Permalink | Reply
    Tags: , , , Ogre3D   

    new class in package: PMaterial.

    This class is an helper that simplify the access to the multiple layers of Ogre’s materials.
    There are 3 levels in a material:

    • technique
    • pass
    • texture units

    The usual Ogre way to access to modify a pass diffuse is looking like this:

    Ogre::MaterialPtr ptr =  Ogre::MaterialManager::getSingleton( ).load( "mat", "group" );
    ptr.getTechnique(0)->getPass(0)->setDiffuse( 1,0,0 );
    

    Using PMaterial, it looks like this:

    polymorph::PMaterial ptr;
    ptr.load( "mat", "group" );
    ptr.diffuse( 1,0,0 );
    

    Selection of technique and pass is optional. The image above shows the fog configuration:

    pmat.fogMode( Ogre::FOG_EXP );
    pmat.fogDensity( 0.1 );
    pmat.fogDistance( 10, 30 );
    pmat.fogColor( 0.4, 0.4, 0.4 );
    

    All methods are not yet there, do not worry, they will come soon.

     
  • frankiezafe 22:39 on 2017-02-10 Permalink | Reply
    Tags: , , , Ogre3D, ,   

    I’ve learned something really important today: an OpenGL context can be accessed by one and ONLY one thread! See Under what circumstances would glGenBuffers/glGenBuffersARB fail?.

    And this is the first time I feel annoyed by the singleton approach of Ogre3D. In my asset converter util, I use Ogre object, the MeshManager mainly, to convert xml files to .mesh files. Due to the limitation of OpenGL and the singleton pattern, I can’t declare a new OpenGL context in my conversion thread by using the Ogre managers…

    I struggled for several hours with that before find the post on stackoverflow.

    This implies a freeze during mesh conversion, wich prevent me to animate a progress bar and keeping the conversion strickly in background.

    I’ll work on the loading and display of the processed meshes next week.

     
  • frankiezafe 18:46 on 2017-02-08 Permalink | Reply
    Tags: , Ogre3D, ,   

    I’m currently working on a more user friendly mesh, skeleton & materials converter.

    For the little story, when you export a model from blender, the blender addon outputs xml files. These files have to be parsed by the OgreXMLConverter to produce the final files. *.mesh & *.skeleton files are binaries.

    It’s a tedious process, especially when you want to organise your files in the folder structure of the application.

    The polymorph xml converter wlll make this a bit more handy (when ready):

    • hotfolder: define the folder where the blender exports lands after export;
    • output models: define the folder where the .mesh files will be exported after conversion;
    • output skeleton: define the folder where the .skeleton files will be exported after conversion;
    • output material: define the folder where the .material files will be moved;
    • output textures: define the folder where images will be moved;

    These paths will be saved in a preference file next to the application, to avoid having to reset them each time you open the application.

    A demo will come once it will starts to work. For the moment, only the GTK filechooser is plugged in.

     
  • frankiezafe 19:56 on 2017-01-29 Permalink | Reply
    Tags: Camera, , matrix, Ogre3D,   

    New example showing how to go from world space to camera space.

    A bit of explanation.

    The black sphere is attached to the pink camera. Therefore, it is located in the camera space, meaning that its position, rotation and scale depends on the camera ones. By default, the sphere is static in the point of view of pink camera.

    The pink camera is rotating around the world center.

    An empty, represented as a XYZ axis, follows the mouse position.
    If the space bar is hit, position & orientation of the empty is converted into camera coordinates.

    Vector3 p = custom_cam.worldToCam( empty.getTrans( ) );
    Quaternion q = custom_cam.worldToCam( empty.getOrientation( ) );
    

    The values are then applied on the sphere:

    ball_cam.move( p );
    ball_cam.orientation( q );
    

    By doing so, the ball is placed at the exact same location and orientation as the empty, relatively to the pink camera.

    note: the 256×256 square at the top left of the images is made with overlay manager, not yet simplified in polymorph namespace.

    The example is available in samples/0.1/example.cam_space

     
  • frankiezafe 22:03 on 2017-01-22 Permalink | Reply
    Tags: , , , Ogre3D, RTT   

    Currently working on PCamera class (a class to manage … camera!). The new samples/0.1/example.cam shows how to create one and render it onto a texture.

    In these images, the pink texture on the cube is the rendering of the camera rotating in the center of the scene, the tall pink cone. It is very ogry to send the camera to the texture:


    RenderTexture * rt = texture->getBuffer( )->getRenderTarget( );
    custom_wp = compositorMgr->addWorkspace( sceneMgr, rt, custom_cam.getOgreCam( ), cwName, true );
    custom_mat->getTechnique( 0 )->getPass( 0 )->createTextureUnitState( )->setTexture( texture );

    There should be a way to make this a bit more handy, I’ll look into it sooner.

     
  • frankiezafe 19:24 on 2017-01-11 Permalink | Reply
    Tags: , , glitch, , Ogre3D, , ,   

    screenshot01112017_142211314

    screenshot01112017_142217797

    screenshot01112017_142624367

    screenshot01112017_150924058

    screenshot01112017_150940710

    screenshot01112017_150945944

    screenshot01112017_155054726

    screenshot01112017_155102542

    screenshot01112017_160911261

    screenshot01112017_160926611

    screenshot01112017_161703380

    screenshot01112017_161732695

    screenshot01112017_161750328

    screenshot01112017_161757179

    screenshot01112017_161810645

    screenshot01112017_170923978

    screenshot01112017_171052215

    screenshot01112017_171406017

    screenshot01112017_172418511

    screenshot01112017_185234271

    Cool day today: the creation of the example.glitch was quite fun.
    The example demonstrate a bit more extensively the usage of the ogre’s compositor (see here) and the interaction with shaders.

    If you test the example, ckeck CustomApp::createCompositor: you’ll find comments about how to interact with the shader’suniform.

    The superb model in this scene is gearthing4 by shivinteger, distributed by #additivism.

     
    • xuv 00:57 on 2017-01-12 Permalink | Reply

      Wow. Looks awesome. Indeed, add some sound and it’s a finished piece. 🙂

  • frankiezafe 20:13 on 2017-01-10 Permalink | Reply
    Tags: , Ogre3D,   

    screenshot01102017_200308117

    screenshot01102017_200310217

    screenshot01102017_200315718

    screenshot01102017_200318951

    screenshot01102017_200328133

    screenshot01102017_200347400

    New example about compositor and shader (example.compositor).

    The example concerns the definition of a custom compositor. In Ogre3d, a compositor is a serie of post-processing nodes attached to the camera. It is the place where the image displayed at each frame is created.

    In the example, there’s a shader attach to the background of the window that renders a blurred circle. The shader params can be modifed RT via the mouse.

    • Moving the mouse change the red and green channels of the center color.
    • Dragging with left button modify the radius of the circle.
    • Dragging with right button modify the center of the circle.
      • Compositor is a really strong feature of Ogre, even if it’s a quite difficult one!

     
  • frankiezafe 23:42 on 2017-01-03 Permalink | Reply
    Tags: , , , Ogre3D,   

    screenshot01032017_233404150

    Today, a lot of bug fixes on the basic classes of the polymorph packages.

    New: it is now possible to declare the resources folders in the XML! The common resources.cfg of Ogre can be replaced by a configuration.xml, placed in the same folder as the exec.

    The resources.cfg was looking like this:

    [Essential]
    Zip=../media/packs/PolymorphTrays.zip

    [General]
    FileSystem=../media
    FileSystem=../media/materials/scripts
    FileSystem=../media/materials/textures
    FileSystem=../media/models

    In the XML, it’s converted to this, with control over recursivity and read access.

        <resources>
            <group name=”Essential”>
                <resource path=”../media/packs/PolymorphTrays.zip” type=”Zip”/>
            </group>
            <group name=”General”>
                <resource path=”../media/models” type=”FileSystem” recursive=”1″ readonly=”0″/>
                <resource path=”../media/materials” type=”FileSystem” recursive=”1″ readonly=”0″/>
                <resource path=”../media/materials/textures” type=”FileSystem” recursive=”1″ readonly=”0″/>
            </group>
        </resources>

    The sreenshot comes from an evolution of the XML example, see Dynamic scenes loading

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel