speedtree

package
v0.7.35 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SDKParseError error = errors.New("failed to parse speedtree sdk data")

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Type        string `xml:",attr" json:"type"`
	Count       int    `xml:",attr" json:"count"`
	Normalize   *bool  `xml:",attr" json:"normalize,omitempty"`
	Description string `xml:",attr" json:"description"`
}
type Header struct {
	Unk00        uint32
	LODDistances [6]float32

	MaterialDefinitionCount  uint32
	MaterialDefinitionOffset uint32

	IndexDefinitionCount  uint32
	IndexDefinitionOffset uint32

	VertexDefinitionCount  uint32
	VertexDefinitionOffset uint32

	MeshDefinitionCount  uint32
	MeshDefinitionOffset uint32

	SDKDataSize   uint32
	SDKDataOffset uint32
	// contains filtered or unexported fields
}

type IndexDefinition

type IndexDefinition struct {
	Count      uint32 `json:"count"`
	Stride     uint32 `json:"stride"`
	Offset     uint32 `json:"offset"`
	VertexDef  uint32 `json:"vertex_definition"` // These probably correspond to materials or vertices
	Unk01      uint32 `json:"unk01"`
	MeshOffset uint32 `json:"mesh_offset"`
	MeshCount  uint32 `json:"mesh_count"`
}

type MaterialDefinition

type MaterialDefinition struct {
	Index uint64        `json:"index"`
	Path  stingray.Hash `json:"path"`
}

type MeshDefinition

type MeshDefinition struct {
	Material    uint32 `json:"material"`
	IndexCount  uint32 `json:"index_count"`
	IndexOffset uint32 `json:"index_offset"`
}

Not really sure what these are for, or if they're actually mesh definitions at all

type SpeedTreeInfo

type SpeedTreeInfo struct {
	LODDistances      [6]float32           `json:"lod_thresholds"`
	StingrayMaterials []MaterialDefinition `json:"material_definitions"`
	IndexDefinitions  []IndexDefinition    `json:"index_definitions"`
	VertexDefinitions []VertexDefinition   `json:"vertex_definitions"`
	MeshDefinitions   []MeshDefinition     `json:"mesh_definitions"`

	Extents             []mgl32.Vec3         `json:"extents"`            // min and max, may be empty if speedtree sdk data failed to parse
	SDKMaterials        []SpeedTreeMaterial  `json:"sdk_materials"`      // may be empty if speedtree sdk data failed to parse
	VertexScriptName    string               `json:"vertex_script_name"` // may be empty if speedtree sdk data failed to parse
	*VertexXML          `json:"vertex_xml"`  // may be empty if speedtree sdk data failed to parse
	BillboardScriptName string               `json:"billboard_script_name"` // may be empty if speedtree sdk data failed to parse
	BillboardXML        *VertexXML           `json:"billboard_xml"`         // may be empty if speedtree sdk data failed to parse
	TextureScriptName   string               `json:"texture_script_name"`   // may be empty if speedtree sdk data failed to parse
	*TextureXML         `json:"texture_xml"` // may be empty if speedtree sdk data failed to parse
}

func LoadSpeedTree

func LoadSpeedTree(r io.ReadSeeker) (*SpeedTreeInfo, error)

type SpeedTreeMaterial

type SpeedTreeMaterial struct {
	Name     string             `json:"name"`
	Index    uint32             `json:"index"`
	Textures []SpeedTreeTexture `json:"textures"`
}

type SpeedTreeSDKData

type SpeedTreeSDKData struct {
	Magic [12]byte
	Root  SpeedTreeSDKNode
}

Isn't it ironic that the graphics toolset used for creating trees represents nearly all of its data as an extended tree?

type SpeedTreeSDKNode

type SpeedTreeSDKNode struct {
	Count   uint32
	Offsets []uint32 // Offsets to more nodes, relative to this node
}

type SpeedTreeTexture

type SpeedTreeTexture struct {
	Used uint32    `json:"used"` // in examples I've seen this is 0 or 1, but I haven't looked at a ton of examples yet
	Name string    `json:"name"` // same as Layers, I've only seen one string in a texture node, but I haven't done any exhaustive research
	Tint []float32 `json:"tint"` // ditto
}

type Stream

type Stream struct {
	Name      string      `xml:"Name,attr" json:"name"`
	Attribute []Attribute `json:"attributes"`
}

type TextureN

type TextureN struct {
	Skip              *bool  `xml:",attr" json:"skip,omitempty"`
	Suffix            string `xml:",attr" json:"suffix,omitempty"`
	MipGenerationFlag string `xml:",attr" json:"mip_generation_flag,omitempty"`
}

type TextureXML

type TextureXML struct {
	XMLName       xml.Name `xml:"SpeedTreeTexturePacker" json:"speed_tree_texture_packer"`
	Shader        string   `xml:",attr" json:"shader_name"`
	ForceTextures bool     `xml:",attr" json:"force_textures"`
	Texture0      TextureN `json:"texture0"`
	Texture1      TextureN `json:"texture1"`
	Texture2      TextureN `json:"texture2"`
	Texture3      TextureN `json:"texture3"`
	Texture4      TextureN `json:"texture4"`
}

type VertexDefinition

type VertexDefinition struct {
	Count  uint32 `json:"count"`
	Stride uint32 `json:"stride"`
	Offset uint32 `json:"offset"`
}

type VertexXML

type VertexXML struct {
	XMLName           xml.Name `xml:"SpeedTreeVertexPacker" json:"speed_tree_vertex_packer"`
	Program           string   `xml:",attr" json:"program"`
	Force32bitIndices bool     `xml:",attr" json:"force_32bit_indices"`
	Stream            Stream   `json:"stream"`
}

Jump to

Keyboard shortcuts

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