Skip to content

Commit

Permalink
Gizmo: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gucio321 committed Oct 29, 2024
1 parent fb155e9 commit 549ff8a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Gizmo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ var _ Widget = &GizmoWidget{}
// GizmoWidget implement ImGuizmo features.
// It is designed just like PlotWidget.
// This structure provides an "area" where you can put Gizmos (see (*GizmoWidget).Gizmos).
// If you wnat to have more understanding about what is going on here, read this:

Check failure on line 23 in Gizmo.go

View workflow job for this annotation

GitHub Actions / Lint

`wnat` is a misspelling of `want` (misspell)
// https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/ (DISCLAIMER: giu authors are not responsible if you get mad or something!)
// TODO: grid thickness
// TODO: Manipulate mode and operation
// TODO: ViewManipulate
// TODO: ProjectionMatrix edition (see https://github.com/jbowtie/glm-go)
type GizmoWidget struct {
gizmos []GizmoI
view, projection *HumanReadableMatrix
Expand All @@ -34,11 +40,14 @@ func Gizmo(view, projection *HumanReadableMatrix) *GizmoWidget {
}
}

// Gizmos adds GizmoI elements to the GizmoWidget area.
func (g *GizmoWidget) Gizmos(gizmos ...GizmoI) *GizmoWidget {
g.gizmos = append(g.gizmos, gizmos...)
return g
}

// build is a local build function.
// Just to separate Global() and Build() methods.
func (g *GizmoWidget) build() {
for _, gizmo := range g.gizmos {
gizmo.Gizmo(g.view, g.projection)
Expand Down Expand Up @@ -69,13 +78,15 @@ type GridGizmo struct {
thickness float32
}

// Grid creates a new GridGizmo.
func Grid() *GridGizmo {
return &GridGizmo{
matrix: IdentityMatrix(),
thickness: 10,
}
}

// Gizmo implements GizmoI interface.
func (g *GridGizmo) Gizmo(view, projection *HumanReadableMatrix) {
imguizmo.DrawGrid(
view.Matrix(),
Expand All @@ -92,6 +103,7 @@ type CubeGizmo struct {
manipulate bool
}

// Cube creates a new CubeGizmo.
func Cube(matrix *HumanReadableMatrix) *CubeGizmo {
return &CubeGizmo{
matrix: matrix,
Expand All @@ -118,6 +130,9 @@ func (c *CubeGizmo) Gizmo(view, projection *HumanReadableMatrix) {
}
}

// ManipulateGizmo is a gizmo that allows you to "visually manipulate a matrix".
// It can be attached to another Gizmo (e.g. CubeGizmo) and will allow to move/rotate/scale it.
// See (*CubeGizmo).Manipulate() method.
type ManipulateGizmo struct {
matrix *HumanReadableMatrix
operation GizmoOperation
Expand Down

0 comments on commit 549ff8a

Please sign in to comment.