mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 23:12:59 +08:00
Cutscene viewer hide models partially working
This commit is contained in:
parent
783248aeab
commit
2f12402a03
@ -1312,6 +1312,8 @@ namespace CodeWalker.GameFiles
|
|||||||
public Vector3 WidgetPosition = Vector3.Zero;
|
public Vector3 WidgetPosition = Vector3.Zero;
|
||||||
public Quaternion WidgetOrientation = Quaternion.Identity;
|
public Quaternion WidgetOrientation = Quaternion.Identity;
|
||||||
|
|
||||||
|
public uint EntityHash { get; set; } = 0; //used by CW as a unique position+name identifier
|
||||||
|
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
@ -1344,6 +1346,7 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
UpdateWidgetPosition();
|
UpdateWidgetPosition();
|
||||||
UpdateWidgetOrientation();
|
UpdateWidgetOrientation();
|
||||||
|
UpdateEntityHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
public YmapEntityDef(YmapFile ymap, int index, ref CMloInstanceDef mlo)
|
public YmapEntityDef(YmapFile ymap, int index, ref CMloInstanceDef mlo)
|
||||||
@ -1456,6 +1459,7 @@ namespace CodeWalker.GameFiles
|
|||||||
MloInstance.UpdateEntities();
|
MloInstance.UpdateEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateEntityHash();
|
||||||
UpdateWidgetPosition();
|
UpdateWidgetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1478,6 +1482,30 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateEntityHash()
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
var ints = new int[4];
|
||||||
|
var pv = Position;
|
||||||
|
ints[0] = (int)pv.X;
|
||||||
|
ints[1] = (int)pv.Y;
|
||||||
|
ints[2] = (int)pv.Z;
|
||||||
|
ints[3] = (int)_CEntityDef.archetypeName.Hash;
|
||||||
|
var bytes = new byte[16];
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
var ib = i * 4;
|
||||||
|
var b = BitConverter.GetBytes(ints[i]);
|
||||||
|
bytes[ib + 0] = b[0];
|
||||||
|
bytes[ib + 1] = b[1];
|
||||||
|
bytes[ib + 2] = b[2];
|
||||||
|
bytes[ib + 3] = b[3];
|
||||||
|
}
|
||||||
|
EntityHash = JenkHash.GenHash(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetOrientation(Quaternion ori, bool inverse = false)
|
public void SetOrientation(Quaternion ori, bool inverse = false)
|
||||||
{
|
{
|
||||||
if (MloParent != null)
|
if (MloParent != null)
|
||||||
|
@ -603,7 +603,7 @@ namespace CodeWalker.GameFiles
|
|||||||
e.Orientation = Quaternion.Multiply(owner.Orientation, e.MloRefOrientation);
|
e.Orientation = Quaternion.Multiply(owner.Orientation, e.MloRefOrientation);
|
||||||
e.UpdateWidgetPosition();
|
e.UpdateWidgetPosition();
|
||||||
e.UpdateWidgetOrientation();
|
e.UpdateWidgetOrientation();
|
||||||
|
e.UpdateEntityHash();
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ namespace CodeWalker.Rendering
|
|||||||
private List<YmapEntityDef> renderworldentities = new List<YmapEntityDef>(); //used when rendering world view.
|
private List<YmapEntityDef> renderworldentities = new List<YmapEntityDef>(); //used when rendering world view.
|
||||||
private List<RenderableEntity> renderworldrenderables = new List<RenderableEntity>();
|
private List<RenderableEntity> renderworldrenderables = new List<RenderableEntity>();
|
||||||
|
|
||||||
|
public Dictionary<uint, YmapEntityDef> HideEntities = new Dictionary<uint, YmapEntityDef>();//dictionary of entities to hide, for cutscenes to use
|
||||||
|
|
||||||
public bool ShowScriptedYmaps = true;
|
public bool ShowScriptedYmaps = true;
|
||||||
public List<YmapFile> VisibleYmaps = new List<YmapFile>();
|
public List<YmapFile> VisibleYmaps = new List<YmapFile>();
|
||||||
@ -294,6 +295,8 @@ namespace CodeWalker.Rendering
|
|||||||
RenderedBoundComps.Clear();
|
RenderedBoundComps.Clear();
|
||||||
|
|
||||||
renderskeletonlist.Clear();
|
renderskeletonlist.Clear();
|
||||||
|
|
||||||
|
HideEntities.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderSkyAndClouds()
|
public void RenderSkyAndClouds()
|
||||||
@ -1641,6 +1644,8 @@ namespace CodeWalker.Rendering
|
|||||||
var ent = rent.Entity;
|
var ent = rent.Entity;
|
||||||
var arch = ent.Archetype;
|
var arch = ent.Archetype;
|
||||||
|
|
||||||
|
if (HideEntities.ContainsKey(ent.EntityHash)) continue; //don't render hidden entities!
|
||||||
|
|
||||||
RenderArchetype(arch, ent, rent.Renderable, false);
|
RenderArchetype(arch, ent, rent.Renderable, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2839,6 +2844,14 @@ namespace CodeWalker.Rendering
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void RenderHideEntity(YmapEntityDef ent)
|
||||||
|
{
|
||||||
|
var hash = ent?.EntityHash ?? 0;
|
||||||
|
if (hash == 0) return;
|
||||||
|
|
||||||
|
HideEntities[hash] = ent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -547,6 +547,15 @@ namespace CodeWalker.World
|
|||||||
renderer.RenderWeapon(obj.Weapon, obj.AnimClip);
|
renderer.RenderWeapon(obj.Weapon, obj.AnimClip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach (var obj in SceneObjects.Values)
|
||||||
|
{
|
||||||
|
if (obj.Enabled == false) continue;
|
||||||
|
|
||||||
|
if (obj.HideEntity != null)
|
||||||
|
{
|
||||||
|
renderer.RenderHideEntity(obj.HideEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -774,23 +783,23 @@ namespace CodeWalker.World
|
|||||||
}
|
}
|
||||||
private void EnableHideObject(CutEvent e)
|
private void EnableHideObject(CutEvent e)
|
||||||
{
|
{
|
||||||
var args = e.EventArgs as CutObjectIdEventArgs;
|
var oe = e as CutObjectIdEvent;
|
||||||
if (args == null)
|
if (oe == null) return;
|
||||||
{ return; }
|
|
||||||
|
|
||||||
var obj = args.Object;
|
|
||||||
|
|
||||||
|
CutsceneObject cso = null;
|
||||||
|
SceneObjects.TryGetValue(oe.iObjectId, out cso);
|
||||||
|
if (cso != null)
|
||||||
|
{
|
||||||
|
cso.Enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void EnableFixupModel(CutEvent e)
|
private void EnableFixupModel(CutEvent e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
private void EnableBlockBounds(CutEvent e)
|
private void EnableBlockBounds(CutEvent e)
|
||||||
{
|
{
|
||||||
var args = e.EventArgs as CutObjectIdEventArgs;
|
var oe = e as CutObjectIdEvent;
|
||||||
if (args == null)
|
if (oe == null) return;
|
||||||
{ return; }
|
|
||||||
|
|
||||||
var obj = args.Object;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void EnableScreenFade(CutEvent e)
|
private void EnableScreenFade(CutEvent e)
|
||||||
@ -798,11 +807,8 @@ namespace CodeWalker.World
|
|||||||
}
|
}
|
||||||
private void EnableAnimation(CutEvent e)
|
private void EnableAnimation(CutEvent e)
|
||||||
{
|
{
|
||||||
var args = e.EventArgs as CutObjectIdEventArgs;
|
var oe = e as CutObjectIdEvent;
|
||||||
if (args == null)
|
if (oe == null) return;
|
||||||
{ return; }
|
|
||||||
|
|
||||||
var obj = args.Object;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void EnableParticleEffect(CutEvent e)
|
private void EnableParticleEffect(CutEvent e)
|
||||||
@ -820,11 +826,8 @@ namespace CodeWalker.World
|
|||||||
}
|
}
|
||||||
private void EnableCamera(CutEvent e)
|
private void EnableCamera(CutEvent e)
|
||||||
{
|
{
|
||||||
var args = e.EventArgs as CutObjectIdEventArgs;
|
var oe = e as CutObjectIdEvent;
|
||||||
if (args == null)
|
if (oe == null) return;
|
||||||
{ return; }
|
|
||||||
|
|
||||||
var obj = args.Object;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void EnableLight(CutEvent e)
|
private void EnableLight(CutEvent e)
|
||||||
@ -832,20 +835,20 @@ namespace CodeWalker.World
|
|||||||
}
|
}
|
||||||
private void DisableHideObject(CutEvent e)
|
private void DisableHideObject(CutEvent e)
|
||||||
{
|
{
|
||||||
var args = e.EventArgs as CutObjectIdEventArgs;
|
var oe = e as CutObjectIdEvent;
|
||||||
if (args == null)
|
if (oe == null) return;
|
||||||
{ return; }
|
|
||||||
|
|
||||||
var obj = args.Object;
|
|
||||||
|
|
||||||
|
CutsceneObject cso = null;
|
||||||
|
SceneObjects.TryGetValue(oe.iObjectId, out cso);
|
||||||
|
if (cso != null)
|
||||||
|
{
|
||||||
|
cso.Enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void DisableBlockBounds(CutEvent e)
|
private void DisableBlockBounds(CutEvent e)
|
||||||
{
|
{
|
||||||
var args = e.EventArgs as CutObjectIdEventArgs;
|
var oe = e as CutObjectIdEvent;
|
||||||
if (args == null)
|
if (oe == null) return;
|
||||||
{ return; }
|
|
||||||
|
|
||||||
var obj = args.Object;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void DisableScreenFade(CutEvent e)
|
private void DisableScreenFade(CutEvent e)
|
||||||
@ -853,11 +856,8 @@ namespace CodeWalker.World
|
|||||||
}
|
}
|
||||||
private void DisableAnimation(CutEvent e)
|
private void DisableAnimation(CutEvent e)
|
||||||
{
|
{
|
||||||
var args = e.EventArgs as CutObjectIdEventArgs;
|
var oe = e as CutObjectIdEvent;
|
||||||
if (args == null)
|
if (oe == null) return;
|
||||||
{ return; }
|
|
||||||
|
|
||||||
var obj = args.Object;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void DisableParticleEffect(CutEvent e)
|
private void DisableParticleEffect(CutEvent e)
|
||||||
@ -875,11 +875,8 @@ namespace CodeWalker.World
|
|||||||
}
|
}
|
||||||
private void DisableCamera(CutEvent e)
|
private void DisableCamera(CutEvent e)
|
||||||
{
|
{
|
||||||
var args = e.EventArgs as CutObjectIdEventArgs;
|
var oe = e as CutObjectIdEvent;
|
||||||
if (args == null)
|
if (oe == null) return;
|
||||||
{ return; }
|
|
||||||
|
|
||||||
var obj = args.Object;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void DisableLight(CutEvent e)
|
private void DisableLight(CutEvent e)
|
||||||
@ -1064,6 +1061,7 @@ namespace CodeWalker.World
|
|||||||
public YmapEntityDef Prop { get; set; }
|
public YmapEntityDef Prop { get; set; }
|
||||||
public Vehicle Vehicle { get; set; }
|
public Vehicle Vehicle { get; set; }
|
||||||
public Weapon Weapon { get; set; }
|
public Weapon Weapon { get; set; }
|
||||||
|
public YmapEntityDef HideEntity { get; set; }
|
||||||
|
|
||||||
public MetaHash AnimHash { get; set; }
|
public MetaHash AnimHash { get; set; }
|
||||||
public ClipMapEntry AnimClip { get; set; }
|
public ClipMapEntry AnimClip { get; set; }
|
||||||
@ -1200,6 +1198,10 @@ namespace CodeWalker.World
|
|||||||
private void InitHiddenModel(CutHiddenModelObject hid, GameFileCache gfc)
|
private void InitHiddenModel(CutHiddenModelObject hid, GameFileCache gfc)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
HideEntity = new YmapEntityDef();
|
||||||
|
HideEntity._CEntityDef.archetypeName = hid.cName;
|
||||||
|
HideEntity.SetPosition(hid.vPosition);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user