Skip to content

Commit 17f481b

Browse files
authored
Small clean-up for models with negative scales (#1083)
* consistent spaces * delete obsolete note regarding cesium
1 parent d2469cd commit 17f481b

File tree

8 files changed

+22
-33
lines changed

8 files changed

+22
-33
lines changed

3ds Max/Max2Babylon/Exporter/BabylonExporter.CustomAttributes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public Dictionary<string, object> ExportExtraAttributes(IIGameNode gameNode, Bab
3737
#if MAX2022 || MAX2023
3838
ManagedServices.MaxscriptSDK.ExecuteMaxscriptCommand("obj = maxOps.getNodeByHandle " + gameNode.MaxNode.Handle + ";", ManagedServices.MaxscriptSDK.ScriptSource.NotSpecified);
3939
#else
40-
ManagedServices.MaxscriptSDK.ExecuteMaxscriptCommand("obj = maxOps.getNodeByHandle " + gameNode.MaxNode.Handle + ";");
40+
ManagedServices.MaxscriptSDK.ExecuteMaxscriptCommand("obj = maxOps.getNodeByHandle " + gameNode.MaxNode.Handle + ";");
4141
#endif
4242

4343
return _ExportExtraAttributes(gameNode.IGameObject.IPropertyContainer, babylonScene, excludeAttributes);

3ds Max/Max2Babylon/Exporter/BabylonExporter.ExportItem.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public bool KeepPosition
113113
}
114114
}
115115

116-
const char s_PropertySeparator = ';';
116+
const char s_PropertySeparator = ';';
117117
private const char s_ProperyLayerSeparator = '~';
118118
const string s_PropertyFormat = "{0};{1};{2};{3};{4}";
119119
const string s_PropertyNamePrefix = "babylonjs_ExportItem";
@@ -282,11 +282,9 @@ public void LoadFromData(string propertyName)
282282
{
283283
throw new Exception("Invalid property name, can't deserialize.");
284284
}
285-
286285

287286
string itemGuidStr = propertyName.Remove(0, s_PropertyNamePrefix.Length);
288287

289-
290288
if (!Guid.TryParse(itemGuidStr, out itemGuid))
291289
{
292290
Loader.Core.PushPrompt("Error: Invalid ID, can't deserialize.");

3ds Max/Max2Babylon/Exporter/BabylonExporter.Material.Pbr.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public PbrMetalRoughDecorator(IIGameMaterial node) : base(node)
4545
public ITexmap MetalnessMap => _getTexMap(_node, "metalness_map");
4646
public float Roughness => Properties?.GetFloatProperty("roughness", 0) ?? 0;
4747
public ITexmap RoughnessMap => _getTexMap(_node, "roughness_map");
48-
}
48+
}
4949

5050
public class PbrSpecGlossDecorator : PbrGameMaterialDecorator
5151
{
@@ -290,14 +290,14 @@ private void ExportPbrSpecGlossMaterial(IIGameMaterial materialNode, BabylonScen
290290
// the target material
291291
var babylonMaterial = new BabylonPBRSpecularGlossinessMaterial(maxDecorator.Id)
292292
{
293-
maxGameMaterial = materialNode,
294-
name = maxDecorator.Name,
295-
backFaceCulling = babylonDecorator.BackFaceCulling,
296-
doubleSided = !babylonDecorator.BackFaceCulling,
297-
separateCullingPass = babylonDecorator.SeparateCullingPass,
298-
isUnlit = babylonDecorator.IsUnlit,
299-
baseColor = maxDecorator.BaseColor.ToArray(),
300-
};
293+
maxGameMaterial = materialNode,
294+
name = maxDecorator.Name,
295+
backFaceCulling = babylonDecorator.BackFaceCulling,
296+
doubleSided = !babylonDecorator.BackFaceCulling,
297+
separateCullingPass = babylonDecorator.SeparateCullingPass,
298+
isUnlit = babylonDecorator.IsUnlit,
299+
baseColor = maxDecorator.BaseColor.ToArray(),
300+
};
301301

302302
// --- Global ---
303303
if (babylonMaterial.isUnlit)

3ds Max/Max2Babylon/Exporter/BabylonExporter.Material.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ private void ExportStandardMaterial(IIGameMaterial materialNode, IIPropertyConta
406406
{
407407
babylonMaterial.opacityFresnelParameters = fresnelParameters;
408408
if (babylonMaterial.alpha == 1 &&
409-
babylonMaterial.opacityTexture == null)
409+
babylonMaterial.opacityTexture == null)
410410
{
411411
babylonMaterial.alpha = 0;
412412
}
@@ -589,7 +589,6 @@ private void ExportPhysicalMaterial(IIGameMaterial materialNode, IIPropertyConta
589589
babylonMaterial.roughness = 1 - babylonMaterial.roughness;
590590
}
591591

592-
593592
// Self illumination is computed from emission color, luminance, temperature and weight
594593
babylonMaterial.emissive = materialNode.MaxMaterial.GetSelfIllumColorOn(0, false)
595594
? materialNode.MaxMaterial.GetSelfIllumColor(0, false).Scale(selfIllumScale).ToArray()

3ds Max/Max2Babylon/Exporter/BabylonExporter.Mesh.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,11 +1021,6 @@ private void ExtractFace(IIGameSkin skin, IIGameMesh unskinnedMesh, BabylonAbstr
10211021
{
10221022
int a, b, c;
10231023
// parity is TRUE, if determinant negative ( counter-intuitive convention of 3ds max, see docs... :/ )
1024-
1025-
// fix for cesium: currently, cesium does not expect a reversed winding order for negative scales
1026-
//if (false)
1027-
1028-
// for threejs and babylonjs (handle negative scales correctly (reversed winding order expected)
10291024
if (invertedWorldMatrix.Parity)
10301025
{
10311026
// flipped case: reverse winding order
@@ -1380,7 +1375,7 @@ private float GetW(IPoint3 normal, IPoint3 tangent, IPoint3 bitangent)
13801375
{
13811376
return 1;
13821377
}
1383-
1378+
13841379
float nx = MathUtilities.RoundToIfAlmostEqualTo(normal.X, 0, Tools.Epsilon);
13851380
float ny = MathUtilities.RoundToIfAlmostEqualTo(normal.Y, 0, Tools.Epsilon);
13861381
float nz = MathUtilities.RoundToIfAlmostEqualTo(normal.Z, 0, Tools.Epsilon);
@@ -1393,7 +1388,7 @@ private float GetW(IPoint3 normal, IPoint3 tangent, IPoint3 bitangent)
13931388

13941389
// theorical bittangent
13951390
MathUtilities.CrossProduct(nx, ny, nz, tx, ty, tz, out float x, out float y, out float z);
1396-
1391+
13971392
// Speaking in broadest terms, if the dot product of two non-zero vectors is positive,
13981393
// then the two vectors point in the same general direction, meaning less than 90 degrees.
13991394
// If the dot product is negative, then the two vectors point in opposite directions,

3ds Max/Max2Babylon/Exporter/BabylonExporter.Texture.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ private BabylonTexture ExportSpecularGlossinessTexture(float[] specularColor, IT
546546
{
547547
var specularTexture = _getBitmapTex(specularTexMap);
548548
var glossinessTexture = _getBitmapTex(glossinessTexMap);
549-
549+
550550
// we are trying to get the best output format, function of source and policy.
551551
var paths = new IBitmapTex[] { specularTexture, glossinessTexture}.Where(t => t != null).Select(t => t.Map.FileName);
552552
var policy = exportParameters.textureFormatExportPolicy;
@@ -1217,8 +1217,6 @@ private IStdUVGen _exportUV(IStdUVGen uvGen, BabylonTexture babylonTexture)
12171217
RaiseMessage(MaxTextureTransformToString(uvGen));
12181218
#endif
12191219

1220-
1221-
12221220
var offset = new BabylonVector3(uvGen.GetUOffs(0), uvGen.GetVOffs(0), 0);
12231221
var scale = new BabylonVector3(uvGen.GetUScl(0), uvGen.GetVScl(0), 1);
12241222
//max rotation is horlogic, here we move using trigonometric, so anti - horlogic
@@ -1257,7 +1255,7 @@ private IStdUVGen _exportUV(IStdUVGen uvGen, BabylonTexture babylonTexture)
12571255
var translateBack = BabylonMatrix.Translation(center);
12581256
var t = translateToOrigin * scaling * rotate * translateBack ;
12591257
offset = origin * t;
1260-
}
1258+
}
12611259

12621260
babylonTexture.uOffset = offset.X%1;
12631261
babylonTexture.vOffset = (1 - offset.Y) % 1;

3ds Max/Max2Babylon/Exporter/BabylonExporter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ public void BakeAnimationsFrame(IINode node,BakeAnimationType bakeAnimationType)
175175
tmp = Point()
176176
--store anim to a point
177177
for t = animationRange.start to animationRange.end do (
178-
with animate on at time t tmp.transform = obj.transform
179-
)
178+
with animate on at time t tmp.transform = obj.transform
179+
)
180180
181181
--remove constraint on original object
182182
obj.pos.controller = Position_XYZ ()
@@ -186,11 +186,11 @@ public void BakeAnimationsFrame(IINode node,BakeAnimationType bakeAnimationType)
186186
187187
--copy back anim from point
188188
for t = animationRange.start to animationRange.end do (
189-
with animate on at time t obj.transform = tmp.transform
190-
)
189+
with animate on at time t obj.transform = tmp.transform
190+
)
191191
delete tmp
192192
)
193-
");
193+
");
194194
}
195195

196196
public void ExportClosedContainers()
@@ -333,7 +333,7 @@ public void Export(MaxExportParameters exportParameters)
333333

334334
var rawScene = Loader.Core.RootNode;
335335

336-
string outputFormat = exportParameters.outputFormat;
336+
string outputFormat = exportParameters.outputFormat;
337337
isBabylonExported = outputFormat == "babylon" || outputFormat == "binary babylon";
338338
isGltfExported = outputFormat == "gltf" || outputFormat == "glb";
339339

3ds Max/Max2Babylon/Exporter/GlobalVertex.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public GlobalVertex(GlobalVertex other)
3737

3838
public override int GetHashCode()
3939
{
40-
4140
//return string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}-{9}",
4241
// BaseIndex,
4342
// CurrentIndex,

0 commit comments

Comments
 (0)