Assigning scene property “Materials” to submeshes using Libawd.

Software: Other

Aleos, Newbie
Posted: 01 November 2013 03:29 PM   Total Posts: 1

Hello.

I has been made an OBJ to AWD converter utility for simple case of OBJ file content - only mesh, normals, faces, faces normals and uvs are exist in OBJ. Utility has been written on C++(Qt) using libawd.lib which has been compiled from the latest sources from the repository.
Additionally I have a textures for my OBJ models, which I add to AWD file too (add textures and materials and assign texture to material).
Actually the question is how can I automatically assign created materials to needed submeshes in scene object?
What I have at the moment:
- Input data: OBJ file with mesh, normals, faces, normal faces, uvs, JPG or PNG file with texture;
- Output data: AWD file with geometry with submeshes, textures with loaded textures from PNG or JPG files, materials with assigned textures, scene object with geometry, with default materials assigned to submeshes.

What I should to achieve: all the same as mentioned in “Output data” but in the scene object the materials (created by me) assigned to submeshes instead of default materials assigned to submeshes.

At the moment have to open Away Builder (v. 1.0.0), open converted AWD file on it and assign materials with my textures to submeshes manually (select it from dropbox list if materials for each submesh in scene object) and then save the file.

As I can see I need to set scene object property (numeric attribute) “material” to according value, but the current specification of AWD format (2.0 and 2.1 alpha) don’t allow this. Actually the question is how can I overcome this restriction of current version of format specification using libawd library.

Thank you.

   

Avatar
80prozent, Sr. Member
Posted: 02 November 2013 09:46 PM   Total Posts: 430   [ # 1 ]

Hi

i am not shure i fully understand your question…

for now i am only working on the ppyawd (python library), so i dont know how much i can help you with the libawd.

A Geometry/Subgeometry never has a material assigned directly.
A Mesh has a geometry assigned, and one material for each of the subGeometries.

So in AWD, a MeshInstance contains a list of IDs that are pointing to materials (One material-ID for each subGeometry).

This material-IDs are created by the libawd automaticcly when exporting.
What you need to do is, to create a AWD-Material for each material you want to export.
https://github.com/awaytools/awd-sdk/blob/master/cpp-libawd/src/material.cc


you will need to add each created AWDMaterial to the material-list of the main AWD-object
https://github.com/awaytools/awd-sdk/blob/master/cpp-libawd/src/awd.cc
see line 80

Now you need to update the AWDMesh and its material-list.
You need to remove the old materials from the ‘materials’-list, and than add your new AWD-materials for each material that you removed.
https://github.com/awaytools/awd-sdk/blob/master/cpp-libawd/src/mesh.cc
see line 309

When exporting the File, the awdlib will create the IDs for the AWDMaterials, when exporting the AWDMaterials and later, when exporting the AWDMeshes, it will retrieve the ID for each AWDMaterial that is assigned to the AWDMesh, and store that with the AWDMesh.
https://github.com/awaytools/awd-sdk/blob/master/cpp-libawd/src/mesh.cc
see line 355


hope that is any help

 Signature 

sorry…i hope my actionscript is better than my english…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X