mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 00:08:05 -04:00
// SkinnedModelRenderer - the only new entry point for speaking
SoundHandle SpeakSound( SoundEvent sound, GameObject mouth = null )
SoundHandle SpeakSound( SoundFile sound, float volume = 1, float pitch = 1, GameObject mouth = null )
// SoundFile - the authored lipsync track, read from the compiled vsnd
VisemeTrack Visemes { get; } // null = no track (or not loaded yet, see IsValidForPlayback)
// VisemeTrack - visemes over time, authored in the sound editor
IReadOnlyList<VisemeFrame> Frames { get; }
float Duration { get; }
bool Sample( float time, Span<float> weights )
// VisemeFrame - one viseme span (struct: Viseme, StartTime, EndTime)
// Visemes - the standard 15-viseme table, OVR order
static IReadOnlyList<string> MorphNames { get; }
static int Count { get; }
// MorphCollection - the one shared viseme blend (sounds, voice chat, editor preview)
void ApplyVisemes( ReadOnlySpan<float> visemeWeights, float scale = 1, float smoothTime = 0 )
// ModelMorphs - per-model viseme weight table, cached managed-side (no interop on lookups)
float GetVisemeMorph( int viseme, int morph )
float GetVisemeMorph( string viseme, int morph )
// ResourceCompileContext - inject managed data into natively-compiled resources
void WriteBlock( string blockName, ReadOnlySpan<byte> data ) // four-char block names, eg "LIPS"
void WriteBlockJson( string blockName, object obj )
JsonObject ReadMeta() // the asset's .meta, registers a compile dependency
T ReadMeta<T>( string key, T defaultValue = default )
// ResourceLoadContext - read blocks back when the resource loads (Resource.OnLoaded, engine-internal for now)
// public ref struct, only valid during the load callback
bool Exists( string blockName )
ReadOnlySpan<byte> ReadData( string blockName )
string ReadString( string blockName )
T ReadJson<T>( string blockName, T defaultValue = default )
79 lines
1.7 KiB
C#
79 lines
1.7 KiB
C#
using Sandbox;
|
|
|
|
/// <summary>
|
|
/// Hidden class. addon code should only ever access MorphCollection.
|
|
/// </summary>
|
|
internal sealed class SceneObjectMorphCollection( SceneModel sceneObject ) : MorphCollection
|
|
{
|
|
const float FadeTime = 0.05f;
|
|
|
|
public override void ResetAll()
|
|
{
|
|
ResetAll( FadeTime );
|
|
}
|
|
|
|
public override void ResetAll( float fadeTime )
|
|
{
|
|
sceneObject.animNative.SBox_ClearFlexOverride( fadeTime );
|
|
}
|
|
|
|
public override void Reset( int i )
|
|
{
|
|
Reset( i, FadeTime );
|
|
}
|
|
|
|
public override void Reset( string name )
|
|
{
|
|
Reset( name, FadeTime );
|
|
}
|
|
|
|
public override void Reset( int i, float fadeTime )
|
|
{
|
|
sceneObject.animNative.SBox_ClearFlexOverride( i, fadeTime );
|
|
}
|
|
|
|
public override void Reset( string name, float fadeTime )
|
|
{
|
|
sceneObject.animNative.SBox_ClearFlexOverride( name, fadeTime );
|
|
}
|
|
|
|
public override void Set( int i, float weight )
|
|
{
|
|
Set( i, weight, FadeTime );
|
|
}
|
|
|
|
public override void Set( string name, float weight )
|
|
{
|
|
Set( name, weight, FadeTime );
|
|
}
|
|
|
|
public override void Set( int i, float weight, float fadeTime )
|
|
{
|
|
sceneObject.animNative.SBox_SetFlexOverride( i, MathF.Max( 0.0f, weight ), fadeTime );
|
|
}
|
|
|
|
public override void Set( string name, float weight, float fadeTime )
|
|
{
|
|
sceneObject.animNative.SBox_SetFlexOverride( name, MathF.Max( 0.0f, weight ), fadeTime );
|
|
}
|
|
|
|
public override float Get( int i )
|
|
{
|
|
return sceneObject.animNative.SBox_GetFlexOverride( i );
|
|
}
|
|
|
|
public override float Get( string name )
|
|
{
|
|
return sceneObject.animNative.SBox_GetFlexOverride( name );
|
|
}
|
|
|
|
public override string GetName( int index )
|
|
{
|
|
return sceneObject.Model.GetMorphName( index );
|
|
}
|
|
|
|
public override int Count => sceneObject.Model.MorphCount;
|
|
|
|
internal override Model Model => sceneObject.Model;
|
|
}
|