-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
53 lines (46 loc) Β· 1005 Bytes
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"errors"
"fmt"
rl "github.com/gen2brain/raylib-go/raylib"
)
type ModelType int32
const (
Wall ModelType = iota
WallDoorway
WallCorner
WallCornerSmall
Box
)
func (scene *Scene3D) AddModel(modelType ModelType, pos, rot rl.Vector3, scale float32) error {
path := ""
uid := fmt.Sprintf("wall%d", len(scene.Items))
if _, e := scene.Items[uid]; e {
return errors.New("model.go: same key already exists: " + uid)
}
switch modelType {
case Wall:
path = "./res/gltf/wall.gltf"
case WallDoorway:
path = "./res/gltf/wall_doorway.gltf"
case WallCorner:
path = "./res/gltf/wall_corner.gltf"
case WallCornerSmall:
path = "./res/gltf/wall_corner_small.gltf"
case Box:
path = "./res/gltf/box_large.gltf"
}
if path == "" {
return errors.New("model key not found")
}
temp := rl.LoadModel(path)
temp.Transform = rl.MatrixRotateXYZ(rot)
scene.Items[uid] = &SceneItem{
uid: uid,
model: temp,
pos: pos,
rot: rot,
scale: scale,
}
return nil
}