private void LoadS3DMeshes(bool force) { atplDic = new Dictionary <int, Model3DGroup>(); foreach (var obj in atpl.Objects) { if (obj.isInherited || obj._2E01 == null) { continue; } try { var group = new Model3DGroup(); foreach (var submesh in obj.Submeshes) { AddS3DMesh(group, obj, submesh, force); } var mGroup = new Transform3DGroup(); var pObj = (obj._2901 == null) ? obj : atpl.ObjectByID(obj._2901.InheritID); Matrix3D mat0 = ModelFunctions.MatrixFromBounds(obj.BoundingBox.Data); Matrix3D mat1 = (obj.isInheritor) ? ModelFunctions.MatrixFromBounds(pObj.BoundingBox.Data) : mat0; Matrix3D mat2 = ModelFunctions.MatrixFromBounds(atpl.RenderBounds); var mat3 = new Matrix3D(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1); var mat4 = new Matrix3D(600, 0, 0, 0, 0, 600, 0, 0, 0, 0, 600, 0, 0, 0, 0, 1); var matX = Matrix3D.Identity; matX.M11 = matX.M22 = matX.M33 = pak.SceneCDT.sets[0].unkf0; //matX.OffsetX = pak.SceneCDT.sets[0].MinBound.x; //matX.OffsetY = pak.SceneCDT.sets[0].MinBound.y; //matX.OffsetZ = pak.SceneCDT.sets[0].MinBound.z; var dmat = new Matrix3D( 1f / 0xFFFF, 0, 0, 0, 0, 1f / 0xFFFF, 0, 0, 0, 0, 1f / 0xFFFF, 0, 0.5, 0.5, 0.5, 1 ); if (pObj.Vertices.Data[0].FormatName == "S3D_World") { dmat = mat0 = mat1 = mat4 = matX = Matrix3D.Identity; } mGroup.Children.Add(new MatrixTransform3D(dmat * mat4 * mat3)); group.Transform = mGroup; atplDic.Add(atpl.Objects.IndexOf(obj), group); } catch (Exception ex) { if (!force) { throw ex; } } } }
private void LoadS3DMeshes(bool force) { atplDic = new Dictionary <int, Model3DGroup>(); foreach (var obj in atpl.Objects) { if (obj._B903.VertCount == 0 /*&& obj.Submeshes == null*/) { continue; } //if (obj.BoundingBox.Length == 0) continue; var group = new Model3DGroup(); foreach (var submesh in obj.Submeshes) { AddS3DMesh(group, obj, submesh, force); } int xx = atpl.Objects.IndexOf(obj); Matrix3D mat0 = ModelFunctions.MatrixFromBounds(obj.BoundingBox.Data); Matrix3D mat1 = obj.Transform.Data; Matrix3D pMat = atpl.HierarchialTransformUp(obj); var dmat = new Matrix3D( 1f / 0xFFFF, 0, 0, 0, 0, 1f / 0xFFFF, 0, 0, 0, 0, 1f / 0xFFFF, 0, 0.5, 0.5, 0.5, 1 ); var mat2 = new Matrix3D(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1); var mat3 = new Matrix3D(100, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 100, 0, 0, 0, 1); int id = obj.ParentID; var mGroup = new Transform3DGroup(); mGroup.Children.Add(new MatrixTransform3D(dmat * mat0 * pMat * mat2)); group.Transform = mGroup; atplDic.Add(atpl.Objects.IndexOf(obj), group); } }