obj mesh texture always the same

Software: Away3D 4.x

Avatar
Luca, Sr. Member
Posted: 29 January 2013 11:02 PM   Total Posts: 230

Hi guys…
I have read on other post about this problem.

I have downloaded the latest version ( away3d-core-fp11 ) from git hub
and the 4.0.1 Alpha of the library but:

In the first case ( by using away3d-core-fp11 library ) when i try to display mesh loaded from obj file i can only see mesh with same texture for all the mesh in the scene but physics ( bullet ) works great.

In the second case ( by using 4.0.1 Alpha ) all the mesh loaded from the same obj file have the right texture, but physics simulation have some problem.

Anyone have a solution ?
( see this post: Away3D Gold : all .obj got the same texture )
Thx

   

Avatar
Luca, Sr. Member
Posted: 30 January 2013 09:12 AM   Total Posts: 230   [ # 1 ]

My solution for now is: ( core_fp11 from github )

In OBJParser.as make this change:

  /**
  * Converts the parsed data into an Away3D scenegraph structure
  */
  private function translate() :void
  {
  for (var objIndex:int = 0; objIndex < _objects.length; ++objIndex)
  {
  var groups:Vector.<Group> = _objects[objIndex].groups;
  var numGroups:uint = groups.length;
  var materialGroups:Vector.<MaterialGroup>;
  var numMaterialGroups:uint;
  var geometry:Geometry;
  var mesh:Mesh;
 
  var m:uint;
  var sm:uint;
  var bmMaterial:TextureMaterial;

  for (var g:uint = 0; g < numGroups; ++g) {
    geometry = new Geometry();
    materialGroups = groups[g].materialGroups;
    numMaterialGroups = materialGroups.length;
   
    for (m = 0; m < numMaterialGroups; ++m)
    translateMaterialGroup(materialGroups[m], geometry);
   
    if(geometry.subGeometries.length == 0) continue;
   
    // Finalize and force type-based name
    finalizeAsset(geometry, “”);
   
    // WORKS !
    bmMaterial = new TextureMaterial(DefaultMaterialManager.getDefaultTexture());
    // DON’T WORKS !!!
    // bmMaterial = DefaultMaterialManager.getDefaultMaterial();
   
    mesh = new Mesh(geometry, bmMaterial);
   
    if (_objects[objIndex].name) {
    // this is a full independent object (‘o’ tag in OBJ file)
    mesh.name = _objects[objIndex].name;
    } else if(groups[g].name) {
    // this is a group so the sub groups contain the actual mesh object names (‘g’ tag in OBJ file)
    mesh.name = groups[g].name;
    } else {
    // No name stored. Use empty string which will force it
    // to be overridden by finalizeAsset() to type default.
    mesh.name = “”;
    }
   
    _meshes.push(mesh);
   
    if(groups[g].materialID != “”){
    bmMaterial.name = groups[g].materialID+”~”+mesh.name;
    } else {
    bmMaterial.name = _lastMtlID+”~”+mesh.name;
    }
   
    if(mesh.subMeshes.length >1){
    for (sm = 1; sm

   
   
‹‹ Device loss

X

Away3D Forum

Member Login

Username

Password

Remember_me



X