BassMunkee / awd

Automatically exported from code.google.com/p/awd
Apache License 2.0
0 stars 0 forks source link

Unexpected Scene Headers #49

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
(Code example attached)

1. Generate a scene with the attached code, nothing fancy, just:
   - default metadata
   - construct an AWDTriGeom from an AWDSubGeom and an AWDMaterial
   - construct an AWDMeshInst from the AWDTriGeom
   - add_mesh_data, add_material, add_scene_block
   - write to a file.

2. Load the file using away3d:
   - AssetLibrary.loadData(new awd(), context, null, new AWDParser);
   - add AssetEvent AssetType.MESH listener, find event.asset as Mesh
   - view.scene.addChild(mesh)
   - controller.lookAtObject = mesh

What is the expected output? What do you see instead?
One expects to see the object, but you don't because
the scene transform is all wrong.

What version of the product are you using? On what operating system?
$ hg identify -bint
f2c379aa1520 490 default tip

$ uname -a
Linux hostname 3.2.0-30-generic #48-Ubuntu SMP Fri Aug 24 16:52:48 UTC 2012 
x86_64 x86_64 x86_64 GNU/Linux

Please provide any additional information below.
In the spec for scene object blocks, Table 16, a 4x4 transform matrix is 
specified.

Accordingly, awdutil_id_mtx4x4() initializes a 16*awd_float64 matrix.
But on line 45 of scene.cc, in AWDSceneBlock::write_scene_common, only the 
first 12 values are written, AWDSceneBlock::calc_common_length() is consistent, 
using the MTX43_SIZE(wide_mtx) on line 53.

Furthermore, in AWD2Parser::parseMatrix43RawData(), called by 
AWD2Parser::parseMatrix3D(), only 12 values are read, and are then expanded 
into a 4x4Matrix interspersed with the default constants.

I am not sure which is right, the spec or the library, either way, let me know 
and I will submit an appropriate patch.

In the interim, the workaround is to load 4x3 matrix (padded to suit) into the 
scene with AWDSceneBlock::set_transform() before writing a file.

Original issue reported on code.google.com by elkq...@gmail.com on 27 Nov 2012 at 11:28

Attachments: