xyzview

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: BSD-3-Clause Imports: 24 Imported by: 4

Documentation

Overview

Package xyzview provides a GUI view for a 3D xyz scene.

Index

Constants

View Source
const (
	// SelectedBoxName 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.
	SelectedBoxName = "__SelectedBox"

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

Variables

View Source
var ManipPointType = types.AddType(&types.Type{Name: "cogentcore.org/core/xyzview.ManipPoint", IDName: "manip-point", Doc: "ManipPoint is a manipulation control point", Directives: []types.Directive{{Tool: "core", Directive: "no-new"}}, Embeds: []types.Field{{Name: "Solid"}}, Instance: &ManipPoint{}})

ManipPointType is the types.Type for ManipPoint

View Source
var SceneType = types.AddType(&types.Type{Name: "cogentcore.org/core/xyzview.Scene", IDName: "scene", Doc: "Scene is a core.Widget that manages a xyz.Scene,\nproviding the basic rendering logic for the 3D scene\nin the 2D core GUI context.", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "XYZ", Doc: "XYZ is the 3D xyz.Scene"}, {Name: "SelectionMode", Doc: "how to deal with selection / manipulation events"}, {Name: "CurrentSelected", Doc: "currently selected node"}, {Name: "CurrentManipPoint", Doc: "currently selected manipulation control point"}, {Name: "SelectionParams", Doc: "parameters for selection / manipulation box"}}, Instance: &Scene{}})

SceneType is the types.Type for Scene

View Source
var SceneViewType = types.AddType(&types.Type{Name: "cogentcore.org/core/xyzview.SceneView", IDName: "scene-view", Doc: "SceneView provides a toolbar controller for an xyz.Scene,\nand manipulation abilities.", Embeds: []types.Field{{Name: "Layout"}}, Instance: &SceneView{}})

SceneViewType is the types.Type for SceneView

Functions

This section is empty.

Types

type ManipPoint

type ManipPoint struct {
	xyz.Solid
}

ManipPoint is a manipulation control point

func NewManipPoint

func NewManipPoint(parent tree.Node, name string, meshName string, clr color.RGBA, pos math32.Vector3) *ManipPoint

NewManipPoint adds a new manipulation point

func (*ManipPoint) New

func (t *ManipPoint) New() tree.Node

New returns a new *ManipPoint value

func (*ManipPoint) NodeType

func (t *ManipPoint) NodeType() *types.Type

NodeType returns the *types.Type of ManipPoint

func (*ManipPoint) SetMat

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

SetMat sets the [ManipPoint.Mat]

type MeshValue

type MeshValue struct {
	views.ValueBase[*core.Button]
}

MeshValue represents an xyz.MeshName with a button.

func (*MeshValue) Config

func (v *MeshValue) Config()

func (*MeshValue) ConfigDialog

func (v *MeshValue) ConfigDialog(d *core.Body) (bool, func())

func (*MeshValue) Update

func (v *MeshValue) Update()

type Scene

type Scene struct {
	core.WidgetBase

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

	// how to deal with selection / manipulation events
	SelectionMode SelectionModes

	// currently selected node
	CurrentSelected xyz.Node `copier:"-" json:"-" xml:"-" view:"-"`

	// currently selected manipulation control point
	CurrentManipPoint *ManipPoint `copier:"-" json:"-" xml:"-" view:"-"`

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

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

func NewScene

func NewScene(parent tree.Node, name ...string) *Scene

NewScene adds a new Scene with the given name to the given parent: Scene is a core.Widget that manages a xyz.Scene, providing the basic rendering logic for the 3D scene in the 2D core GUI context.

func (*Scene) Config

func (sw *Scene) Config()

func (*Scene) ConfigFrame

func (sw *Scene) ConfigFrame()

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

func (*Scene) Destroy

func (sw *Scene) Destroy()

func (*Scene) DirectRenderDraw

func (sw *Scene) DirectRenderDraw(drw system.Drawer, idx int, flipY bool)

DirectRenderDraw draws the current image to RenderWin drawer

func (*Scene) DirectRenderImage

func (sw *Scene) DirectRenderImage(drw system.Drawer, idx int)

DirectRenderImage uploads framebuffer image

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) ManipBox

func (sw *Scene) ManipBox()

ManipBox draws a manipulation box around selected node

func (*Scene) New

func (t *Scene) New() tree.Node

New returns a new *Scene value

func (*Scene) NodeType

func (t *Scene) NodeType() *types.Type

NodeType returns the *types.Type of Scene

func (*Scene) OnAdd

func (sw *Scene) OnAdd()

func (*Scene) OnInit

func (sw *Scene) OnInit()

func (*Scene) Render

func (sw *Scene) Render()

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) SetCurrentManipPoint

func (t *Scene) SetCurrentManipPoint(v *ManipPoint) *Scene

SetCurrentManipPoint sets the [Scene.CurrentManipPoint]: currently selected manipulation control point

func (*Scene) SetCurrentSelected

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

SetCurrentSelected sets the [Scene.CurrentSelected]: currently selected node

func (*Scene) SetSelected

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

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

func (*Scene) SetSelectionMode

func (t *Scene) SetSelectionMode(v SelectionModes) *Scene

SetSelectionMode sets the [Scene.SelectionMode]: how to deal with selection / manipulation events

func (*Scene) SetSelectionParams

func (t *Scene) SetSelectionParams(v SelectionParams) *Scene

SetSelectionParams sets the [Scene.SelectionParams]: 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]

type SceneView

type SceneView struct {
	core.Layout
}

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

func NewSceneView

func NewSceneView(parent tree.Node, name ...string) *SceneView

NewSceneView adds a new SceneView with the given name to the given parent: SceneView provides a toolbar controller for an xyz.Scene, and manipulation abilities.

func (*SceneView) Config

func (sv *SceneView) Config()

func (*SceneView) ConfigSceneView

func (sv *SceneView) ConfigSceneView()

func (*SceneView) ConfigToolbar

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

func (*SceneView) New

func (t *SceneView) New() tree.Node

New returns a new *SceneView value

func (*SceneView) NodeType

func (t *SceneView) NodeType() *types.Type

NodeType returns the *types.Type of SceneView

func (*SceneView) OnInit

func (sv *SceneView) OnInit()

func (*SceneView) SceneWidget

func (sv *SceneView) SceneWidget() *Scene

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

func (*SceneView) SceneXYZ

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

Scene returns the xyz.Scene

func (*SceneView) SetTooltip

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

SetTooltip sets the [SceneView.Tooltip]

func (*SceneView) Toolbar

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

func (*SceneView) UpdateToolbar

func (sv *SceneView) UpdateToolbar()

type SelectionModes

type SelectionModes int32 //enums:enum

SelectionModes are selection modes for Scene

const (
	// NotSelectable means that selection events are ignored entirely
	NotSelectable SelectionModes = 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 SelectionModesN SelectionModes = 4

SelectionModesN is the highest valid value for type SelectionModes, plus one.

func SelectionModesValues

func SelectionModesValues() []SelectionModes

SelectionModesValues returns all possible values for the type SelectionModes.

func (SelectionModes) Desc

func (i SelectionModes) Desc() string

Desc returns the description of the SelectionModes value.

func (SelectionModes) Int64

func (i SelectionModes) Int64() int64

Int64 returns the SelectionModes value as an int64.

func (SelectionModes) MarshalText

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

MarshalText implements the encoding.TextMarshaler interface.

func (*SelectionModes) SetInt64

func (i *SelectionModes) SetInt64(in int64)

SetInt64 sets the SelectionModes value from an int64.

func (*SelectionModes) SetString

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

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

func (SelectionModes) String

func (i SelectionModes) String() string

String returns the string representation of this SelectionModes value.

func (*SelectionModes) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (SelectionModes) Values

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

Values returns all possible values for the type SelectionModes.

type SelectionParams

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

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

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

SelectionParams are parameters for selection / manipulation box

func (*SelectionParams) Defaults

func (sp *SelectionParams) Defaults()

Jump to

Keyboard shortcuts

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