Documentation ¶
Index ¶
- func AddCube(p, d [3]uint8, uvd uint8, f t.Facing, c *t.Cube, m *CubeMesh)
- func AddFace[T any](p, d [3]uint8, uvd uint8, f t.Facing, c T, m Mesh[T])
- func BuildVoxelMesh[T comparable](v VoxelSource[T], d Mesh[T])
- type AABB
- type Animation
- type AnimationFrame
- type App
- func (a *App) AddChunkDD(d *ChunkDrawDescriptor)
- func (a *App) AddDebugLine(c [3]uint8, f string, args ...any)
- func (a *App) AddLineDD(d *LineMeshDrawDescriptor)
- func (a *App) AddModelDD(d *ModelDrawDescriptor)
- func (a *App) AddUIMesh(m *UIMesh)
- func (a *App) Delete()
- func (a *App) Draw(c *Camera)
- func (a *App) NewTextMesh() *TextMesh
- func (a *App) NewUIMesh() *UIMesh
- func (a *App) RemoveChunkDD(id uint32)
- func (a *App) RemoveLineDD(id uint32)
- func (a *App) RemoveModelDD(id uint32)
- func (a *App) RemoveUIMesh(m *UIMesh)
- func (a *App) SetCrosshair(f t.FaceIndex, l uint16)
- func (a *App) SetCursor(f t.FaceIndex, l uint16)
- func (a *App) SetCursorPosition(p mgl32.Vec2)
- type Camera
- type ChunkDrawDescriptor
- type ColoredString
- type CubeMesh
- type CubeMeshDrawDescriptor
- type FaceAtlas
- type LineMesh
- type LineMeshDrawDescriptor
- type Mesh
- type ModelDrawDescriptor
- type NinePatch
- type Part
- type TextMesh
- type Thing
- type UIMesh
- func (e *UIMesh) AddCube(m *CubeMeshDrawDescriptor)
- func (e *UIMesh) CubeMeshIcon(x, y, w, h, d int, c *t.Cube, f t.Facing, defs []*t.Cube) *CubeMeshDrawDescriptor
- func (e *UIMesh) NinePatch(x, y, w, h int, n NinePatch)
- func (e *UIMesh) Print(x, y int, c [3]uint8, s string, args ...any)
- func (e *UIMesh) Reset(ui, text bool)
- func (e *UIMesh) Scaled(x, y, w, h int, i t.FaceIndex)
- func (e *UIMesh) Tile(x, y int, i t.FaceIndex)
- type VoxelMesh
- type VoxelMeshDrawDescriptor
- type VoxelSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildVoxelMesh ¶
func BuildVoxelMesh[T comparable](v VoxelSource[T], d Mesh[T])
BuildVoxelMesh builds a VoxelMesh object from the passed voxel source and constructs faces in the destination mesh. Note that the destination mesh is not reset before faces are added.
Types ¶
type Animation ¶
type Animation struct { Frames []*AnimationFrame // List of all frames // contains filtered or unexported fields }
Animation contains the information and functionality to play an animation loop on a model. Animations consist of rotations to joints only.
type AnimationFrame ¶
type AnimationFrame struct { Time float32 // Time T for interpolation to Q TTL float32 // Time left to move Joints map[string]*mgl32.Quat // Map of part ID's to quaternions that describe that part's final rotation Targets map[string]mgl32.Quat // Target rotations for each joint Starts map[string]mgl32.Quat // Staring rotation of the part in the frame }
AnimationFrame describes a single frame of the animation.
type App ¶
type App struct { CursorVisible bool // If true, draw the cursor CrosshairVisible bool // If true, draw the crosshair DebugTextVisible bool // If true, draw the debug text WireFramesVisible bool // If true, draws wire frames // contains filtered or unexported fields }
App manages a set of drawable objects and the shader programs used to draw them.
func (*App) AddChunkDD ¶
func (a *App) AddChunkDD(d *ChunkDrawDescriptor)
AddChunkDD adds the chunk draw descriptor to the list to draw.
func (*App) AddDebugLine ¶
AddDebugLine sets the debug text drawn in the bottom-left.
func (*App) AddLineDD ¶
func (a *App) AddLineDD(d *LineMeshDrawDescriptor)
AddLineDD adds the line draw descriptor to the list to draw.
func (*App) AddModelDD ¶
func (a *App) AddModelDD(d *ModelDrawDescriptor)
AddModelDD adds the model draw descriptor to the list to draw.
func (*App) Delete ¶
func (a *App) Delete()
Delete removes all memory and GPU resources managed by the app.
func (*App) NewTextMesh ¶
NewTextMesh returns a new text mesh ready for use.
func (*App) RemoveChunkDD ¶
RemoveChunkDD removes the chunk draw descriptor by ID.
func (*App) RemoveLineDD ¶
RemoveLineDD removes the line draw descriptor by ID.
func (*App) RemoveModelDD ¶
RemoveModelDD removes the model draw descriptor by ID.
func (*App) RemoveUIMesh ¶
RemoveUIMesh removes the passed UI mesh from the renderer.
func (*App) SetCrosshair ¶
SetCrosshair sets the UI tile to use as the 3D crosshair.
func (*App) SetCursorPosition ¶
SetCursorPosition sets the cursor position.
type Camera ¶
type Camera struct { Position mgl32.Vec3 // Position of the camera Front mgl32.Vec3 // Camera facing direction Up mgl32.Vec3 // Camera up vector Pitch float32 // Camera rotation about the X axis Yaw float32 // Camera rotation about the Y axis }
Camera manages the properties and matrixes of a camera.
func (*Camera) TransformMatrix ¶
TransformMatrix returns the matrix to transform from world space to camera space.
type ChunkDrawDescriptor ¶
type ChunkDrawDescriptor struct { ID uint32 // ID CubeDD CubeMeshDrawDescriptor // The draw descriptor for the cube mesh VoxelDDs []*VoxelMeshDrawDescriptor // Draw descriptors for all voxel meshes contained within the chunk }
ChunkDrawDescriptor describes how and where to render the static portions of a scene.
type ColoredString ¶
ColoredString is a string associated with an RGB color.
type CubeMesh ¶
type CubeMesh struct {
// contains filtered or unexported fields
}
CubeMesh is a utility struct that builds cube-based meshes.
func NewCubeMesh ¶
NewCubeMesh constructs a new CubeMesh object ready for use.
type CubeMeshDrawDescriptor ¶
type CubeMeshDrawDescriptor struct { ID uint32 // ID Mesh *CubeMesh // The mesh to draw Position mgl32.Vec3 // Position of the bottom-north-west corner of the mesh Orientation t.Orientation // Describes the origin and rotation of the mesh }
CubeMeshDrawDescriptor describes how and where to draw a cube mesh.
type FaceAtlas ¶
type FaceAtlas struct {
// contains filtered or unexported fields
}
FaceAtlas manages
func NewFaceAtlas ¶
func NewFaceAtlas() *FaceAtlas
NewFaceAtlas creates a new FaceAtlas object ready for use.
type LineMesh ¶
type LineMesh struct { Orientation t.Orientation // Orientation of the wire frame Hidden bool // If true, do not draw the line mesh // contains filtered or unexported fields }
LineMesh provides a simple axis indicator made of full-bright lines.
type LineMeshDrawDescriptor ¶
type LineMeshDrawDescriptor struct { ID uint32 // ID Orientation t.Orientation // Origin of the model Mesh *LineMesh // Mesh }
LineMeshDrawDescriptor describes how and where to render a line mesh.
type Mesh ¶
type Mesh[T any] interface { // Reset resets the vertex data of the mesh. Reset() // contains filtered or unexported methods }
Mesh is implemented by all mesh types in c3d.
type ModelDrawDescriptor ¶
type ModelDrawDescriptor struct { ID uint32 // ID Bounds AABB // Bounds of the model Origin mgl32.Vec3 // Origin of the model in model space Orientation t.Orientation // Origin of the model Root *Part // Root part that everything else is attached to }
ModelDrawDescriptor describes how and where to render a dynamic model.
type NinePatch ¶
NinePatch describes the resources used to generate an arbitrarily sized rectangle skinned with nine tiles stretched over the area.
type Part ¶
type Part struct { ID string // Unique ID of the part for animation references Mesh *VoxelMesh // Voxel mesh for the part Origin mgl32.Vec3 // Center point of the part Orientation t.Orientation // Current part orientation relative to the parent Children []*Part // Child parts, if any }
Part manages a voxel volume that represents one body part of a model.
type TextMesh ¶
type TextMesh struct {
// contains filtered or unexported fields
}
TextMesh is a drawable layer of text. TextMesh may be printed into the layer at any point, and may overlap.
type UIMesh ¶
type UIMesh struct { Cubes []*CubeMeshDrawDescriptor // List of all cube meshes to draw Position mgl32.Vec2 // Position of the element in virtual screen units Layer uint16 // Layer index, the higher the value the higher priority Hidden bool // If true, do not render the mesh or any of its children // contains filtered or unexported fields }
UIMesh is a drawable 2D orthographic mode object that can include ui tiles and text.
func (*UIMesh) AddCube ¶
func (e *UIMesh) AddCube(m *CubeMeshDrawDescriptor)
AddCube adds a cube to the list of cube meshes.
func (*UIMesh) CubeMeshIcon ¶
func (e *UIMesh) CubeMeshIcon(x, y, w, h, d int, c *t.Cube, f t.Facing, defs []*t.Cube) *CubeMeshDrawDescriptor
CubeMeshIcon adds an icon rendering of a cube mesh.
func (*UIMesh) Reset ¶
Reset resets the text object to blank. Internal memory buffers are retained to reduce allocations.
type VoxelMesh ¶
type VoxelMesh struct {
// contains filtered or unexported fields
}
VoxelMesh is a utility struct that builds voxel-based meshes.
func NewVoxelMesh ¶
func NewVoxelMesh() *VoxelMesh
NewVoxelMesh constructs a new CubeMesh object ready for use.
type VoxelMeshDrawDescriptor ¶
type VoxelMeshDrawDescriptor struct { ID uint32 // ID Mesh *VoxelMesh // The mesh to draw Position mgl32.Vec3 // Position of the center point of the voxel mesh Facing t.Facing // Facing of the mesh }
VoxelMeshDrawDescriptor describes how and where to draw a cube mesh.
type VoxelSource ¶
type VoxelSource[T any] interface { // Get returns the value at the given position within the voxel volume. Get(x, y, z int) T // Dimensions returns the dimensions of the voxel volume. Dimensions() (w, h, d int) // IsEmpty returns true if the value is considered empty. IsEmpty(v T) bool }
VoxelSource is the interface that must be implemented by voxel data providers to the BuildVoxelMesh function.