From 20c0292e97cac4ea9849d676b9a2ceab9140d50c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 7 Apr 2014 14:03:40 +0000 Subject: [PATCH] =?UTF-8?q?From=20Bjorn=20Blessing,=20"I=20got=20bored=20o?= =?UTF-8?q?f=20the=20constant=20reports=20of=20=E2=80=9Cmissing=20chunk=20?= =?UTF-8?q?0xA08A=E2=80=9D=20when=20reading=203ds-files.=20After=20a=20bit?= =?UTF-8?q?=20of=20research=20I=20discovered=20that=20this=20property=20is?= =?UTF-8?q?=20related=20to=20the=20advanced=20transparency=20settings=20fo?= =?UTF-8?q?r=20the=20material=20in=203D=20studio.=20In=20this=20case=20the?= =?UTF-8?q?=20falloff=20parameter.=20These=20controls=20affect=20the=20opa?= =?UTF-8?q?city=20falloff=20of=20a=20transparent=20material.=20And=20the?= =?UTF-8?q?=20property=20chooses=20whether=20falloff=20is=20in=20or=20out.?= =?UTF-8?q?=20I=20have=20added=20the=20property=20to=20the=20file=20reader?= =?UTF-8?q?=20BUT=20no=20changes=20are=20made=20to=20make=20this=20propert?= =?UTF-8?q?y=20propagate=20into=20the=20osgMaterial.=20But=20at=20least=20?= =?UTF-8?q?we=20get=20rid=20of=20this=20annoying=20error=20message."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/osgPlugins/3ds/lib3ds/lib3ds.h | 1 + src/osgPlugins/3ds/lib3ds/lib3ds_chunktable.c | 1 + src/osgPlugins/3ds/lib3ds/lib3ds_impl.h | 3 ++- src/osgPlugins/3ds/lib3ds/lib3ds_material.c | 14 +++++++++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds.h b/src/osgPlugins/3ds/lib3ds/lib3ds.h index f4dfde01a..e3f4d171f 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds.h +++ b/src/osgPlugins/3ds/lib3ds/lib3ds.h @@ -242,6 +242,7 @@ typedef struct Lib3dsMaterial { int soften; /* bool */ int face_map; /* bool */ int two_sided; /* Material visible from back */ + int transparency_falloff; /* Transparency falloff in/out */ int map_decal; /* bool */ int use_wire; int use_wire_abs; diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_chunktable.c b/src/osgPlugins/3ds/lib3ds/lib3ds_chunktable.c index dcf13084e..8b1a42cab 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_chunktable.c +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_chunktable.c @@ -86,6 +86,7 @@ static Lib3dsChunkTable lib3ds_chunk_table[] = { {CHK_MAT_SELF_ILPCT, "MAT_SELF_ILPCT"}, {CHK_MAT_WIRE, "MAT_WIRE"}, {CHK_MAT_FACEMAP, "MAT_FACEMAP"}, + {CHK_MAT_TRANSPARENCY_FALLOFF, "MAT_TRANSPARENCY_FALLOFF"}, {CHK_MAT_PHONGSOFT, "MAT_PHONGSOFT"}, {CHK_MAT_WIREABS, "MAT_WIREABS"}, {CHK_MAT_WIRE_SIZE, "MAT_WIRE_SIZE"}, diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_impl.h b/src/osgPlugins/3ds/lib3ds/lib3ds_impl.h index b3c90c17f..b79c2c16e 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_impl.h +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_impl.h @@ -10,7 +10,7 @@ by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. - Thisprogram is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -132,6 +132,7 @@ typedef enum Lib3dsChunks { CHK_MAT_SELF_ILPCT =0xA084, CHK_MAT_WIRE =0xA085, CHK_MAT_FACEMAP =0xA088, + CHK_MAT_TRANSPARENCY_FALLOFF =0xA08A, CHK_MAT_PHONGSOFT =0xA08C, CHK_MAT_WIREABS =0xA08E, CHK_MAT_WIRE_SIZE =0xA087, diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_material.c b/src/osgPlugins/3ds/lib3ds/lib3ds_material.c index bb5ffc803..d3ed4988b 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_material.c +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_material.c @@ -371,6 +371,11 @@ lib3ds_material_read(Lib3dsMaterial *material, Lib3dsIo *io) { break; } + case CHK_MAT_TRANSPARENCY_FALLOFF: { + material->transparency_falloff = TRUE; + break; + } + case CHK_MAT_PHONGSOFT: { material->soften = TRUE; break; @@ -492,7 +497,7 @@ lib3ds_material_read(Lib3dsMaterial *material, Lib3dsIo *io) { material->autorefl_map_frame_step = lib3ds_io_read_intd(io); break; } - + default: lib3ds_chunk_unknown(chunk, io); } @@ -821,6 +826,13 @@ lib3ds_material_write(Lib3dsMaterial *material, Lib3dsIo *io) { lib3ds_chunk_write(&c, io); } + if (material->transparency_falloff) { /*---- CHK_MAT_TRANSPARENCY_FALLOFF ----*/ + Lib3dsChunk c; + c.chunk = CHK_MAT_TRANSPARENCY_FALLOFF; + c.size = 6; + lib3ds_chunk_write(&c, io); + } + if (material->soften) { /*---- CHK_MAT_PHONGSOFT ----*/ Lib3dsChunk c; c.chunk = CHK_MAT_PHONGSOFT;