mirror of
https://github.com/bloeys/assimp-go.git
synced 2025-12-29 08:28:20 +00:00
Scene flags+start material import
This commit is contained in:
@ -24,9 +24,6 @@ import (
|
||||
type Node struct {
|
||||
}
|
||||
|
||||
type Material struct {
|
||||
}
|
||||
|
||||
type Animation struct {
|
||||
}
|
||||
|
||||
@ -43,6 +40,8 @@ type Metadata struct {
|
||||
}
|
||||
|
||||
type Scene struct {
|
||||
Flags SceneFlag
|
||||
|
||||
RootNode *Node
|
||||
Meshes []*Mesh
|
||||
Materials []*Material
|
||||
@ -73,6 +72,7 @@ func getAiErr() error {
|
||||
func parseScene(cs *C.struct_aiScene) *Scene {
|
||||
|
||||
s := &Scene{}
|
||||
s.Flags = SceneFlag(cs.mFlags)
|
||||
s.Meshes = parseMeshes(cs.mMeshes, uint(cs.mNumMeshes))
|
||||
|
||||
return s
|
||||
|
||||
172
asig/enums.go
172
asig/enums.go
@ -1,8 +1,67 @@
|
||||
package asig
|
||||
|
||||
type SceneFlag int32
|
||||
|
||||
const (
|
||||
/**
|
||||
* Specifies that the scene data structure that was imported is not complete.
|
||||
* This flag bypasses some internal validations and allows the import
|
||||
* of animation skeletons, material libraries or camera animation paths
|
||||
* using Assimp. Most applications won't support such data.
|
||||
*/
|
||||
SceneFlagIncomplete SceneFlag = 1 << 0
|
||||
|
||||
/**
|
||||
* This flag is set by the validation postprocess-step (PostProcessValidateDataStructure)
|
||||
* if the validation is successful. In a validated scene you can be sure that
|
||||
* any cross references in the data structure (e.g. vertex indices) are valid.
|
||||
*/
|
||||
SceneFlagValidated SceneFlag = 1 << 1
|
||||
|
||||
/**
|
||||
* This flag is set by the validation postprocess-step (PostProcessValidateDataStructure)
|
||||
* if the validation is successful but some issues have been found.
|
||||
* This can for example mean that a texture that does not exist is referenced
|
||||
* by a material or that the bone weights for a vertex don't sum to 1.0 ... .
|
||||
* In most cases you should still be able to use the import. This flag could
|
||||
* be useful for applications which don't capture Assimp's log output.
|
||||
*/
|
||||
SceneFlagValidationWarning SceneFlag = 1 << 2
|
||||
|
||||
/**
|
||||
* This flag is currently only set by the PostProcessJoinIdenticalVertices step.
|
||||
* It indicates that the vertices of the output meshes aren't in the internal
|
||||
* verbose format anymore. In the verbose format all vertices are unique,
|
||||
* no vertex is ever referenced by more than one face.
|
||||
*/
|
||||
SceneFlagNonVerboseFormat SceneFlag = 1 << 3
|
||||
|
||||
/**
|
||||
* Denotes pure height-map terrain data. Pure terrains usually consist of quads,
|
||||
* sometimes triangles, in a regular grid. The x,y coordinates of all vertex
|
||||
* positions refer to the x,y coordinates on the terrain height map, the z-axis
|
||||
* stores the elevation at a specific point.
|
||||
*
|
||||
* TER (Terragen) and HMP (3D Game Studio) are height map formats.
|
||||
* @note Assimp is probably not the best choice for loading *huge* terrains -
|
||||
* fully triangulated data takes extremely much free store and should be avoided
|
||||
* as long as possible (typically you'll do the triangulation when you actually
|
||||
* need to render it).
|
||||
*/
|
||||
SceneFlagTerrain SceneFlag = 1 << 4
|
||||
|
||||
/**
|
||||
* Specifies that the scene data can be shared between structures. For example:
|
||||
* one vertex in few faces. SceneFlagNonVerboseFormat can not be
|
||||
* used for this because SceneFlagNonVerboseFormat has internal
|
||||
* meaning about postprocessing steps.
|
||||
*/
|
||||
SceneFlagAllowShared SceneFlag = 1 << 5
|
||||
)
|
||||
|
||||
//aiGetErrorString specifies the types of primitives that can be present in a mesh
|
||||
type PrimitiveType int32
|
||||
|
||||
//Specifies types of primitives that can be present in a mesh
|
||||
const (
|
||||
PrimitiveTypePoint = 1 << 0
|
||||
PrimitiveTypeLine = 1 << 1
|
||||
@ -10,9 +69,9 @@ const (
|
||||
PrimitiveTypePolygon = 1 << 3
|
||||
)
|
||||
|
||||
//MorphMethod specifies the Supported methods of mesh morphing
|
||||
type MorphMethod int32
|
||||
|
||||
//Supported methods of mesh morphing
|
||||
const (
|
||||
//Interpolation between morph targets
|
||||
MorphMethodVertexBlend = 0x1
|
||||
@ -58,3 +117,112 @@ const (
|
||||
PostProcessDropNormals PostProcess = 0x40000000
|
||||
PostProcessGenBoundingBoxes PostProcess = 0x80000000
|
||||
)
|
||||
|
||||
type TextureType int32
|
||||
|
||||
const (
|
||||
|
||||
/** Dummy value.
|
||||
*
|
||||
* No texture, but the value to be used as 'texture semantic'
|
||||
* (MaterialProperty.Semantic) for all material properties
|
||||
* *not* related to textures.
|
||||
*/
|
||||
TextureTypeNone TextureType = 0
|
||||
|
||||
/** The texture is combined with the result of the diffuse
|
||||
* lighting equation.
|
||||
*/
|
||||
TextureTypeDiffuse TextureType = 1
|
||||
|
||||
/** The texture is combined with the result of the specular
|
||||
* lighting equation.
|
||||
*/
|
||||
TextureTypeSpecular TextureType = 2
|
||||
|
||||
/** The texture is combined with the result of the ambient
|
||||
* lighting equation.
|
||||
*/
|
||||
TextureTypeAmbient TextureType = 3
|
||||
|
||||
/** The texture is added to the result of the lighting
|
||||
* calculation. It isn't influenced by incoming light.
|
||||
*/
|
||||
TextureTypeEmissive TextureType = 4
|
||||
|
||||
/** The texture is a height map.
|
||||
*
|
||||
* By convention, higher gray-scale values stand for
|
||||
* higher elevations from the base height.
|
||||
*/
|
||||
TextureTypeHeight TextureType = 5
|
||||
|
||||
/** The texture is a (tangent space) normal-map.
|
||||
*
|
||||
* Agn, there are several conventions for tangent-space
|
||||
* normal maps. Assimp does (intentionally) not
|
||||
* distinguish here.
|
||||
*/
|
||||
TextureTypeNormal TextureType = 6
|
||||
|
||||
/** The texture defines the glossiness of the material.
|
||||
*
|
||||
* The glossiness is in fact the exponent of the specular
|
||||
* (phong) lighting equation. Usually there is a conversion
|
||||
* function defined to map the linear color values in the
|
||||
* texture to a suitable exponent. Have fun.
|
||||
*/
|
||||
TextureTypeShininess TextureType = 7
|
||||
|
||||
/** The texture defines per-pixel opacity.
|
||||
*
|
||||
* Usually 'white' means opaque and 'black' means
|
||||
* 'transparency'. Or quite the opposite. Have fun.
|
||||
*/
|
||||
TextureTypeOpacity TextureType = 8
|
||||
|
||||
/** Displacement texture
|
||||
*
|
||||
* The exact purpose and format is application-dependent.
|
||||
* Higher color values stand for higher vertex displacements.
|
||||
*/
|
||||
TextureTypeDisplacement TextureType = 9
|
||||
|
||||
/** Lightmap texture (aka Ambient Occlusion)
|
||||
*
|
||||
* Both 'Lightmaps' and dedicated 'ambient occlusion maps' are
|
||||
* covered by this material property. The texture contains a
|
||||
* scaling value for the final color value of a pixel. Its
|
||||
* intensity is not affected by incoming light.
|
||||
*/
|
||||
TextureTypeLightmap TextureType = 10
|
||||
|
||||
/** Reflection texture
|
||||
*
|
||||
* Contains the color of a perfect mirror reflection.
|
||||
* Rarely used, almost never for real-time applications.
|
||||
*/
|
||||
TextureTypeReflection TextureType = 11
|
||||
|
||||
/** Unknown texture
|
||||
* A texture reference that does not match any of the definitions
|
||||
* above is considered to be 'unknown'. It is still imported,
|
||||
* but is excluded from any further post-processing.
|
||||
*/
|
||||
TextureTypeUnknown TextureType = 18
|
||||
)
|
||||
|
||||
/** PBR Materials
|
||||
* PBR definitions from maya and other modelling packages now use this standard.
|
||||
* This was originally introduced around 2012.
|
||||
* Support for this is in game engines like Godot, Unreal or Unity3D.
|
||||
* Modelling packages which use this are very common now.
|
||||
*/
|
||||
const (
|
||||
TextureTypeBaseColor TextureType = 12
|
||||
TextureTypeNormalCamera TextureType = 13
|
||||
TextureTypeEmissionColor TextureType = 14
|
||||
TextureTypeMetalness TextureType = 15
|
||||
TextureTypeDiffuseRoughness TextureType = 16
|
||||
TextureTypeAmbientOcclusion TextureType = 17
|
||||
)
|
||||
|
||||
52
asig/material.go
Executable file
52
asig/material.go
Executable file
@ -0,0 +1,52 @@
|
||||
package asig
|
||||
|
||||
type Material struct {
|
||||
|
||||
/** List of all material properties loaded. */
|
||||
Properties []*MaterialProperty
|
||||
|
||||
/** Storage allocated */
|
||||
NumAllocated uint
|
||||
}
|
||||
|
||||
type MaterialProperty struct {
|
||||
|
||||
//Specifies the name of the property (aka key). Keys are generally case insensitive.
|
||||
name string
|
||||
|
||||
/** Textures: Specifies their exact usage semantic.
|
||||
* For non-texture properties, this member is always 0 (aka TextureTypeNone).
|
||||
*/
|
||||
Semantic TextureType
|
||||
|
||||
/** Textures: Specifies the index of the texture.
|
||||
* For non-texture properties, this member is always 0.
|
||||
*/
|
||||
Index uint
|
||||
|
||||
/** Type information for the property.
|
||||
*
|
||||
* Defines the data layout inside the data buffer. This is used
|
||||
* by the library internally to perform debug checks and to
|
||||
* utilize proper type conversions.
|
||||
* (It's probably a hacky solution, but it works.)
|
||||
*/
|
||||
TypeInfo MatPropertyTypeInfo
|
||||
|
||||
/** Binary buffer to hold the property's value.
|
||||
* The size of the buffer is always mDataLength.
|
||||
*/
|
||||
Data []byte
|
||||
}
|
||||
|
||||
type MatPropertyTypeInfo int32
|
||||
|
||||
const (
|
||||
MatPropTypeInfoFloat32 MatPropertyTypeInfo = iota + 1
|
||||
MatPropTypeInfoFloat64
|
||||
MatPropTypeInfoString
|
||||
MatPropTypeInfoInt32
|
||||
|
||||
//Simple binary buffer, content undefined. Not convertible to anything.
|
||||
MatPropTypeInfoBuffer
|
||||
)
|
||||
Reference in New Issue
Block a user