Class Primitive
- Namespace
- LibGFX.Core.GameElements
- Assembly
- LibGFX.dll
TODO REWORK! Represents a primitive game element that can be rendered with a material and shader.
public class Primitive : GameElement, IIdentifier, IPropertyTable, ISerialization
- Inheritance
-
Primitive
- Implements
- Inherited Members
Constructors
Primitive()
Initializes a new instance of the Primitive class.
public Primitive()
Primitive(string, Mesh)
Initializes a new instance of the Primitive class with the specified name and mesh.
public Primitive(string name, Mesh mesh)
Parameters
namestringThe name to assign to the primitive. Cannot be null or empty.
meshMeshThe mesh that defines the geometry of the primitive. Cannot be null.
Primitive(string, Mesh, IMaterial)
Initializes a new instance of the Primitive class with the specified name, mesh, and material.
public Primitive(string name, Mesh mesh, IMaterial material)
Parameters
namestringThe name to assign to the primitive. Cannot be null or empty.
meshMeshThe mesh that defines the geometry of the primitive. Cannot be null.
materialIMaterialThe material to apply to the primitive. Cannot be null.
Remarks
This constructor uses an material override. The mesh material wont get replaced.
Properties
HasTransparency
Gets a value indicating whether the mesh's material includes transparency.
public override bool HasTransparency { get; }
Property Value
MaterialOverride
Override to get or set the material associated with this primitive.
public IMaterial MaterialOverride { get; set; }
Property Value
Mesh
Gets or sets the mesh geometry associated with this object.
public Mesh Mesh { get; set; }
Property Value
Shader
the shader program used for rendering the primitive.
public RenderShader Shader { get; set; }
Property Value
Methods
ComputeAABB()
Computes the axis-aligned bounding box (AABB) for the primitive based on its mesh vertices.
public override void ComputeAABB()
CreatePrimitive(string, IMaterial, AssetManager, PrimitiveType)
Creates a primitive game element with the specified name, material, asset manager, and primitive type.
public static Primitive CreatePrimitive(string name, IMaterial material, AssetManager assets, PrimitiveType type = PrimitiveType.Cube)
Parameters
namestringThe name of the primitive.
materialIMaterialThe material to be used for the primitive.
assetsAssetManagerThe asset manager to manage the primitive's assets.
typePrimitiveTypeThe type of the primitive.
Returns
- Primitive
A new instance of the Primitive class.
Deserialize(JObject, SerializationContext, Func<JObject, bool>)
Deserializes the primitive from JSON format.
public override void Deserialize(JObject obj, SerializationContext serializationContext, Func<JObject, bool> callback = null)
Parameters
objJObjectserializationContextSerializationContextcallbackFunc<JObject, bool>
Dispose(BaseScene, IRenderDevice)
Disposes the primitive and the mesh resources.
public override void Dispose(BaseScene scene, IRenderDevice renderer)
Parameters
sceneBaseScenerendererIRenderDevice
GetMeshes()
Gets the meshes and materials associated with the primitive.
public override Mesh[]? GetMeshes()
Returns
- Mesh[]
Init(BaseScene, Viewport, IRenderDevice)
Initializes the primitive with the specified scene, viewport, and renderer.
public override void Init(BaseScene scene, Viewport viewport, IRenderDevice renderer)
Parameters
sceneBaseSceneviewportViewportrendererIRenderDevice
Render(BaseScene, Viewport, IRenderDevice, Camera)
Renders the primitive with the specified scene, viewport, renderer, and camera.
public override void Render(BaseScene scene, Viewport viewport, IRenderDevice renderer, Camera camera)
Parameters
sceneBaseSceneviewportViewportrendererIRenderDevicecameraCamera
RenderShadow(BaseScene, Viewport, IRenderDevice)
Render the primitive for shadow mapping purposes.
public override void RenderShadow(BaseScene scene, Viewport viewport, IRenderDevice renderer)
Parameters
sceneBaseSceneviewportViewportrendererIRenderDevice
Serialize(JsonWriter, SerializationContext, Action<JsonWriter>)
Serializes the primitive to JSON format.
public override void Serialize(JsonWriter writer, SerializationContext serializationContext, Action<JsonWriter> callback = null)
Parameters
writerJsonWriterserializationContextSerializationContextcallbackAction<JsonWriter>