assimp

package module
v0.0.0-...-a775ba6 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2012 License: MIT Imports: 1 Imported by: 1

README

What is this?

The Open Asset Import (http://assimp.sourceforge.net/) is a library capable of reading a variety of 3D formats and present them in a single API (aiScene).

This project contains wrappers for that library and also a similar api (assimp.Scene) to manipulate the data inside a Go program.

The Go structures are implemented in pure go, so you can use it even without the Open Asset Import lib, only the package assimp/conv need the library.

How to use?

You can use your 3D models in two ways:

  • use the assimp binary (assimp/assimp) to convert your models to a pure go representation (using gob) and then inside your 3d application use the packages (assimp/enc, assimp) to load and manipulate the model.

  • in your 3d application import the (assimp/conv assimp) packages to convert and manipulate the model.

Do you have any samples?

You can read the unit tests for each package to see how the API is used or you can look at https://github.com/andrebq/exp and see a 3d application that can display your models (the application is limited to small models at this moment.)

Can I help?

Yes, just do the usual fork/edit/request thing.

Who is responsible for this?

If you want to know more about me, just go to: http://resume.amoraes.info/en-US/ there you can see my profiles and link to my personal blog.

Where I can have more information about this project?

Just check the commit messages and there is a possibility that I will post something at http://amoraes.info/

Documentation

Overview

Structures used to represent 3D scenes (imported using Open Asset Importer).

This file contains the strucutres used in the program

Index

Constants

View Source
const (
	// All indexes are under 255
	ByteSize IndexSize = 255
	// All indexes are under 65536
	ShortSize = 32767
	// Fall back
	IntSize = 2147483647
)
View Source
const (
	ErrMeshNotFound = Error("Unable to find the given mesh in the Scene")
)

Variables

This section is empty.

Functions

func RandomColor

func RandomColor(m *Mesh)

Just fill the mesh color array with some random colors

Types

type Error

type Error string

Represent an error in the structure of a scene/node.

func (Error) Error

func (e Error) Error() string

Error interface

type Face

type Face struct {
	// List of vector indices
	Indices []int
}

Hold the information of a single face. Hold only the pointers to the vector stored in the Mesh

type FlatMesh

type FlatMesh struct {
	Vertex  []float32
	Normal  []float32
	Color   []float32
	Texture []float32
	Index   []uint32
}

This structure is optimized to be used with OpenGL. The vertex information is flat and can be passed directly to OpenGL API.

Vertex and Normals are 3 components (x,y,z)

Colors are 4 components (r,g,b,a)

Face index can be a list of: int8 or int16 or int (usually it's int16), this is used to reduce the amount of data sent to the VRAM, the user must check the value of index size to discover that property should be used

32 bit floats are used instead of 64 since most of the time 32 bit's have enough space to hold most geometries

func NewFlatMesh

func NewFlatMesh(m *Mesh) *FlatMesh

Return a flat representation of the given mesh

func (*FlatMesh) FillIndexArray

func (fm *FlatMesh) FillIndexArray(size IndexSize) interface{}

Return a copy of the mesh index array with elements of the size informed.

No overflow is checked, so if you request the ByteSize and there are indexes with values greater than 255, the value will be truncated and the mesh will be deformed.

type IndexSize

type IndexSize int

Size of the vertex index

type Mesh

type Mesh struct {
	// List of vertices
	Vertices []Vector3

	// List of normals
	Normals []Vector3

	// List of colors
	Colors []Vector4

	// List of faces
	Faces []*Face

	// List of UV Coordinates (at this point, only one texture for each mesh)
	UVCoords []Vector2
	// contains filtered or unexported fields
}

Hold the Mesh information Vertices, Textures and Normals

func (*Mesh) HasNormals

func (m *Mesh) HasNormals() bool

Return true if the mesh has normal information

func (*Mesh) Id

func (m *Mesh) Id() int

Represent the id of the given mesh in the given scene.

This Id is valid only for Go and isn't loaded from the asset file

type Node

type Node struct {
	// The list of index used by this node
	Mesh []int

	// Child nodes
	Childs []*Node
}

One node in the scene.

func (*Node) AddMeshIndex

func (n *Node) AddMeshIndex(i int)

Add a mesh into this node

func (*Node) UseMesh

func (n *Node) UseMesh(m *Mesh, s *Scene) (err error)

Use the given mesh from the given scene

type Scene

type Scene struct {
	// Root node of the scene
	Root *Node

	// List of mesh
	Mesh []*Mesh
}

The Scene object, hold the root node of the scene and the list of meshes

func (*Scene) AddMesh

func (s *Scene) AddMesh(m *Mesh)

Push a new mesh into the Scene

func (*Scene) IndexOfMesh

func (s *Scene) IndexOfMesh(m *Mesh) (idx int, err error)

Index of the given mesh

type Vector2

type Vector2 [2]float64

A 2D Vertex

type Vector3

type Vector3 [3]float64

A 3D Vertex

type Vector4

type Vector4 [4]float64

A 4D Vertex

Directories

Path Synopsis
Open Asset Importer This application uses the OpenAssetLibrary to import a scene and output's a gob encoded structure (see github.com/andrebq/assimp) that can be further manipulated using just go whithout the need for cgo packages.
Open Asset Importer This application uses the OpenAssetLibrary to import a scene and output's a gob encoded structure (see github.com/andrebq/assimp) that can be further manipulated using just go whithout the need for cgo packages.
Hold the routines used to convert from C structures to the Go ones This package is a wrapper for the Open Asset Importer library (http://assimp.sourceforge.net/).
Hold the routines used to convert from C structures to the Go ones This package is a wrapper for the Open Asset Importer library (http://assimp.sourceforge.net/).
Functions to write 3D scenes to disk The only supported format right now is gob, so in order to load/save data you must also import the assimp library.
Functions to write 3D scenes to disk The only supported format right now is gob, so in order to load/save data you must also import the assimp library.

Jump to

Keyboard shortcuts

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