Table of Contents

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

name string

The name to assign to the primitive. Cannot be null or empty.

mesh Mesh

The 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

name string

The name to assign to the primitive. Cannot be null or empty.

mesh Mesh

The mesh that defines the geometry of the primitive. Cannot be null.

material IMaterial

The 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

bool

MaterialOverride

Override to get or set the material associated with this primitive.

public IMaterial MaterialOverride { get; set; }

Property Value

IMaterial

Mesh

Gets or sets the mesh geometry associated with this object.

public Mesh Mesh { get; set; }

Property Value

Mesh

Shader

the shader program used for rendering the primitive.

public RenderShader Shader { get; set; }

Property Value

RenderShader

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

name string

The name of the primitive.

material IMaterial

The material to be used for the primitive.

assets AssetManager

The asset manager to manage the primitive's assets.

type PrimitiveType

The 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

obj JObject
serializationContext SerializationContext
callback Func<JObject, bool>

Dispose(BaseScene, IRenderDevice)

Disposes the primitive and the mesh resources.

public override void Dispose(BaseScene scene, IRenderDevice renderer)

Parameters

scene BaseScene
renderer IRenderDevice

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

scene BaseScene
viewport Viewport
renderer IRenderDevice

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

scene BaseScene
viewport Viewport
renderer IRenderDevice
camera Camera

RenderShadow(BaseScene, Viewport, IRenderDevice)

Render the primitive for shadow mapping purposes.

public override void RenderShadow(BaseScene scene, Viewport viewport, IRenderDevice renderer)

Parameters

scene BaseScene
viewport Viewport
renderer IRenderDevice

Serialize(JsonWriter, SerializationContext, Action<JsonWriter>)

Serializes the primitive to JSON format.

public override void Serialize(JsonWriter writer, SerializationContext serializationContext, Action<JsonWriter> callback = null)

Parameters

writer JsonWriter
serializationContext SerializationContext
callback Action<JsonWriter>