Skip to content

Commit

Permalink
Object depths are stored in a map.
Browse files Browse the repository at this point in the history
This is done to be faster than the previous object sorting method.
Creating depth vertex list to make things simpler.
FIX: DrawDebugWireframe() / DrawDebugDrawOrder() / DrawDebugDrawCallCount() / DrawDebugNormals() to properly frustum cull.
Adding GLTFLoadOptions.CameraDepth to set camera depth when loading scenes from the GLTF file.
FIX: Moving setting up skin root to before instance collection; this way cloning armatures now properly clones its meshes.
  • Loading branch information
SolarLune committed Apr 11, 2022
1 parent 00c565f commit 8e5f36b
Show file tree
Hide file tree
Showing 10 changed files with 559 additions and 190 deletions.
268 changes: 156 additions & 112 deletions camera.go

Large diffs are not rendered by default.

Binary file modified examples/animations/animations.blend
Binary file not shown.
205 changes: 192 additions & 13 deletions examples/animations/animations.gltf

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/animations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ var gltf []byte
func NewGame() *Game {

game := &Game{
Width: 398,
Height: 224,
Width: 796,
Height: 448,
PrevMousePosition: vector.Vector{},
DrawDebugText: true,
}
Expand Down Expand Up @@ -247,7 +247,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
if g.DrawDebugText {
g.Camera.DrawDebugText(screen, 1, colors.White())
txt := "F1 to toggle this text\nWASD: Move, Mouse: Look\n1 Key: Play [SmoothRoll] Animation On Table\n2 Key: Play [StepRoll] Animation on Table\nNote the animations can blend\nF Key: Play Animation on Skinned Mesh\nNote that the nodes move as well\nF4: Toggle fullscreen\nF6: Node Debug View\nESC: Quit"
text.Draw(screen, txt, basicfont.Face7x13, 0, 104, color.RGBA{255, 0, 0, 255})
text.Draw(screen, txt, basicfont.Face7x13, 0, 140, color.RGBA{255, 0, 0, 255})
}

}
Expand Down
11 changes: 6 additions & 5 deletions examples/lighting/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type Game struct {

func NewGame() *Game {
game := &Game{
Width: 1920,
Height: 1080,
Width: 796,
Height: 448,
PrevMousePosition: vector.Vector{},
DrawDebugText: true,
}
Expand All @@ -57,8 +57,8 @@ func NewGame() *Game {
func (g *Game) Init() {

opt := tetra3d.DefaultGLTFLoadOptions()
opt.CameraWidth = 1920
opt.CameraHeight = 1080
opt.CameraWidth = g.Width
opt.CameraHeight = g.Height
opt.LoadBackfaceCulling = true
library, err := tetra3d.LoadGLTFData(gltfData, opt)
if err != nil {
Expand All @@ -68,7 +68,7 @@ func (g *Game) Init() {
g.Library = library
g.Scene = library.Scenes[0]

g.Camera = tetra3d.NewCamera(1920, 1080)
g.Camera = tetra3d.NewCamera(g.Width, g.Height)
g.Camera.SetLocalPosition(vector.Vector{0, 2, 15})
g.Scene.Root.AddChildren(g.Camera)

Expand Down Expand Up @@ -194,6 +194,7 @@ func (g *Game) Update() error {
}

func (g *Game) Draw(screen *ebiten.Image) {

// Clear, but with a color - we can use the world lighting color for this.
light := g.Scene.Root.Get("World Ambient").(*tetra3d.AmbientLight)
energy := light.Energy
Expand Down
Loading

0 comments on commit 8e5f36b

Please sign in to comment.