mirror of
https://github.com/Kugelschieber/go-game.git
synced 2026-01-18 06:40:28 +00:00
Code restructuring.
This commit is contained in:
40
model.go
40
model.go
@@ -14,26 +14,6 @@ type Mesh struct {
|
||||
Vao *VAO
|
||||
}
|
||||
|
||||
// Model is an actor having a 3D position, a texture and a 3D mesh.
|
||||
type Model struct {
|
||||
*Actor
|
||||
*Pos3D
|
||||
*Tex
|
||||
*Mesh
|
||||
}
|
||||
|
||||
// The model renderer is a system rendering models.
|
||||
// It has a 3D position component, to move all models at once.
|
||||
type ModelRenderer struct {
|
||||
Pos3D
|
||||
|
||||
Shader *Shader
|
||||
Camera *Camera
|
||||
ortho bool
|
||||
|
||||
models []Model
|
||||
}
|
||||
|
||||
// Creates a new mesh with given GL buffers.
|
||||
// The VAO must be prepared by ModelRenderer.
|
||||
func NewMesh(index, vertex, texcoord *VBO) *Mesh {
|
||||
@@ -56,6 +36,14 @@ func (m *Mesh) Drop() {
|
||||
m.Vao.Drop()
|
||||
}
|
||||
|
||||
// Model is an actor having a 3D position, a texture and a 3D mesh.
|
||||
type Model struct {
|
||||
*Actor
|
||||
*Pos3D
|
||||
*Tex
|
||||
*Mesh
|
||||
}
|
||||
|
||||
// Creates a new model with given mesh and texture.
|
||||
func NewModel(mesh *Mesh, tex *Tex) *Model {
|
||||
model := &Model{}
|
||||
@@ -72,6 +60,18 @@ func NewModel(mesh *Mesh, tex *Tex) *Model {
|
||||
return model
|
||||
}
|
||||
|
||||
// The model renderer is a system rendering models.
|
||||
// It has a 3D position component, to move all models at once.
|
||||
type ModelRenderer struct {
|
||||
Pos3D
|
||||
|
||||
Shader *Shader
|
||||
Camera *Camera
|
||||
ortho bool
|
||||
|
||||
models []Model
|
||||
}
|
||||
|
||||
// Creates a new model renderer using given shader and camera.
|
||||
// If shader and/or camera are nil, the default one will be used.
|
||||
// Orth can be set to true, to use orthogonal projection.
|
||||
|
||||
Reference in New Issue
Block a user