Rendering scenario vehicles at correct height

This commit is contained in:
dexyfex 2018-03-04 06:24:15 +11:00
parent 5c991cd06a
commit 4ff94156e7
3 changed files with 27 additions and 20 deletions

View File

@ -49,15 +49,15 @@ namespace CodeWalker.GameFiles
public uint Unknown_14h { get; set; } // 0x00000000
public uint Unknown_18h { get; set; } // 0x00000000
public uint Unknown_1Ch { get; set; } // 0x00000000
public uint Unknown_20h { get; set; }
public uint Unknown_24h { get; set; }
public uint Unknown_28h { get; set; }
public uint Unknown_2Ch { get; set; }
public float Unknown_20h { get; set; }
public float Unknown_24h { get; set; }
public float Unknown_28h { get; set; }
public float Unknown_2Ch { get; set; }
public ulong DrawablePointer { get; set; }
public ulong Unknown_28h_Pointer { get; set; }
public ulong Unknown_30h_Pointer { get; set; }
public uint Count0 { get; set; }
public uint Unknown_4Ch { get; set; }
public uint Unknown_4Ch { get; set; } //pointer?
public uint Unknown_50h { get; set; } // 0x00000000
public uint Unknown_54h { get; set; } // 0x00000000
public ulong NamePointer { get; set; }
@ -83,10 +83,10 @@ namespace CodeWalker.GameFiles
public uint Unknown_BCh { get; set; }
public uint Unknown_C0h { get; set; }
public uint Unknown_C4h { get; set; }
public uint Unknown_C8h { get; set; }
public uint Unknown_CCh { get; set; }
public uint Unknown_D0h { get; set; }
public uint Unknown_D4h { get; set; }
public uint Unknown_C8h { get; set; }//pointer?
public float Unknown_CCh { get; set; }
public float Unknown_D0h { get; set; }
public float Unknown_D4h { get; set; }
public byte Unknown_D8h { get; set; }
public byte Count3 { get; set; }
public ushort Unknown_DAh { get; set; }
@ -130,10 +130,10 @@ namespace CodeWalker.GameFiles
this.Unknown_14h = reader.ReadUInt32();
this.Unknown_18h = reader.ReadUInt32();
this.Unknown_1Ch = reader.ReadUInt32();
this.Unknown_20h = reader.ReadUInt32();
this.Unknown_24h = reader.ReadUInt32();
this.Unknown_28h = reader.ReadUInt32();
this.Unknown_2Ch = reader.ReadUInt32();
this.Unknown_20h = reader.ReadSingle();
this.Unknown_24h = reader.ReadSingle();
this.Unknown_28h = reader.ReadSingle();
this.Unknown_2Ch = reader.ReadSingle();
this.DrawablePointer = reader.ReadUInt64();
this.Unknown_28h_Pointer = reader.ReadUInt64();
this.Unknown_30h_Pointer = reader.ReadUInt64();
@ -165,9 +165,9 @@ namespace CodeWalker.GameFiles
this.Unknown_C0h = reader.ReadUInt32();
this.Unknown_C4h = reader.ReadUInt32();
this.Unknown_C8h = reader.ReadUInt32();
this.Unknown_CCh = reader.ReadUInt32();
this.Unknown_D0h = reader.ReadUInt32();
this.Unknown_D4h = reader.ReadUInt32();
this.Unknown_CCh = reader.ReadSingle();
this.Unknown_D0h = reader.ReadSingle();
this.Unknown_D4h = reader.ReadSingle();
this.Unknown_D8h = reader.ReadByte();
this.Count3 = reader.ReadByte();
this.Unknown_DAh = reader.ReadUInt16();

View File

@ -2256,10 +2256,8 @@ namespace CodeWalker.Rendering
public void RenderCar(Vector3 pos, Quaternion ori, MetaHash modelHash, MetaHash modelSetHash)
public void RenderCar(Vector3 pos, Quaternion ori, MetaHash modelHash, MetaHash modelSetHash, bool valign = false)
{
SelectedCarGenEntity.SetPosition(pos);
SelectedCarGenEntity.SetOrientation(ori);
uint carhash = modelHash;
if ((carhash == 0) && (modelSetHash != 0))
@ -2280,6 +2278,15 @@ namespace CodeWalker.Rendering
YftFile caryft = gameFileCache.GetYft(carhash);
if ((caryft != null) && (caryft.Loaded) && (caryft.Fragment != null))
{
if (valign)
{
float minz = caryft.Fragment.PhysicsLODGroup?.PhysicsLOD1?.Bound?.BoundingBoxMin.Z ?? 0.0f;
pos.Z -= minz;
}
SelectedCarGenEntity.SetPosition(pos);
SelectedCarGenEntity.SetOrientation(ori);
RenderFragment(null, SelectedCarGenEntity, caryft.Fragment, carhash);
}
}

View File

@ -1327,7 +1327,7 @@ namespace CodeWalker
}
}
Renderer.RenderCar(sn.Position, sn.Orientation, 0, vhash);
Renderer.RenderCar(sn.Position, sn.Orientation, 0, vhash, true);
}
}