engine: github.com/g3n/engine/graphic Index | Files

package graphic

import "github.com/g3n/engine/graphic"

Package graphic implements scene objects which have a graphic representation.

Index

Package Files

axis_helper.go doc.go graphic.go grid_helper.go line_strip.go lines.go logger.go mesh.go normals_helper.go points.go rigged_mesh.go skeleton.go skybox.go sprite.go

Constants

const MaxBoneInfluencers = 4

MaxBoneInfluencers is the maximum number of bone influencers per vertex.

type AxisHelper Uses

type AxisHelper struct {
    Lines
}

AxisHelper is the visual representation of the three axes

func NewAxisHelper Uses

func NewAxisHelper(size float32) *AxisHelper

NewAxisHelper returns a pointer to a new AxisHelper object

type Graphic Uses

type Graphic struct {
    core.Node // Embedded Node

    ShaderDefines gls.ShaderDefines // Graphic-specific shader defines
    // contains filtered or unexported fields
}

Graphic is a Node which has a visible representation in the scene. It has an associated geometry and one or more materials. It is the base type used by other graphics such as lines, line_strip, points and meshes.

func NewGraphic Uses

func NewGraphic(igeom geometry.IGeometry, mode uint32) *Graphic

NewGraphic creates and returns a pointer to a new graphic object with the specified geometry and OpenGL primitive. The created graphic object, though, has not materials.

func (*Graphic) AddGroupMaterial Uses

func (gr *Graphic) AddGroupMaterial(igr IGraphic, imat material.IMaterial, gindex int)

AddGroupMaterial adds a material for the specified geometry group.

func (*Graphic) AddMaterial Uses

func (gr *Graphic) AddMaterial(igr IGraphic, imat material.IMaterial, start, count int)

AddMaterial adds a material for the specified subset of vertices. If the material applies to all vertices, start and count must be 0.

func (*Graphic) BoundingBox Uses

func (gr *Graphic) BoundingBox() math32.Box3

BoundingBox recursively calculates and returns the bounding box containing this node and all its children.

func (*Graphic) CalculateMatrices Uses

func (gr *Graphic) CalculateMatrices(gs *gls.GLS, rinfo *core.RenderInfo)

CalculateMatrices calculates the model view and model view projection matrices.

func (*Graphic) ClearMaterials Uses

func (gr *Graphic) ClearMaterials()

ClearMaterials removes all the materials from this Graphic.

func (*Graphic) Clone Uses

func (gr *Graphic) Clone() core.INode

Clone clones the graphic and satisfies the INode interface. It should be called by Clone() implementations of IGraphic. Note that the topmost implementation calling this method needs to call clone.SetIGraphic(igraphic) after calling this method.

func (*Graphic) Cullable Uses

func (gr *Graphic) Cullable() bool

Cullable satisfies the IGraphic interface and returns the cullable state of this graphic.

func (*Graphic) Dispose Uses

func (gr *Graphic) Dispose()

Dispose overrides the embedded Node Dispose method.

func (*Graphic) GetGeometry Uses

func (gr *Graphic) GetGeometry() *geometry.Geometry

GetGeometry satisfies the IGraphic interface and returns a pointer to the geometry associated with this graphic.

func (*Graphic) GetGraphic Uses

func (gr *Graphic) GetGraphic() *Graphic

GetGraphic satisfies the IGraphic interface and returns pointer to the base Graphic.

func (*Graphic) GetMaterial Uses

func (gr *Graphic) GetMaterial(vpos int) material.IMaterial

GetMaterial returns the material associated with the specified vertex position.

func (*Graphic) IGeometry Uses

func (gr *Graphic) IGeometry() geometry.IGeometry

IGeometry satisfies the IGraphic interface and returns a pointer to the IGeometry associated with this graphic.

func (*Graphic) Init Uses

func (gr *Graphic) Init(igeom geometry.IGeometry, mode uint32) *Graphic

Init initializes a Graphic type embedded in another type with the specified geometry and OpenGL mode.

func (*Graphic) Materials Uses

func (gr *Graphic) Materials() []GraphicMaterial

Materials returns slice with this graphic materials.

func (*Graphic) ModelMatrix Uses

func (gr *Graphic) ModelMatrix() *math32.Matrix4

ModelViewMatrix returns the last cached model view matrix for this graphic.

func (*Graphic) ModelViewMatrix Uses

func (gr *Graphic) ModelViewMatrix() *math32.Matrix4

ModelViewMatrix returns the last cached model view matrix for this graphic.

func (*Graphic) ModelViewProjectionMatrix Uses

func (gr *Graphic) ModelViewProjectionMatrix() *math32.Matrix4

ModelViewProjectionMatrix returns the last cached model view projection matrix for this graphic.

func (*Graphic) RenderOrder Uses

func (gr *Graphic) RenderOrder() int

RenderOrder returns the render order of the object.

func (*Graphic) Renderable Uses

func (gr *Graphic) Renderable() bool

Renderable satisfies the IGraphic interface and returns the renderable state of this graphic.

func (*Graphic) SetCullable Uses

func (gr *Graphic) SetCullable(state bool)

SetCullable satisfies the IGraphic interface and sets the cullable state of this Graphic (default = true).

func (*Graphic) SetIGraphic Uses

func (gr *Graphic) SetIGraphic(igr IGraphic)

SetIGraphic sets the IGraphic on all this Graphic's GraphicMaterials.

func (*Graphic) SetRenderOrder Uses

func (gr *Graphic) SetRenderOrder(order int)

SetRenderOrder sets the render order of the object. All objects have renderOrder of 0 by default. To render before renderOrder 0 set a lower renderOrder e.g. -1. To render after renderOrder 0 set a higher renderOrder e.g. 1

func (*Graphic) SetRenderable Uses

func (gr *Graphic) SetRenderable(state bool)

SetRenderable satisfies the IGraphic interface and sets the renderable state of this Graphic (default = true).

type GraphicMaterial Uses

type GraphicMaterial struct {
    // contains filtered or unexported fields
}

GraphicMaterial specifies the material to be used for a subset of vertices from the Graphic geometry A Graphic object has at least one GraphicMaterial.

func (*GraphicMaterial) IGraphic Uses

func (grmat *GraphicMaterial) IGraphic() IGraphic

IGraphic returns the graphic associated with the GraphicMaterial.

func (*GraphicMaterial) IMaterial Uses

func (grmat *GraphicMaterial) IMaterial() material.IMaterial

IMaterial returns the material associated with the GraphicMaterial.

func (*GraphicMaterial) Render Uses

func (grmat *GraphicMaterial) Render(gs *gls.GLS, rinfo *core.RenderInfo)

Render is called by the renderer to render this graphic material.

type GridHelper Uses

type GridHelper struct {
    Lines
}

GridHelper is the visual representation of a grid

func NewGridHelper Uses

func NewGridHelper(size, step float32, color *math32.Color) *GridHelper

NewGridHelper creates and returns a pointer to a new grid help object with the specified size and step

type IGraphic Uses

type IGraphic interface {
    core.INode
    GetGraphic() *Graphic
    GetGeometry() *geometry.Geometry
    IGeometry() geometry.IGeometry
    SetRenderable(bool)
    Renderable() bool
    SetCullable(bool)
    Cullable() bool
    RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo)
}

IGraphic is the interface for all Graphic objects.

type LineStrip Uses

type LineStrip struct {
    Graphic // Embedded graphic object
    // contains filtered or unexported fields
}

LineStrip is a Graphic which is rendered as a collection of connected lines.

func NewLineStrip Uses

func NewLineStrip(igeom geometry.IGeometry, imat material.IMaterial) *LineStrip

NewLineStrip creates and returns a pointer to a new LineStrip graphic with the specified geometry and material.

func (*LineStrip) Raycast Uses

func (l *LineStrip) Raycast(rc *core.Raycaster, intersects *[]core.Intersect)

Raycast satisfies the INode interface and checks the intersections of this geometry with the specified raycaster.

func (*LineStrip) RenderSetup Uses

func (l *LineStrip) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo)

RenderSetup is called by the engine before drawing this geometry.

type Lines Uses

type Lines struct {
    Graphic // Embedded graphic object
    // contains filtered or unexported fields
}

Lines is a Graphic which is rendered as a collection of independent lines.

func NewLines Uses

func NewLines(igeom geometry.IGeometry, imat material.IMaterial) *Lines

NewLines returns a pointer to a new Lines object.

func (*Lines) Init Uses

func (l *Lines) Init(igeom geometry.IGeometry, imat material.IMaterial)

Init initializes the Lines object and adds the specified material.

func (*Lines) Raycast Uses

func (l *Lines) Raycast(rc *core.Raycaster, intersects *[]core.Intersect)

Raycast satisfies the INode interface and checks the intersections of this geometry with the specified raycaster.

func (*Lines) RenderSetup Uses

func (l *Lines) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo)

RenderSetup is called by the engine before drawing this geometry.

type Mesh Uses

type Mesh struct {
    Graphic // Embedded graphic
    // contains filtered or unexported fields
}

Mesh is a Graphic with uniforms for the model, view, projection, and normal matrices.

func NewMesh Uses

func NewMesh(igeom geometry.IGeometry, imat material.IMaterial) *Mesh

NewMesh creates and returns a pointer to a mesh with the specified geometry and material. If the mesh has multi materials, the material specified here must be nil and the individual materials must be add using "AddMaterial" or AddGroupMaterial".

func (*Mesh) AddGroupMaterial Uses

func (m *Mesh) AddGroupMaterial(imat material.IMaterial, gindex int)

AddGroupMaterial adds a material for the specified geometry group.

func (*Mesh) AddMaterial Uses

func (m *Mesh) AddMaterial(imat material.IMaterial, start, count int)

AddMaterial adds a material for the specified subset of vertices.

func (*Mesh) Clone Uses

func (m *Mesh) Clone() core.INode

Clone clones the mesh and satisfies the INode interface.

func (*Mesh) Init Uses

func (m *Mesh) Init(igeom geometry.IGeometry, imat material.IMaterial)

Init initializes the Mesh and its uniforms.

func (*Mesh) Raycast Uses

func (m *Mesh) Raycast(rc *core.Raycaster, intersects *[]core.Intersect)

Raycast checks intersections between this geometry and the specified raycaster and if any found appends it to the specified intersects array.

func (*Mesh) RenderSetup Uses

func (m *Mesh) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo)

RenderSetup is called by the engine before drawing the mesh geometry It is responsible to updating the current shader uniforms with the model matrices.

func (*Mesh) SetMaterial Uses

func (m *Mesh) SetMaterial(imat material.IMaterial)

SetMaterial clears all materials and adds the specified material for all vertices.

type NormalsHelper Uses

type NormalsHelper struct {
    Lines
    // contains filtered or unexported fields
}

NormalsHelper is the visual representation of the normals of a target object.

func NewNormalsHelper Uses

func NewNormalsHelper(ig IGraphic, size float32, color *math32.Color, lineWidth float32) *NormalsHelper

NewNormalsHelper creates, initializes and returns a pointer to Normals helper object. This helper shows the surface normals of the specified object.

func (*NormalsHelper) Update Uses

func (nh *NormalsHelper) Update()

Update should be called in the render loop to update the normals based on the target object.

type Points Uses

type Points struct {
    Graphic // Embedded graphic
    // contains filtered or unexported fields
}

Points represents a geometry containing only points

func NewPoints Uses

func NewPoints(igeom geometry.IGeometry, imat material.IMaterial) *Points

NewPoints creates and returns a graphic points object with the specified geometry and material.

func (*Points) Raycast Uses

func (p *Points) Raycast(rc *core.Raycaster, intersects *[]core.Intersect)

Raycast satisfies the INode interface and checks the intersections of this geometry with the specified raycaster.

func (*Points) RenderSetup Uses

func (p *Points) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo)

RenderSetup is called by the engine before rendering this graphic.

type RiggedMesh Uses

type RiggedMesh struct {
    *Mesh // Embedded mesh
    // contains filtered or unexported fields
}

RiggedMesh is a Mesh associated with a skeleton.

func NewRiggedMesh Uses

func NewRiggedMesh(mesh *Mesh) *RiggedMesh

NewRiggedMesh returns a new rigged mesh.

func (*RiggedMesh) RenderSetup Uses

func (rm *RiggedMesh) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo)

RenderSetup is called by the renderer before drawing the geometry.

func (*RiggedMesh) SetSkeleton Uses

func (rm *RiggedMesh) SetSkeleton(sk *Skeleton)

SetSkeleton sets the skeleton used by the rigged mesh.

func (*RiggedMesh) Skeleton Uses

func (rm *RiggedMesh) Skeleton() *Skeleton

SetSkeleton returns the skeleton used by the rigged mesh.

type Skeleton Uses

type Skeleton struct {
    // contains filtered or unexported fields
}

Skeleton contains armature information.

func NewSkeleton Uses

func NewSkeleton() *Skeleton

NewSkeleton creates and returns a pointer to a new Skeleton.

func (*Skeleton) AddBone Uses

func (sk *Skeleton) AddBone(node *core.Node, inverseBindMatrix *math32.Matrix4)

AddBone adds a bone to the skeleton along with an optional inverseBindMatrix.

func (*Skeleton) BoneMatrices Uses

func (sk *Skeleton) BoneMatrices(invMat *math32.Matrix4) []math32.Matrix4

BoneMatrices calculates and returns the bone world matrices to be sent to the shader.

func (*Skeleton) Bones Uses

func (sk *Skeleton) Bones() []*core.Node

Bones returns the list of bones in the skeleton.

type Skybox Uses

type Skybox struct {
    Graphic // embedded graphic object
    // contains filtered or unexported fields
}

Skybox is the Graphic that represents a skybox.

func NewSkybox Uses

func NewSkybox(data SkyboxData) (*Skybox, error)

NewSkybox creates and returns a pointer to a Skybox with the specified textures.

func (*Skybox) RenderSetup Uses

func (skybox *Skybox) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo)

RenderSetup is called by the engine before drawing the skybox geometry It is responsible to updating the current shader uniforms with the model matrices.

type SkyboxData Uses

type SkyboxData struct {
    DirAndPrefix string
    Extension    string
    Suffixes     [6]string
}

SkyboxData contains the data necessary to locate the textures for a Skybox in a concise manner.

type Sprite Uses

type Sprite struct {
    Graphic // Embedded graphic
    // contains filtered or unexported fields
}

Sprite is a potentially animated image positioned in space that always faces the camera.

func NewSprite Uses

func NewSprite(width, height float32, imat material.IMaterial) *Sprite

NewSprite creates and returns a pointer to a sprite with the specified dimensions and material

func (*Sprite) Raycast Uses

func (s *Sprite) Raycast(rc *core.Raycaster, intersects *[]core.Intersect)

Raycast checks intersections between this geometry and the specified raycaster and if any found appends it to the specified intersects array.

func (*Sprite) RenderSetup Uses

func (s *Sprite) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo)

RenderSetup sets up the rendering of the sprite.

Package graphic imports 8 packages (graph) and is imported by 24 packages. Updated 2019-01-31. Refresh now. Tools for package owners.