Add mesh reading and conversion support
This commit is contained in:
parent
65dc96c4d6
commit
aa1277a4e1
25 changed files with 2212 additions and 9 deletions
33
LibDgf/Ps2/Vif/VuFloat.cs
Normal file
33
LibDgf/Ps2/Vif/VuFloat.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace LibDgf.Ps2.Vif
|
||||
{
|
||||
public struct VuFloat
|
||||
{
|
||||
public uint Packed;
|
||||
|
||||
public static implicit operator double(VuFloat f)
|
||||
{
|
||||
ulong sign = (f.Packed >> 31) & 1;
|
||||
ulong exponent = (f.Packed >> 23) & 0xff;
|
||||
ulong mantissa = f.Packed & 0x7fffff;
|
||||
ulong doubleValue;
|
||||
if (exponent == 0)
|
||||
{
|
||||
doubleValue = sign << 63;
|
||||
}
|
||||
else
|
||||
{
|
||||
doubleValue = (sign << 63) | ((exponent + 1023 - 127) << 52) | (mantissa << 29);
|
||||
}
|
||||
return BitConverter.ToDouble(BitConverter.GetBytes(doubleValue), 0);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ((double)this).ToString();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue