graphics

package
v0.0.0-...-d77b964 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Unlicense Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExtensionVtf     = ".vtf"
	BasePathMaterial = "materials/"
	BasePathModel    = "models/"
)

Variables

This section is empty.

Functions

func LightmapCoordsForFaceFromTexInfo

func LightmapCoordsForFaceFromTexInfo(vertexes []float32,
	faceInfo *face.Face,
	tx *texinfo.TexInfo,
	lightmapWidth float32,
	lightmapHeight float32,
	lightmapOffsetX float32,
	lightmapOffsetY float32) []float32

LightmapCoordsForFaceFromTexInfo create lightmap coordinates from TexInfo

func LoadProp

func LoadProp(path string, fs virtualFileSystem) (*mesh.Model, error)

LoadProp loads a single prop/model of known filepath

func TexCoordsForFaceFromTexInfo

func TexCoordsForFaceFromTexInfo(vertexes []float32, tx *texinfo.TexInfo, width int, height int) []float32

TexCoordsForFaceFromTexInfo Generate texturecoordinates for face data

func VertexDataForModel

func VertexDataForModel(studioModel *studiomodel.StudioModel, lodIdx int) ([]float32, []float32, []float32, [][]uint32, error)

VertexDataForModel loads model vertex data

Types

type AtlasTexture

type AtlasTexture struct {
	W, H int
	X, Y float32
	// contains filtered or unexported fields
}

func (*AtlasTexture) Release

func (atlasTexture *AtlasTexture) Release()

type Bsp

type Bsp struct {
	StaticPropDictionary map[string]*mesh2.Model
	StaticProps          []StaticProp

	EntityPropDictionary map[string]*mesh2.Model
	// contains filtered or unexported fields
}

Bsp

func NewBsp

func NewBsp(
	file *bsp.Bsp,
	mesh *mesh2.BasicMesh,
	faces []BspFace,
	dispFaces []int,
	materialDictionary map[string]*Material,
	textureInfos []texinfo.TexInfo,
	lightmapAtlas *TextureAtlas) *Bsp

NewBsp

func (*Bsp) Camera

func (bsp *Bsp) Camera() *Camera

func (*Bsp) DispFaces

func (bsp *Bsp) DispFaces() []int

DispFaces

func (*Bsp) Faces

func (bsp *Bsp) Faces() []BspFace

Faces

func (*Bsp) File

func (bsp *Bsp) File() *bsp.Bsp

func (*Bsp) LightmapAtlas

func (bsp *Bsp) LightmapAtlas() *TextureAtlas

func (*Bsp) MaterialDictionary

func (bsp *Bsp) MaterialDictionary() map[string]*Material

MaterialDictionary

func (*Bsp) Mesh

func (bsp *Bsp) Mesh() *mesh2.BasicMesh

BasicMesh

func (*Bsp) SetCamera

func (bsp *Bsp) SetCamera(camera *Camera)

func (*Bsp) TexInfos

func (bsp *Bsp) TexInfos() []texinfo.TexInfo

type BspFace

type BspFace struct {
	// contains filtered or unexported fields
}

BspFace

func NewMeshFace

func NewMeshFace(offset int32, length int32, texInfo *texinfo.TexInfo, bspFace *face.Face) BspFace

NewFace

func (*BspFace) Length

func (face *BspFace) Length() int

Length

func (*BspFace) Material

func (face *BspFace) Material() string

func (*BspFace) Offset

func (face *BspFace) Offset() int

Offset

func (*BspFace) RawFace

func (face *BspFace) RawFace() *face.Face

func (*BspFace) SetMaterial

func (face *BspFace) SetMaterial(materialPath string)

func (*BspFace) TexInfo

func (face *BspFace) TexInfo() *texinfo.TexInfo

type Camera

type Camera struct {
	// contains filtered or unexported fields
}

Camera

func NewCamera

func NewCamera(fov float32, aspectRatio float32) *Camera

NewCamera returns a new camera fov should be provided in radians

func (*Camera) AspectRatio

func (camera *Camera) AspectRatio() float32

AspectRatio

func (*Camera) Backwards

func (camera *Camera) Backwards(dt float64)

Backwards

func (*Camera) Forwards

func (camera *Camera) Forwards(dt float64)

Forwards

func (*Camera) Fov

func (camera *Camera) Fov() float32

Fov

func (*Camera) Left

func (camera *Camera) Left(dt float64)

Left

func (*Camera) ModelMatrix

func (camera *Camera) ModelMatrix() mgl32.Mat4

ModelMatrix returns identity matrix (camera model is our position!)

func (*Camera) ProjectionMatrix

func (camera *Camera) ProjectionMatrix() mgl32.Mat4

ProjectionMatrix calculates projection matrix. This is unlikely to change throughout program lifetime, but could do

func (*Camera) Right

func (camera *Camera) Right(dt float64)

Right

func (*Camera) Rotate

func (camera *Camera) Rotate(x, y, z float32)

Rotate

func (*Camera) Transform

func (camera *Camera) Transform() *Transform

Transform Returns this entity's transform component

func (*Camera) Update

func (camera *Camera) Update(dt float64)

Update updates the camera position

func (*Camera) ViewMatrix

func (camera *Camera) ViewMatrix() mgl32.Mat4

ViewMatrix calculates the cameras View matrix

type Frustum

type Frustum struct {
	// contains filtered or unexported fields
}

Frustum based on https://gist.github.com/jimmikaelkael/2e4ffa5712d61816c7ca

func FrustumFromCamera

func FrustumFromCamera(camera *Camera) *Frustum

FrustumFromCamera

func (*Frustum) IsCuboidInFrustum

func (frustum *Frustum) IsCuboidInFrustum(mins, maxs mgl32.Vec3) bool

IsCuboidInFrustum NOTE: This fails for leafs where all points sit outside the frustum but the contents is actually inside it

func (*Frustum) IsLeafInFrustum

func (frustum *Frustum) IsLeafInFrustum(mins, maxs mgl32.Vec3) bool

IsCuboidInFrustum

func (*Frustum) IsPointInFrustum

func (frustum *Frustum) IsPointInFrustum(x, y, z float32) bool

type Material

type Material struct {

	// ShaderName
	ShaderName string
	// BaseTextureName
	BaseTextureName string
	// Skip
	Skip bool
	// Alpha
	Alpha float32
	// Translucent
	Translucent bool
	// contains filtered or unexported fields
}

Material

func LoadMaterial

func LoadMaterial(fs VirtualFileSystem, filePath string) (mat *Material, err error)

func NewMaterial

func NewMaterial(filePath string) *Material

func (*Material) FilePath

func (mat *Material) FilePath() string

FilePath returns this materials location in whatever filesystem it was found

type StaticProp

type StaticProp struct {
	Transform Transform
	// contains filtered or unexported fields
}

StaticProp is a somewhat specialised model that implements a few core entity features (largely because it is basically a renderable entity that cannot do anything or be reference)

func NewStaticProp

func NewStaticProp(lumpProp game.IStaticPropDataLump, propLeafs *game.StaticPropLeafLump, renderable *mesh.Model) *StaticProp

NewStaticProp returns new StaticProp

func (*StaticProp) FadeMaxDistance

func (prop *StaticProp) FadeMaxDistance() float32

func (*StaticProp) FadeMinDistance

func (prop *StaticProp) FadeMinDistance() float32

func (*StaticProp) LeafList

func (prop *StaticProp) LeafList() []uint16

LeafList returrns all leafs that this props is in

func (*StaticProp) Model

func (prop *StaticProp) Model() *mesh.ModelInstance

Model returns props model

type Texture

type Texture adapter.Texture

type Texture2D

type Texture2D struct {
	// contains filtered or unexported fields
}

Texture2D is a material defined by raw/computed colour data

func LoadTexture

func LoadTexture(fs VirtualFileSystem, filePath string) (*Texture2D, error)

LoadTexture

func NewErrorTexture

func NewErrorTexture(name string) *Texture2D

NewError returns new Error material

func NewTexture

func NewTexture(filePath string, width, height int, format uint32, colour []uint8) *Texture2D

func (*Texture2D) Format

func (texture *Texture2D) Format() uint32

Format returns colour format

func (*Texture2D) Height

func (texture *Texture2D) Height() int

Height

func (*Texture2D) Image

func (texture *Texture2D) Image() []uint8

Image returns raw colour data

func (*Texture2D) Release

func (texture *Texture2D) Release()

Free color data from memory

func (*Texture2D) Width

func (texture *Texture2D) Width() int

Width

type TextureAtlas

type TextureAtlas struct {
	// contains filtered or unexported fields
}

TextureAtlas is a simple 2d texture atlas. Does NOT support transparency

func NewTextureAtlas

func NewTextureAtlas(width, height int) *TextureAtlas

func (*TextureAtlas) AddRaw

func (atlas *TextureAtlas) AddRaw(width, height int, colour []uint8) *AtlasTexture

func (*TextureAtlas) AtlasEntry

func (atlas *TextureAtlas) AtlasEntry(index int) *AtlasTexture

func (*TextureAtlas) Format

func (atlas *TextureAtlas) Format() uint32

func (*TextureAtlas) Height

func (atlas *TextureAtlas) Height() int

func (*TextureAtlas) Image

func (atlas *TextureAtlas) Image() []uint8

func (*TextureAtlas) Pack

func (atlas *TextureAtlas) Pack() []AtlasTexture

func (*TextureAtlas) PopulatedHeight

func (atlas *TextureAtlas) PopulatedHeight() int

func (*TextureAtlas) PopulatedWidth

func (atlas *TextureAtlas) PopulatedWidth() int

func (*TextureAtlas) Release

func (texture *TextureAtlas) Release()

Free color data from memory

func (*TextureAtlas) Width

func (atlas *TextureAtlas) Width() int

type Transform

type Transform struct {
	Translation mgl32.Vec3
	Orientation mgl32.Quat
	Scale       mgl32.Vec3
	Velocity    mgl32.Vec3
	// contains filtered or unexported fields
}

Transform Represents the transformation of an entity in a 3-dimensional space: position, rotation and scale. Note: Orientation is measured in degrees

func (*Transform) TransformationMatrix

func (transform *Transform) TransformationMatrix() mgl32.Mat4

TransformationMatrix computes object transformation matrix

type VirtualFileSystem

type VirtualFileSystem interface {
	GetFile(string) (io.Reader, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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