Apply dummy joint rotation
This commit is contained in:
		
							parent
							
								
									59582bdfb8
								
							
						
					
					
						commit
						d83e020de0
					
				|  | @ -2,6 +2,7 @@ using System.Collections.Generic; | ||||||
| using System.IO; | using System.IO; | ||||||
| using Godot; | using Godot; | ||||||
| using KeepersCompound.LGS; | using KeepersCompound.LGS; | ||||||
|  | using Quaternion = System.Numerics.Quaternion; | ||||||
| 
 | 
 | ||||||
| namespace KeepersCompound.TMV; | namespace KeepersCompound.TMV; | ||||||
| 
 | 
 | ||||||
|  | @ -54,17 +55,27 @@ public class ModelLoader | ||||||
|         // TODO: Traverse children properly |         // TODO: Traverse children properly | ||||||
|         // TODO: Apply to normals |         // TODO: Apply to normals | ||||||
|         // TODO: Apply joints(??) |         // TODO: Apply joints(??) | ||||||
|  |         // TODO: Handle Slide joints | ||||||
|  |         // !HACK: Hardcoded joint :)) | ||||||
|  |         var ang = float.DegreesToRadians(45); | ||||||
|         foreach (var subObj in modelFile.Objects) |         foreach (var subObj in modelFile.Objects) | ||||||
|         { |         { | ||||||
|             if (subObj.Type == 0) |             if (subObj.Type == 0) | ||||||
|             { |             { | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|  | 
 | ||||||
|  |             var translation = subObj.Transform.Translation; | ||||||
|  |             var rotation = subObj.Transform; | ||||||
|  |             rotation.Translation = System.Numerics.Vector3.Zero; | ||||||
|  |             var jointRotation = Quaternion.CreateFromYawPitchRoll(0, ang, 0); | ||||||
|              |              | ||||||
|             for (var i = subObj.PointIdx; i < subObj.PointIdx + subObj.PointCount; i++) |             for (var i = subObj.PointIdx; i < subObj.PointIdx + subObj.PointCount; i++) | ||||||
|             { |             { | ||||||
|                 var v = modelFile.Vertices[i]; |                 var v = modelFile.Vertices[i]; | ||||||
|                 v = System.Numerics.Vector3.Transform(v, subObj.Transform); |                 v = System.Numerics.Vector3.Transform(v, jointRotation); | ||||||
|  |                 v = System.Numerics.Vector3.Transform(v, rotation); | ||||||
|  |                 v += translation; | ||||||
|                 modelFile.Vertices[i] = v; |                 modelFile.Vertices[i] = v; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue