summaryrefslogtreecommitdiff
path: root/NW4RTools/ColladaWriter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'NW4RTools/ColladaWriter.cs')
-rw-r--r--NW4RTools/ColladaWriter.cs44
1 files changed, 37 insertions, 7 deletions
diff --git a/NW4RTools/ColladaWriter.cs b/NW4RTools/ColladaWriter.cs
index f0f5b19..2c57d7e 100644
--- a/NW4RTools/ColladaWriter.cs
+++ b/NW4RTools/ColladaWriter.cs
@@ -37,8 +37,8 @@ namespace NW4RTools {
Collada.asset.contributor[0] = new assetContributor();
Collada.asset.contributor[0].authoring_tool = "NW4RTools Collada exporter by Treeki";
Collada.asset.contributor[0].source_data = "NW4R model: " + modelName;
- Collada.asset.created = DateTime.Now;
- Collada.asset.modified = DateTime.Now;
+ //Collada.asset.created = DateTime.Now;
+ //Collada.asset.modified = DateTime.Now;
Collada.asset.unit = new assetUnit();
Collada.asset.unit.meter = 1.0;
Collada.asset.up_axis = UpAxisType.Y_UP;
@@ -344,16 +344,17 @@ namespace NW4RTools {
eff.id = "Material-Effect-" + name;
eff.name = eff.id;
+
+ // HACK!!
+ if (mat.TextureInfos.Count == 0)
+ return eff;
+
// this is based off what colladamax outputs
eff.Items = new effectFx_profile_abstractProfile_COMMON[1];
var profile = eff.Items[0] = new effectFx_profile_abstractProfile_COMMON();
// TODO: handle this correctly for multiple textures ETC and check how bb does it
- // HACK!!
- if (mat.TextureInfos.Count == 0)
- return eff;
-
profile.Items = new object[2];
// create a surface newparam
@@ -374,7 +375,10 @@ namespace NW4RTools {
var samplerParam = new common_newparam_type();
var sampler2d = new fx_sampler2D_common();
+ // add wrapping
sampler2d.source = "Surface-" + mat.TextureInfos[0].TextureName;
+ sampler2d.wrap_s = mat.TextureInfos[0].WrapS.ToColladaSamplerWrap();
+ sampler2d.wrap_t = mat.TextureInfos[0].WrapT.ToColladaSamplerWrap();
samplerParam.sid = "Sampler-" + mat.TextureInfos[0].TextureName;
samplerParam.ItemElementName = ItemChoiceType.sampler2D;
@@ -395,6 +399,28 @@ namespace NW4RTools {
pShader.diffuse.Item = diffuseTex;
+ pShader.emission = new common_color_or_texture_type();
+ var emissionClr = new common_color_or_texture_typeColor();
+ emissionClr.Values = new double[] { 0, 0, 0, 1 };
+ pShader.emission.Item = emissionClr;
+
+ pShader.ambient = new common_color_or_texture_type();
+ var ambientClr = new common_color_or_texture_typeColor();
+ ambientClr.Values = new double[] { 0, 0, 0, 1 };
+ pShader.ambient.Item = ambientClr;
+
+ pShader.transparent = new common_transparent_type();
+ pShader.transparent.opaque = fx_opaque_enum.A_ONE;
+ var transparentClr = new common_color_or_texture_typeColor();
+ transparentClr.Values = new double[] { 1, 1, 1, 1 };
+ pShader.transparent.Item = transparentClr;
+ pShader.transparency = new common_float_or_param_type();
+ var bs = new common_float_or_param_typeFloat();
+ bs.Value = 1;
+ pShader.transparency.Item = bs;
+ // we can reuse DiffuseTex!
+ pShader.transparent.Item = diffuseTex;
+
profile.technique.Item = pShader;
return eff;
@@ -537,7 +563,11 @@ namespace NW4RTools {
for (int i = 0; i < tcData.EntryCount; i++) {
float[] data = tcData.GetEntry(i);
for (int j = 0; j < data.Length; j++) {
- tcArray.Values[dest++] = data[j];
+ // flip T (Y axis) coordinate
+ if (j == 1)
+ tcArray.Values[dest++] = 1.0 - data[j];
+ else
+ tcArray.Values[dest++] = data[j];
}
}