Documentation ¶
Index ¶
- Constants
- func NewCube(id, matID uint64, size float32) (Mesh, Material)
- func SampleRex() []byte
- func WriteDataBlockHeader(w io.Writer, hdr DataBlockHeader) error
- type DataBlockHeader
- type Decoder
- type Encoder
- type File
- type Header
- type Image
- type LineSet
- type Material
- type Mesh
- type PointList
- type SceneGraph
- type SceneNode
- type Text
- type Track
- type TrackElement
- type Triangle
Constants ¶
const ( Raw24 = iota Jpeg Png )
const (
// NotSpecified is used if no material or no texture image is set
NotSpecified = 0x7fffffffffffffff
)
Variables ¶
This section is empty.
Functions ¶
func SampleRex ¶
func SampleRex() []byte
SampleRex returns a valid REX buffer containing colored points
func WriteDataBlockHeader ¶
func WriteDataBlockHeader(w io.Writer, hdr DataBlockHeader) error
WriteDataBlockHeader writes the given data block header to the writer
Types ¶
type DataBlockHeader ¶
type DataBlockHeader struct { Type uint16 Version uint16 Size uint32 // the Size is the size of the data block w/o the data block header ID uint64 }
DataBlockHeader stores the header information of a data block
func ReadDataBlockHeader ¶
func ReadDataBlockHeader(r io.Reader) (DataBlockHeader, error)
ReadDataBlockHeader reads a data block header from reader
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder which can be used to read and decode REX files from a stream
func NewDecoder ¶
NewDecoder creates a new REX decoder with a given input stream
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is used to dump a valid REX file buffer into a writer
type File ¶
type File struct { LineSets []LineSet Texts []Text PointLists []PointList Meshes []Mesh Materials []Material Images []Image SceneNodes []SceneNode Tracks []Track UnknownBlocks uint }
File represents a complete valid REX file which can either be stored locally or sent to an arbirary writer with the Encoder.
type Header ¶
type Header struct { Magic [4]byte Version uint16 Crc uint32 NrBlocks uint16 StartAddr uint16 SizeBytes uint64 Reserved [42]byte }
Header defines the structure of the REX header
func ReadHeader ¶
ReadHeader reads the REX header from a given file
type Image ¶
Image datastructure
func ReadImage ¶
func ReadImage(r io.Reader, hdr DataBlockHeader) (*Image, error)
ReadImage reads a REX image w/o block header
type LineSet ¶
LineSet stores a list of 3D points which form a polyline. Number of lines are size(p)-1. The color is (RGBA)
func ReadLineSet ¶
func ReadLineSet(r io.Reader, hdr DataBlockHeader) (*LineSet, error)
ReadLineSet reads the block
type Material ¶
type Material struct { ID uint64 KaRgb mgl32.Vec3 KaTextureID uint64 KdRgb mgl32.Vec3 KdTextureID uint64 KsRgb mgl32.Vec3 KsTextureID uint64 Ns float32 Alpha float32 // 1 is full opaque }
Material datastructure
func NewMaterial ¶
NewMaterial creates a new default material (gray)
func ReadMaterial ¶
func ReadMaterial(r io.Reader, hdr DataBlockHeader) (*Material, error)
ReadMaterial reads a REX material
type Mesh ¶
type Mesh struct { ID uint64 Name string Coords []mgl32.Vec3 Normals []mgl32.Vec3 TexCoords []mgl32.Vec2 Colors []mgl32.Vec3 Triangles []Triangle MaterialID uint64 }
Mesh datastructure
func ReadMesh ¶
func ReadMesh(r io.Reader, hdr DataBlockHeader) (*Mesh, error)
ReadMesh reads a REX mesh
type PointList ¶
PointList stores a list of (colored) 3D points
func ReadPointList ¶
func ReadPointList(r io.Reader, hdr DataBlockHeader) (*PointList, error)
ReadPointList reads the block
type SceneGraph ¶
type SceneGraph struct { GUID string `json:"guid,omitempty"` Name string `json:"name"` Root SceneNode `json:"root"` }
SceneGraph describes the complete scenegraph tree with one root node
type SceneNode ¶
type SceneNode struct { ID uint64 `json:"id"` GeometryID uint64 `json:"geometryId"` Name string `json:"name"` Translation mgl32.Vec3 `json:"translation"` Rotation mgl32.Vec4 `json:"rotation"` Scale mgl32.Vec3 `json:"scale"` // TODO scale is only one float !!!! Children []SceneNode `json:"children,omitempty"` // not serialized to binary block! }
SceneNode is a description of a scenegraph node and can reference a REX geometry block
func NewSceneNode ¶
NewSceneNode creates a new empty SceneNode pointing to no geometry
func ReadSceneNode ¶
func ReadSceneNode(r io.Reader, hdr DataBlockHeader) (*SceneNode, error)
ReadSceneNode reads the block
type Text ¶
type Text struct { ID uint64 Red float32 Green float32 Blue float32 Alpha float32 Position mgl32.Vec3 FontSize float32 Text string }
Text datastructure
func ReadText ¶
func ReadText(r io.Reader, hdr DataBlockHeader) (*Text, error)
ReadText reads a REX text
type Track ¶
type Track struct { ID uint64 NrOfPoints uint32 Timestamp int64 // UNIX time - seconds since January 1, 1970 UTC Points []TrackElement }
Track consists of a list of 3D points with orientation
func ReadTrack ¶
func ReadTrack(r io.Reader, hdr DataBlockHeader) (*Track, error)
ReadTrack reads a REX track
type TrackElement ¶
A TrackElement for a track consists of its x,y,z coordinate, the orientation which is denoted as a normalized normal vector pointing from the device to the world (LookAt vector) and a confidence value.