Table of Contents

Class GLModel

Namespace
SearchAThing.OpenGL.Core
Assembly
netcore-opengl-core.dll

Gl model.

[JsonObject(MemberSerialization.OptIn)]
public class GLModel : IGLContextObject
Inheritance
GLModel
Implements
Inherited Members
Extension Methods

Constructors

GLModel(GLContext)

Constructor.

public GLModel(GLContext glContext)

Parameters

glContext GLContext

Gl context.

Fields

BuildModel

Build model action that will executed each time the model requires a full rebuild because invalidated.
Arguments (GLControl, bool isInitial).

public GLBuildModelDelegate? BuildModel

Field Value

GLBuildModelDelegate

NotificationRequest

Event emitted when gl control would to notify something. This will handled by SearchAThing.OpenGL.GUI.AvaloniaGLControl.

public NotificationDelegate NotificationRequest

Field Value

NotificationDelegate

Properties

CursorMode

Current cursor mode.

public CursorMode CursorMode { get; set; }

Property Value

CursorMode
See Also

CustomVertexManagers

Enumerates custom vertex managers registered into this model.

public IEnumerable<GLVertexManager> CustomVertexManagers { get; }

Property Value

IEnumerable<GLVertexManager>

Figures

Figures (included those from custom vertex managers)

public ReadOnlyObservableCollection<GLFigureBase> Figures { get; }

Property Value

ReadOnlyObservableCollection<GLFigureBase>

GLContext

Gl context.

public GLContext GLContext { get; }

Property Value

GLContext

GLVertexManager

Gl vertex manager.

public GLVertexManager GLVertexManager { get; }

Property Value

GLVertexManager

IsInvalidated

States if model is invalidated thus BuildModel will be automatically invoked at first render.

public bool IsInvalidated { get; set; }

Property Value

bool

LBBox

bbox of model vertexes [local].

public BBox LBBox { get; }

Property Value

BBox

NormalFactor

Factor respect to bbox size used when normal geometry shader generates normals.

public float NormalFactor { get; set; }

Property Value

float
See Also

OverrideAmbient

Override ambient strength (default:0.8).

public float OverrideAmbient { get; set; }

Property Value

float

Remarks

Requires OverrideAmbient to be effective.

See Also

OverrideAmbientEnabled

Override ambient strength enabled.

public bool OverrideAmbientEnabled { get; set; }

Property Value

bool

OverrideDiffuse

Override diffuse strength (default:0.6).

public float OverrideDiffuse { get; set; }

Property Value

float

Remarks

Requires OverrideDiffuse to be effective.

See Also

OverrideDiffuseEnabled

Override diffuse strength enabled.

public bool OverrideDiffuseEnabled { get; set; }

Property Value

bool

OverrideSpecular

Override specular strength (default:0.6).

public float OverrideSpecular { get; set; }

Property Value

float

Remarks

Requires OverrideSpecular to be effective.

See Also

OverrideSpecularEnabled

Override specular strength enabled.

public bool OverrideSpecularEnabled { get; set; }

Property Value

bool

PointLights

Observable collection of model point lights.

[JsonProperty]
public ObservableCollection2<GLPointLight> PointLights { get; }

Property Value

ObservableCollection2<GLPointLight>
See Also

SelectedFigures

Selected figures.

public ReadOnlyObservableCollection<GLFigureBase> SelectedFigures { get; }

Property Value

ReadOnlyObservableCollection<GLFigureBase>

SelectedPrimitives

Selected primitives.

public ReadOnlyObservableCollection<GLPrimitiveBase> SelectedPrimitives { get; }

Property Value

ReadOnlyObservableCollection<GLPrimitiveBase>

SerializerSettings

Default settings for json serialization of model.

public static JsonSerializerSettings SerializerSettings { get; }

Property Value

JsonSerializerSettings

Vertexes

Enumerates gl vertexes [object].

public IEnumerable<GLVertex> Vertexes { get; }

Property Value

IEnumerable<GLVertex>

Methods

AddCustomVertexManager(GLVertexManager)

Attach given custom vertex manager to the model.

public void AddCustomVertexManager(GLVertexManager vertexManager)

Parameters

vertexManager GLVertexManager

Gl vertex manager to attach.

AddFigure(GLFigureBase)

Adds given figure to the vertex manager.

public void AddFigure(GLFigureBase figure)

Parameters

figure GLFigureBase

Gl figure to add.

See Also

AddFigure(IEnumerable<GLFigureBase>)

Adds given figures to the vertex manager.

public void AddFigure(IEnumerable<GLFigureBase> figures)

Parameters

figures IEnumerable<GLFigureBase>

Gl figures to add.

See Also

Clear(bool)

Clear the model removing all entities from vertex manager, deregistering custom vertex manager and clearing point lights if specified.

public void Clear(bool clearPointLights = false)

Parameters

clearPointLights bool

If true clear point lights (Default:false).

ClearSelection(bool)

Clear current selection ( of figures, primitives ) and cancel select command.

public void ClearSelection(bool resetToViewMode = true)

Parameters

resetToViewMode bool

If true (Default) cursor back to View.

DeleteSelected()

Delete selected primitives/figures.

public void DeleteSelected()

DeserializeFigures(string)

Deserialize given gl model retrieving gl figures.

public IEnumerable<GLFigureBase> DeserializeFigures(string json)

Parameters

json string

Returns

IEnumerable<GLFigureBase>

DeserializeFiguresFromFile(string)

Deserialize gl figures from given serialized gl model pathfilename.

public IEnumerable<GLFigureBase> DeserializeFiguresFromFile(string pathfilename)

Parameters

pathfilename string

Returns

IEnumerable<GLFigureBase>

FiguresFromSimpleCmd(string)

Load primitives from given simgple cmd and group them by primitive type creating figures ( newlines supported ).
SimpleCmd() SimpleCmd() SimpleCmd()

public IEnumerable<GLFigureBase> FiguresFromSimpleCmd(string simpleCmd)

Parameters

simpleCmd string

Returns

IEnumerable<GLFigureBase>

GetSelectionSimpleCmd()

Retrieve SimpleCmd(bool) representation of selected primitives and figure primitives.

public string GetSelectionSimpleCmd()

Returns

string

InvalidateModel()

Invalidate the gl model.

This cause BuildModel to be invoked at next render.

public void InvalidateModel()
See Also

OnPropertyChanged(string?)

invoke this method to forward propertchanged event notification. note: not needed to specify propertyName set by compiler service to called property.

protected void OnPropertyChanged(string? propertyName = null)

Parameters

propertyName string

OverrideLightStrengths(float?, float?, float?)

Override vertex material properties.
Has no effect if no light points present.

public void OverrideLightStrengths(float? ambient = null, float? diffuse = null, float? specular = null)

Parameters

ambient float?

Ambient light strength (Default:0.8).

diffuse float?

Diffuse light strength (Default:0.6).

specular float?

Specular light strength (Default:0.6).

PasteSimpleCmd(string)

Add to the model figures coming from given SimpleCmd(bool).
Generated figures are primitives coming from the cmd grouped by primitive type.

public IEnumerable<IGLFigure> PasteSimpleCmd(string simpleCmd)

Parameters

simpleCmd string

Simple cmd representation.

Returns

IEnumerable<IGLFigure>

Figures added to the model.

PrimitivesFromSimpleCmd(string)

Load figure primitives from simple cmd ( newlines supported ).
SimpleCmd() SimpleCmd() SimpleCmd()

public IEnumerable<GLPrimitiveBase> PrimitivesFromSimpleCmd(string simpleCmd)

Parameters

simpleCmd string

Returns

IEnumerable<GLPrimitiveBase>

RecomputeLBBox()

Invalidate and recalc bounding box [local].
Used internally after delete of figures/primitives.

public void RecomputeLBBox()

RemoveCustomVertexManager(GLVertexManager)

Detach given custom manager from the model.

public void RemoveCustomVertexManager(GLVertexManager vertexManager)

Parameters

vertexManager GLVertexManager

Gl vertex manager to detach.

RemoveFigure(GLFigureBase)

Remove given figure from the vertex manager.

public bool RemoveFigure(GLFigureBase figure)

Parameters

figure GLFigureBase

Gl figure to remove.

Returns

bool

True if figure effectively removed.

See Also

RemoveFigure(params GLFigureBase[])

Remove given figures from the vertex manager.

public int RemoveFigure(params GLFigureBase[] figures)

Parameters

figures GLFigureBase[]

Gl figures to remove.

Returns

int

Count of figures effectively removed.

See Also

RemoveFigure(IEnumerable<GLFigureBase>)

Remove given figures from the vertex manager.

public int RemoveFigure(IEnumerable<GLFigureBase> figures)

Parameters

figures IEnumerable<GLFigureBase>

Gl figures to remove.

Returns

int

Count of figures effectively removed.

See Also

ResetLight()

Resets and create predefined lights

public void ResetLight()

SendNotification(string, string, GLNotificationType)

Send notification to frontend that manage this gl control.

public void SendNotification(string title, string msg, GLNotificationType notifyType = GLNotificationType.Information)

Parameters

title string

Title of notification.

msg string

Message to display, it can contains at most 1 newlines.

notifyType GLNotificationType

Level type of notification (Default:Information).

Serialize()

Json serialized representation of this model.

public string Serialize()

Returns

string

SerializeToFile(string)

Save json serialized representation of this model to given pathfilename.

public void SerializeToFile(string pathfilename)

Parameters

pathfilename string

SetupLightAttenuation(float?, float?, float?)

Configure light constant, linear, quadratic attenuation based on the model size.

public void SetupLightAttenuation(float? adjustConstant = 1, float? adjustLinear = 0, float? adjustQuadratic = 0)

Parameters

adjustConstant float?

Gl point light constant attenuation (Default:1f).

adjustLinear float?

Gl point light linear attenuation (Default:5e-1f).

adjustQuadratic float?

Gl point light quadratic attenuation (Default:1e-4).

ToString()

public override string? ToString()

Returns

string

ToggleSelectFigures(IEnumerable<GLFigureBase>)

Select/Deselect given figures.

public void ToggleSelectFigures(IEnumerable<GLFigureBase> figures)

Parameters

figures IEnumerable<GLFigureBase>

Figures for which toggle selection.

ToggleSelectPrimitives(IEnumerable<GLPrimitiveBase>)

Select/Deselect given primitives.

public void ToggleSelectPrimitives(IEnumerable<GLPrimitiveBase> primitives)

Parameters

primitives IEnumerable<GLPrimitiveBase>

Primitives for which toggle selection.

Events

PropertyChanged

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler

ViewInvalidated

Event emitted when a vertex of the model changes.
Useful to keep in sync the view calling the Invalidate(InvalidateEnum). See example-0016

public event ModelViewInvalidated? ViewInvalidated

Event Type

ModelViewInvalidated