Class GLModel
- Namespace
- SearchAThing.OpenGL.Core
- Assembly
- netcore-opengl-core.dll
Gl model.
- contains the associated GLVertexManager
- the list of model figures GLFigureBase
- point lights GLPointLight.
- custom vertex managers AddCustomVertexManager(GLVertexManager)
- contains the default build model action.
[JsonObject(MemberSerialization.OptIn)]
public class GLModel : IGLContextObject
- Inheritance
-
GLModel
- Implements
- Inherited Members
- Extension Methods
Constructors
GLModel(GLContext)
Constructor.
public GLModel(GLContext glContext)
Parameters
glContext
GLContextGl 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
NotificationRequest
Event emitted when gl control would to notify something. This will handled by SearchAThing.OpenGL.GUI.AvaloniaGLControl.
public NotificationDelegate NotificationRequest
Field Value
Properties
CursorMode
Current cursor mode.
public CursorMode CursorMode { get; set; }
Property Value
- See Also
CustomVertexManagers
Enumerates custom vertex managers registered into this model.
public IEnumerable<GLVertexManager> CustomVertexManagers { get; }
Property Value
Figures
Figures (included those from custom vertex managers)
public ReadOnlyObservableCollection<GLFigureBase> Figures { get; }
Property Value
GLContext
Gl context.
public GLContext GLContext { get; }
Property Value
GLVertexManager
Gl vertex manager.
public GLVertexManager GLVertexManager { get; }
Property Value
IsInvalidated
States if model is invalidated thus BuildModel will be automatically invoked at first render.
public bool IsInvalidated { get; set; }
Property Value
LBBox
bbox of model vertexes [local].
public BBox LBBox { get; }
Property Value
NormalFactor
Factor respect to bbox size used when normal geometry shader generates normals.
public float NormalFactor { get; set; }
Property Value
- See Also
OverrideAmbient
Override ambient strength (default:0.8).
public float OverrideAmbient { get; set; }
Property Value
Remarks
Requires OverrideAmbient to be effective.
- See Also
OverrideAmbientEnabled
Override ambient strength enabled.
public bool OverrideAmbientEnabled { get; set; }
Property Value
OverrideDiffuse
Override diffuse strength (default:0.6).
public float OverrideDiffuse { get; set; }
Property Value
Remarks
Requires OverrideDiffuse to be effective.
- See Also
OverrideDiffuseEnabled
Override diffuse strength enabled.
public bool OverrideDiffuseEnabled { get; set; }
Property Value
OverrideSpecular
Override specular strength (default:0.6).
public float OverrideSpecular { get; set; }
Property Value
Remarks
Requires OverrideSpecular to be effective.
- See Also
OverrideSpecularEnabled
Override specular strength enabled.
public bool OverrideSpecularEnabled { get; set; }
Property Value
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
SelectedPrimitives
Selected primitives.
public ReadOnlyObservableCollection<GLPrimitiveBase> SelectedPrimitives { get; }
Property Value
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
Methods
AddCustomVertexManager(GLVertexManager)
Attach given custom vertex manager to the model.
public void AddCustomVertexManager(GLVertexManager vertexManager)
Parameters
vertexManager
GLVertexManagerGl vertex manager to attach.
AddFigure(GLFigureBase)
Adds given figure to the vertex manager.
public void AddFigure(GLFigureBase figure)
Parameters
figure
GLFigureBaseGl 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
boolIf 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
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
DeserializeFiguresFromFile(string)
Deserialize gl figures from given serialized gl model pathfilename.
public IEnumerable<GLFigureBase> DeserializeFiguresFromFile(string pathfilename)
Parameters
pathfilename
string
Returns
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
GetSelectionSimpleCmd()
Retrieve SimpleCmd(bool) representation of selected primitives and figure primitives.
public string GetSelectionSimpleCmd()
Returns
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
stringSimple 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
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
GLVertexManagerGl vertex manager to detach.
RemoveFigure(GLFigureBase)
Remove given figure from the vertex manager.
public bool RemoveFigure(GLFigureBase figure)
Parameters
figure
GLFigureBaseGl 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(params GLFigureBase[])
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
stringTitle of notification.
msg
stringMessage to display, it can contains at most 1 newlines.
notifyType
GLNotificationTypeLevel type of notification (Default:Information).
Serialize()
Json serialized representation of this model.
public string Serialize()
Returns
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
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
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