xyzv

package
v0.0.0-...-7f2886f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2024 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SelBoxName is the reserved top-level Group name for holding
	// a bounding box or manipulator for currently selected object.
	// also used for meshes representing the box.
	SelBoxName = "__SelectedBox"

	// ManipBoxName is the reserved top-level name for meshes
	// representing the manipulation box.
	ManipBoxName = "__ManipBox"
)

Variables

View Source
var ManipPtType = gti.AddType(&gti.Type{
	Name:      "goki.dev/gix/xyzv.ManipPt",
	ShortName: "xyzv.ManipPt",
	IDName:    "manip-pt",
	Doc:       "ManipPt is a manipulation control point",
	Directives: gti.Directives{
		&gti.Directive{Tool: "goki", Directive: "no-new", Args: []string{}},
	},
	Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}),
	Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"Solid", &gti.Field{Name: "Solid", Type: "goki.dev/xyz.Solid", LocalType: "xyz.Solid", Doc: "", Directives: gti.Directives{}, Tag: ""}},
	}),
	Methods:  ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}),
	Instance: &ManipPt{},
})

ManipPtType is the gti.Type for ManipPt

View Source
var SceneType = gti.AddType(&gti.Type{
	Name:       "goki.dev/gix/xyzv.Scene",
	ShortName:  "xyzv.Scene",
	IDName:     "scene",
	Doc:        "Scene is a gi.Widget that manages a xyz.Scene,\nproviding the basic rendering logic for the 3D scene\nin the 2D gi gui context.",
	Directives: gti.Directives{},
	Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"Scene", &gti.Field{Name: "Scene", Type: "*goki.dev/xyz.Scene", LocalType: "*xyz.Scene", Doc: "Scene is the 3D Scene", Directives: gti.Directives{}, Tag: "set:\"-\""}},
		{"SelMode", &gti.Field{Name: "SelMode", Type: "goki.dev/gix/xyzv.SelModes", LocalType: "SelModes", Doc: "how to deal with selection / manipulation events", Directives: gti.Directives{}, Tag: ""}},
		{"CurSel", &gti.Field{Name: "CurSel", Type: "goki.dev/xyz.Node", LocalType: "xyz.Node", Doc: "currently selected node", Directives: gti.Directives{}, Tag: "copy:\"-\" json:\"-\" xml:\"-\" view:\"-\""}},
		{"CurManipPt", &gti.Field{Name: "CurManipPt", Type: "*goki.dev/gix/xyzv.ManipPt", LocalType: "*ManipPt", Doc: "currently selected manipulation control point", Directives: gti.Directives{}, Tag: "copy:\"-\" json:\"-\" xml:\"-\" view:\"-\""}},
		{"SelParams", &gti.Field{Name: "SelParams", Type: "goki.dev/gix/xyzv.SelParams", LocalType: "SelParams", Doc: "parameters for selection / manipulation box", Directives: gti.Directives{}, Tag: "view:\"inline\""}},
	}),
	Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"WidgetBase", &gti.Field{Name: "WidgetBase", Type: "goki.dev/gi/v2/gi.WidgetBase", LocalType: "gi.WidgetBase", Doc: "", Directives: gti.Directives{}, Tag: ""}},
	}),
	Methods:  ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}),
	Instance: &Scene{},
})

SceneType is the gti.Type for Scene

View Source
var SceneViewType = gti.AddType(&gti.Type{
	Name:       "goki.dev/gix/xyzv.SceneView",
	ShortName:  "xyzv.SceneView",
	IDName:     "scene-view",
	Doc:        "SceneView provides a toolbar controller for an xyz.Scene,\nand manipulation abilities.",
	Directives: gti.Directives{},
	Fields:     ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}),
	Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"Layout", &gti.Field{Name: "Layout", Type: "goki.dev/gi/v2/gi.Layout", LocalType: "gi.Layout", Doc: "", Directives: gti.Directives{}, Tag: ""}},
	}),
	Methods:  ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{}),
	Instance: &SceneView{},
})

SceneViewType is the gti.Type for SceneView

Functions

This section is empty.

Types

type ManipPt

type ManipPt struct {
	xyz.Solid
}

ManipPt is a manipulation control point

func NewManipPt

func NewManipPt(par ki.Ki, name string, meshName string, clr color.RGBA, pos mat32.Vec3) *ManipPt

NewManipPt adds a new manipulation point

func (*ManipPt) KiType

func (t *ManipPt) KiType() *gti.Type

KiType returns the *gti.Type of ManipPt

func (*ManipPt) New

func (t *ManipPt) New() ki.Ki

New returns a new *ManipPt value

func (*ManipPt) SetMat

func (t *ManipPt) SetMat(v xyz.Material) *ManipPt

SetMat sets the [ManipPt.Mat]

type MeshValue

type MeshValue struct {
	giv.ValueBase
}

MeshValue presents an action for displaying a MeshName and selecting meshes from a ChooserDialog

func (*MeshValue) ConfigDialog

func (vv *MeshValue) ConfigDialog(d *gi.Body) (bool, func())

func (*MeshValue) ConfigWidget

func (vv *MeshValue) ConfigWidget(widg gi.Widget)

func (*MeshValue) HasDialog

func (vv *MeshValue) HasDialog() bool

func (*MeshValue) OpenDialog

func (vv *MeshValue) OpenDialog(ctx gi.Widget, fun func())

func (*MeshValue) UpdateWidget

func (vv *MeshValue) UpdateWidget()

func (*MeshValue) WidgetType

func (vv *MeshValue) WidgetType() *gti.Type

type Scene

type Scene struct {
	gi.WidgetBase

	// Scene is the 3D Scene
	Scene *xyz.Scene `set:"-"`

	// how to deal with selection / manipulation events
	SelMode SelModes

	// currently selected node
	CurSel xyz.Node `copy:"-" json:"-" xml:"-" view:"-"`

	// currently selected manipulation control point
	CurManipPt *ManipPt `copy:"-" json:"-" xml:"-" view:"-"`

	// parameters for selection / manipulation box
	SelParams SelParams `view:"inline"`
}

Scene is a gi.Widget that manages a xyz.Scene, providing the basic rendering logic for the 3D scene in the 2D gi gui context.

func NewScene

func NewScene(par ki.Ki, name ...string) *Scene

NewScene adds a new Scene with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.

func (*Scene) ConfigFrame

func (sw *Scene) ConfigFrame()

ConfigFrame configures the framebuffer for GPU rendering, using the RenderWin GPU and Device.

func (*Scene) ConfigWidget

func (sw *Scene) ConfigWidget()

func (*Scene) CopyFieldsFrom

func (sw *Scene) CopyFieldsFrom(frm any)

func (*Scene) DrawIntoScene

func (sw *Scene) DrawIntoScene()

func (*Scene) HandleEvents

func (sw *Scene) HandleEvents()

func (*Scene) HandleSelectEvents

func (sw *Scene) HandleSelectEvents()

func (*Scene) HandleSelectEventsImpl

func (sw *Scene) HandleSelectEventsImpl(e events.Event)

func (*Scene) HandleSlideEvents

func (sw *Scene) HandleSlideEvents()

func (*Scene) KiType

func (t *Scene) KiType() *gti.Type

KiType returns the *gti.Type of Scene

func (*Scene) ManipBox

func (sw *Scene) ManipBox()

ManipBox draws a manipulation box around selected node

func (*Scene) New

func (t *Scene) New() ki.Ki

New returns a new *Scene value

func (*Scene) OnInit

func (sw *Scene) OnInit()

func (*Scene) Render

func (sw *Scene) Render()

func (*Scene) Render3D

func (sw *Scene) Render3D()

Render renders the Frame Image

func (*Scene) SceneXYZ

func (sw *Scene) SceneXYZ() *xyz.Scene

SceneXYZ returns the xyz.Scene

func (*Scene) SelectBox

func (sw *Scene) SelectBox()

SelectBox draws a selection box around selected node

func (*Scene) SetCurManipPt

func (t *Scene) SetCurManipPt(v *ManipPt) *Scene

SetCurManipPt sets the [Scene.CurManipPt]: currently selected manipulation control point

func (*Scene) SetCurSel

func (t *Scene) SetCurSel(v xyz.Node) *Scene

SetCurSel sets the [Scene.CurSel]: currently selected node

func (*Scene) SetManipPt

func (sw *Scene) SetManipPt(pt *ManipPt)

SetManipPt sets the CurManipPt

func (*Scene) SetSel

func (sw *Scene) SetSel(nd xyz.Node)

SetSel -- if Selectable is true, then given object is selected if node is nil then selection is reset.

func (*Scene) SetSelMode

func (t *Scene) SetSelMode(v SelModes) *Scene

SetSelMode sets the [Scene.SelMode]: how to deal with selection / manipulation events

func (*Scene) SetSelParams

func (t *Scene) SetSelParams(v SelParams) *Scene

SetSelParams sets the [Scene.SelParams]: parameters for selection / manipulation box

func (*Scene) SetStyles

func (sw *Scene) SetStyles()

func (*Scene) SetTooltip

func (t *Scene) SetTooltip(v string) *Scene

SetTooltip sets the [Scene.Tooltip]

func (*Scene) UpdateEnd3D

func (sw *Scene) UpdateEnd3D(updt bool)

UpdateEnd3D calls UpdateEnd on the 3D Scene: resets the scene ScUpdating flag if updt = true

func (*Scene) UpdateEndConfig3D

func (sw *Scene) UpdateEndConfig3D(updt bool)

UpdateEndConfig3D calls UpdateEndConfig on the 3D Scene and calls gi SetNeedsRender. UpdateEndConfig resets the scene ScUpdating flag if updt = true and sets the ScNeedsConfig flag; updt is from UpdateStart(). Config is for Texture, Lighting Meshes or more complex nodes).

func (*Scene) UpdateEndRender3D

func (sw *Scene) UpdateEndRender3D(updt bool)

UpdateEndRender3D calls UpdateEndRender on the 3D Scene and calls gi SetNeedsRender. resets the scene ScUpdating flag if updt = true and sets the ScNeedsRender flag; updt is from UpdateStart(). Render only updates based on camera changes, not any node-level changes. See [UpdateEndUpdate].

func (*Scene) UpdateEndUpdate3D

func (sw *Scene) UpdateEndUpdate3D(updt bool)

UpdateEndUpdate3D calls UpdateEndUpdate on the 3D Scene and calls gi SetNeedsRender. UpdateEndUpdate resets the scene ScUpdating flag if updt = true and sets the ScNeedsUpdate flag; updt is from UpdateStart(). Update is for when any node Pose or material changes happen. See [UpdateEndConfig] for major changes.

func (*Scene) UpdateStart3D

func (sw *Scene) UpdateStart3D() bool

UpdateStart3D calls UpdateStart on the 3D Scene: sets the scene ScUpdating flag to prevent render updates during construction on a scene. if already updating, returns false. Pass the result to UpdateEnd* methods.

type SceneView

type SceneView struct {
	gi.Layout
}

SceneView provides a toolbar controller for an xyz.Scene, and manipulation abilities.

func NewSceneView

func NewSceneView(par ki.Ki, name ...string) *SceneView

NewSceneView adds a new SceneView with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.

func (*SceneView) ConfigSceneView

func (sv *SceneView) ConfigSceneView()

func (*SceneView) ConfigToolbar

func (sv *SceneView) ConfigToolbar(tb *gi.Toolbar)

func (*SceneView) ConfigWidget

func (sv *SceneView) ConfigWidget()

func (*SceneView) KiType

func (t *SceneView) KiType() *gti.Type

KiType returns the *gti.Type of SceneView

func (*SceneView) New

func (t *SceneView) New() ki.Ki

New returns a new *SceneView value

func (*SceneView) OnInit

func (sv *SceneView) OnInit()

func (*SceneView) SceneWidget

func (sv *SceneView) SceneWidget() *Scene

SceneWidget returns the gi.Widget Scene (xyzv.Scene)

func (*SceneView) SceneXYZ

func (sv *SceneView) SceneXYZ() *xyz.Scene

Scene returns the xyz.Scene

func (*SceneView) SetStackTop

func (t *SceneView) SetStackTop(v int) *SceneView

SetStackTop sets the [SceneView.StackTop]

func (*SceneView) SetTooltip

func (t *SceneView) SetTooltip(v string) *SceneView

SetTooltip sets the [SceneView.Tooltip]

func (*SceneView) Toolbar

func (sv *SceneView) Toolbar() *gi.Toolbar

func (*SceneView) UpdateToolbar

func (sv *SceneView) UpdateToolbar()

type SelModes

type SelModes int32 //enums:enum

SelModes are selection modes for Scene

const (
	// NotSelectable means that selection events are ignored entirely
	NotSelectable SelModes = iota

	// Selectable means that nodes can be selected but no visible consequence occurs
	Selectable

	// SelectionBox means that a selection bounding box is drawn around selected nodes
	SelectionBox

	// Manipulable means that a manipulation box will be created for selected nodes,
	// which can update the Pose parameters dynamically.
	Manipulable
)
const SelModesN SelModes = 4

SelModesN is the highest valid value for type SelModes, plus one.

func SelModesValues

func SelModesValues() []SelModes

SelModesValues returns all possible values for the type SelModes.

func (SelModes) Desc

func (i SelModes) Desc() string

Desc returns the description of the SelModes value.

func (SelModes) Int64

func (i SelModes) Int64() int64

Int64 returns the SelModes value as an int64.

func (SelModes) IsValid

func (i SelModes) IsValid() bool

IsValid returns whether the value is a valid option for type SelModes.

func (SelModes) MarshalText

func (i SelModes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*SelModes) SetInt64

func (i *SelModes) SetInt64(in int64)

SetInt64 sets the SelModes value from an int64.

func (*SelModes) SetString

func (i *SelModes) SetString(s string) error

SetString sets the SelModes value from its string representation, and returns an error if the string is invalid.

func (SelModes) String

func (i SelModes) String() string

String returns the string representation of this SelModes value.

func (*SelModes) UnmarshalText

func (i *SelModes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (SelModes) Values

func (i SelModes) Values() []enums.Enum

Values returns all possible values for the type SelModes.

type SelParams

type SelParams struct {
	// color for selection box (default yellow)
	Color color.RGBA

	// width of the box lines, scaled by view distance
	Width float32 `def:"0.001"`

	// radius of the manipulation control point spheres, scaled by view distance
	Radius float32 `def:"0.005"`
}

SelParams are parameters for selection / manipulation box

func (*SelParams) Defaults

func (sp *SelParams) Defaults()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL