Implement evidence-backed VR02 Rocketship flight and ownership
This commit is contained in:
1 parent
312efccb77
commit
e77add5fdf
50 files changed
+4326
-66
No files matched your search
@@ -0,0 +1,53 @@
|
||||
using System.Numerics;
|
||||
using System.Text.Json;
|
||||
using GamePort.Assets;
|
||||
using GamePort.Game;
|
||||
|
||||
namespace GamePort.Application;
|
||||
|
||||
/// <summary>Original Strato, HIDRIVE, HIROCK and additive FireStrato resources.
|
||||
/// Uses source local pivots/transforms without standing-sole correction.</summary>
|
||||
public sealed class RocketshipVisuals
|
||||
{
|
||||
private sealed record Clip(MorphAnimation Animation,int Offset,MeshDraw Draw);
|
||||
private readonly Clip ship,rider,dog,fire;
|
||||
public Mesh Mesh { get; }
|
||||
|
||||
public RocketshipVisuals(Mesh combined,string preparedRoot)
|
||||
{
|
||||
var root=Path.Combine(preparedRoot,"rocketship");
|
||||
using var doc=JsonDocument.Parse(File.ReadAllText(Path.Combine(root,"rocketship.json")));
|
||||
if(doc.RootElement.GetProperty("schema").GetInt32()!=1)throw new InvalidDataException("Unknown Rocketship resource schema");
|
||||
Clip Load(string name)
|
||||
{
|
||||
var animation=new MorphAnimation(Path.Combine(root,name,"animation.json"));
|
||||
var offset=combined.Vertices.Length;
|
||||
var id=int.MinValue;while(combined.Textures.ContainsKey(id))id++;
|
||||
combined=animation.AppendTo(combined,id);
|
||||
var draw=combined.Draws[^1];draw.Visible=false;
|
||||
return new(animation,offset,draw);
|
||||
}
|
||||
ship=Load("strato");rider=Load("jimdrive");dog=Load("godrocket");fire=Load("firestrato");
|
||||
fire.Draw.Blend=MeshBlend.Additive;fire.Draw.Opacity=1;
|
||||
Mesh=combined;
|
||||
}
|
||||
|
||||
public void Update(Mesh mesh,Rocketship vehicle,double time,PlayerAppearance appearance)
|
||||
{
|
||||
var ordinary=RocketOrientation.Model(vehicle.Rotation,vehicle.Root,Vector3.One);
|
||||
Draw(ship,RocketOrientation.Model(vehicle.Rotation,vehicle.Root,vehicle.ShapeScale),vehicle.Mounted);
|
||||
Draw(rider,ordinary,vehicle.Mounted);
|
||||
Draw(dog,RocketOrientation.Model(vehicle.Rotation,vehicle.CompanionRoot,Vector3.One),vehicle.Mounted);
|
||||
Draw(fire,ordinary,vehicle.Mounted&&vehicle.FireVisible);
|
||||
PlayerGadgetMaterial.Apply(rider.Draw,appearance);
|
||||
var color=appearance.Color;
|
||||
for(var i=0;i<rider.Animation.Base.Vertices.Length;i++)
|
||||
mesh.Vertices[rider.Offset+i].Color*=new Vector3(color.X,color.Y,color.Z);
|
||||
|
||||
void Draw(Clip clip,Matrix4x4 model,bool visible)
|
||||
{
|
||||
clip.Draw.Visible=visible;
|
||||
if(visible)clip.Animation.Sample(time,mesh.Vertices.AsSpan(clip.Offset,clip.Animation.Base.Vertices.Length),model);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user