Files
sbox-public/engine/Sandbox.Engine/Resources/Model/Model.VertexData.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

49 lines
1.1 KiB
C#

using NativeEngine;
namespace Sandbox;
public partial class Model
{
/// <summary>
/// Experimental!
/// </summary>
public unsafe Vertex[] GetVertices()
{
int numVertices = MeshGlue.GetModelNumVertices( native );
if ( numVertices == 0 )
return null;
var vertices = new Vertex[numVertices];
fixed ( Vertex* vmem = &vertices[0] )
{
MeshGlue.GetModelVertices( native, (IntPtr)vmem, (uint)numVertices );
}
return vertices;
}
/// <summary>
/// Experimental!
/// </summary>
public unsafe uint[] GetIndices()
{
int numIndices = MeshGlue.GetModelNumIndices( native );
if ( numIndices == 0 )
return null;
var indices = new uint[numIndices];
fixed ( uint* vmem = &indices[0] )
{
MeshGlue.GetModelIndices( native, (IntPtr)vmem, (uint)numIndices );
}
return indices;
}
public int GetIndexCount( int drawcall ) => MeshGlue.GetModelIndexCount( native, drawcall );
public int GetIndexStart( int drawcall ) => MeshGlue.GetModelIndexStart( native, drawcall );
public int GetBaseVertex( int drawcall ) => MeshGlue.GetModelBaseVertex( native, drawcall );
}