Results 1 to 11 of 11

Thread: Development of a new teapot example

  1. #1
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default Development of a new teapot example

    See attached image:

    The aim of this example is to demonstrate how to use ClanLib without Lib3ds to display models.

    TODO:
    1) Calculate the surface normals at each point. The function generate_point_facelist() can be used to create a list of faces that attach to a specific point. Since we already calculate surface normal. For point normal, we just need to average the normals for smooth shading.

    2) Load the Collada file (in resources/teapot.dae) Currently, the points and verticies are located in teapot.cpp

    3) The aim is to be able to create a single vertex buffer object using multiple objects for optimum speed.

    4) Add bones to manipulate the mesh of certain objects on the scene (for example, an arm lifting the teapot)

    Note, the example uses the GL1 target, so I don't need to write a shader. It is possible for some of the code to be moved into a shader (normal calculation for dynamic objects (bones).
    Attached Images Attached Images  

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    The example has been modified to:

    1) Calculate the normal at each point (for smooth shading)

    2) It loads the Teapot as a Collada file. Note, the loader is very hacky, and makes some assumptions

    3) Appends two cubes to the teapot, treating them as the same object

    See attached:
    Attached Images Attached Images  
    Last edited by rombust; 09-07-2009 at 09:39 AM. Reason: spelling mistake

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    An updated image.

    A 3d clanlib logo, using a collada object with a layer for each letter and a different surface for the letter front and sides.
    Attached Images Attached Images  

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I have now developed a CL_Collada loader

    Currently the source can be found at Examples/Object3D/Collada

    CL_Collada is the base class.

    "library_geometries" using "polylist" is now complete. (Except, it does not link to materials at the moment - until materials loader is added)

    See updated example - Rotating ball, containing a uvmap of tux.
    Attached Images Attached Images  

  5. #5
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I started a materials loader.

    Currently it is up to:
    <library_effects><effect><profile_COMMON>

    I am unsure how to handle <newparam sid="...">

    (that contains...
    <sampler2D>
    <source>tux-surface</source>
    <minfilter>LINEAR_MIPMAP_LINEAR</minfilter>
    <magfilter>LINEAR</magfilter>
    </sampler2D>
    )

    (I am thinking is ignoring all other newparam parameters for now)

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I have creating the martial loader part of the collada importer.

    Dicewar has been modified to use the importer.

    However, because i can't get dicewar to run (framebuffer problems), i cannot test it.

    However, it should look like the attached screenshot

    The CL_Texture's have not been mapped to the object face when drawing to the screen - that's why it's got the wrong texture - i ran out of time!
    Attached Images Attached Images  

  7. #7
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I am not entirely convinced that CL_Collada in the current state is the way to go.

    I wrote it with the objective to ease the loading of the Collada object XML. However, it has almost turned into a map of the XML file (ie xml elements converted into classes).

    Is that the correct approach?
    Should it be stripped down to be easier to use?
    Should it be extended so it can also display an object? Or is that a separate class?
    Should we instead simply navigate the XML (using XPointers etc)?
    What is the meaning of life, the universe and everything?

  8. #8
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I have thought of a new approach, which may work.

    For simplicity, we assume all meshes are made up of triangles. I believe most 3D modellers can convert meshes into triangles with a single key press.

    Keep the existing CL_Collada loader.

    Create a new class, CL_Collada_Manger - That is created by the application, and shared between multiple CL_Collada objects. It contains:

    add_storage( allocator_callback,
    options,
    "VERTEX", stride, must_exist
    "UV", stride, must_exist
    "NORMAL", stride, create_if_not_exist
    Ö
    )

    So when loading an object, the application can decide where and how the data is to be stored. For example: all objects in one interleaved list.

    ?

  9. #9
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    My experience with the 3DS model loader indicates that generic model class would have to solve the following problems:

    • Convert meshes to triangle lists with associated data (weights, texture coordinates)
    • Z-sorting of transparent parts (unless someone got a better idea on how to render that )
    • Program object, texture and material sharing between objects
    • Efficient rendering of many visible objects
    • Animation support of some sort which uses vertex weights (not just frame animation)
    • A way to query and find 'attachment points' so an object can equip other equipment (someone wearing a weapon and so on)


    This stuff gets complex very fast, which is why I still highly recommend we play around with it a lot in examples until we know exactly what we want in a base 3D object class in ClanLib.

  10. #10
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Looking at it now, I don't think we can have a generic 3D class that satisfies everyone.

    Personally, I will not use Collada, as it does not contain all the functionality that Lightwave 9.6 can give.

    So, I agree, the way forward (for now) is to have different examples containing different methods of loading and displaying models.

    That way, the user can use and adapt the engine to their needs.

    I have modified Dicewar to use the Collada loader. Instead, I am thinking of reducing it. Still using Collada for the model, but using itís own compact loader (reading directly from the XML)

  11. #11
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    For now, dicewar still uses the CL_Collada loader

    The loader has been modified to make it more user friendly.

    The API to extract the data from the imported object is simple:

    Code:
    	void create_vertices(CL_Vec3f *destination, int stride, const CL_String &semantic, std::vector<CL_Collada_Triangles> &surface_list);
    	void create_vertices(CL_Vec2f *destination, int stride, const CL_String &semantic, std::vector<CL_Collada_Triangles> &surface_list);
    	void create_vertices_normal(CL_Vec3f *destination, int stride, const CL_String &semantic, const CL_Angle &smoothing_angle);
    create_vertices() converts the vertex data to any format the user wishes (via stride parameter)
    Use can use "get_triangle_count() * 3" to determine the size for destination.
    "semantic" can be "VERTEX" or "TEXCOORD", "NORMAL" etc

    create_vertices_normal() can be used if "NORMAL" semantic does not exist inside the model.

    See attached screenshot of dicewar:
    Attached Images Attached Images  

Similar Threads

  1. Development roadmap
    By glajan in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 09-27-2007, 07:41 AM
  2. Davidi Development
    By Davidi in forum RTsoft Tavern
    Replies: 10
    Last Post: 08-07-2004, 06:14 PM
  3. Is FQ development happening?
    By jjohn in forum Funeral Quest
    Replies: 2
    Last Post: 08-15-2003, 02:13 PM
  4. "New" D-mod in development
    By Satanic Ewok in forum RTsoft Tavern
    Replies: 2
    Last Post: 09-22-2002, 12:02 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •