model

package
v0.0.0-...-b7300e8 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VertexAttributeDescriptions

func VertexAttributeDescriptions() []vk.VertexInputAttributeDescription

VertexAttributeDescriptions return Vulkan attribute descriptors

func VertexBindingDescriptions

func VertexBindingDescriptions() []vk.VertexInputBindingDescription

VertexBindingDescriptions return Vulkan Vertex descriptors

Types

type Collada

type Collada struct {
	Geometries []Geometry `xml:"library_geometries>geometry"`
	Materials  []Material `xml:"library_materials>material"`
	Effects    []Effect   `xml:"library_effects>effect"`
}

Collada is the top-level Collada object

type ColladaObject

type ColladaObject struct {
	Object
	// contains filtered or unexported fields
}

ColladaObject is imported from a collada (.dae) file. Loaded and held in memory

func (*ColladaObject) Position

func (co *ColladaObject) Position() glm.Mat4

Position implements interface

func (*ColladaObject) Rotation

func (co *ColladaObject) Rotation() glm.Mat4

Rotation implements interface

func (*ColladaObject) SetPosition

func (co *ColladaObject) SetPosition(pos glm.Mat4)

SetPosition implements interface

func (*ColladaObject) SetRotation

func (co *ColladaObject) SetRotation(rot glm.Mat4)

SetRotation implements interface

func (*ColladaObject) Texture

func (co *ColladaObject) Texture() image.Image

Texture implements interface

func (*ColladaObject) Vertices

func (co *ColladaObject) Vertices() []Vertex

Vertices implements interface

type Effect

type Effect struct {
	ID       string     `xml:"id,attr"`
	Emission [4]float32 // The following need custom Unmarshaller
	Diffuse  [4]float32
	Specular float32
}

Effect is Collada's effect, located in library_effects

type EffectURL

type EffectURL struct {
	URL string `xml:"url,attr"`
}

EffectURL contains the location url to the effect

type Floats

type Floats struct {
	ID   string
	Data []float32
}

Floats is the array of floats

func (*Floats) UnmarshalXML

func (f *Floats) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the array of floats

type Geometry

type Geometry struct {
	Mesh Mesh   `xml:"mesh"`
	ID   string `xml:"id,attr"`
	Name string `xml:"name,attr"`
}

Geometry represents Collada's geometry

type Input

type Input struct {
	Semantic string `xml:"semantic,attr"`
	Source   string `xml:"source,attr"`
	Offset   uint   `xml:"offset,attr"`
	Set      uint   `xml:"set,attr"`
}

Input is Collada'a input type

type Material

type Material struct {
	ID      string      `xml:"id,attr"`
	Name    string      `xml:"name,attr"`
	Effects []EffectURL `xml:"instance_effect"`
}

Material is Collada's material located in library_materials

type Mesh

type Mesh struct {
	Source    []Source  `xml:"source"`
	Vertices  Vertices  `xml:"vertices"`
	Triangles Triangles `xml:"triangles"`
}

Mesh contains all the primitive data

type Object

type Object interface {

	// SetPosition sets the object's current position in space.
	// Has to be thread-safe
	SetPosition(glm.Mat4)

	// Position gets the object's current position in space.
	// Has to be thread-safe
	Position() glm.Mat4

	// SetRotation sets the object's rotation matrix.
	// Has to be thread-safe
	SetRotation(glm.Mat4)

	// Rotation gets the object's rotation matrix.
	// Has to be thread-safe
	Rotation() glm.Mat4

	// Vertices returns the vertices for Renderer use,
	// so it has to match the descriptors exactly
	Vertices() []Vertex

	// Texture returns the raw data of a color texture image
	// for use in the Renderer
	Texture() image.Image
}

Object represents the engine supported model

func ImportColladaObject

func ImportColladaObject(fileContents []byte, texture image.Image) (Object, error)

ImportColladaObject reads given file and converts Collada object to engine's internal object

type Source

type Source struct {
	ID     string `xml:"id,attr"`
	Floats Floats `xml:"float_array"`
}

Source links to other sources where data is present

func (Source) GetVec2

func (s Source) GetVec2(idx int) glm.Vec2

GetVec2 returns a set of floats from a given index this function assumes array is made in sets of 2 elements

func (Source) GetVec3

func (s Source) GetVec3(idx int) glm.Vec3

GetVec3 returns a set of floats from a given index this function assumes array is made in sets of 3 elements

type Texture

type Texture struct {
	Img    image.Image
	Raw    []uint8
	Bounds image.Rectangle
}

Texture is a container component for textures. Because textures can either be in an image form or raw form, this struct accomodates both

type Triangles

type Triangles struct {
	Count    int     `xml:"count,attr"`
	Material string  `xml:"material,attr"`
	Inputs   []Input `xml:"input"`
	Index    []int
}

Triangles contain the list of triangles

func (*Triangles) UnmarshalXML

func (t *Triangles) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML parses the index list

type Uniform

type Uniform struct {
	View       glm.Mat4
	Projection glm.Mat4
}

Uniform defines a model-view-projection object

type Vertex

type Vertex struct {
	Pos    glm.Vec3
	Normal glm.Vec3
	Color  glm.Vec4
	Tex    glm.Vec2
}

Vertex is a model vertex

type Vertices

type Vertices struct {
	ID     string  `xml:"id,attr"`
	Inputs []Input `xml:"input"`
}

Vertices contains the list of vertices

Jump to

Keyboard shortcuts

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