# Base entities of the depth 3D game framework
module depth_core
-intrude import gamnit::flat
+import gamnit::flat_core
# Visible 3D entity in the game world
#
# Position of this sprite in world coordinates
var center: Point3d[Float] is writable
- # Rotation on the Z axis
- var rotation = 0.0 is writable
+ # Rotation around the X axis (+ looks up, - looks down)
+ #
+ # Positive values look up, and negative look down.
+ #
+ # All actor rotations follow the right hand rule.
+ # The default orientation of the model should look towards -Z.
+ var pitch = 0.0 is writable
+
+ # Rotation around the Y axis (+ turns left, - turns right)
+ #
+ # Positive values turn `self` to the left, and negative values to the right.
+ #
+ # All actor rotations follow the right hand rule.
+ # The default orientation of the model should look towards -Z.
+ var yaw = 0.0 is writable
+
+ # Rotation around the Z axis (looking to -Z: + turns counterclockwise, - clockwise)
+ #
+ # From the default camera point of view, looking down on the Z axis,
+ # positive values turn `self` counterclockwise, and negative values clockwise.
+ #
+ # All actor rotations follow the right hand rule.
+ # The default orientation of the model should look towards -Z.
+ var roll = 0.0 is writable
# Scale applied to the model
var scale = 1.0 is writable
# 3D model composed of `Mesh` and `Material`, loaded from the assets folder by default
#
-# Instances can be created at any time and must be loaded after or at the end of `on_create`.
+# Instances can be created at any time and must be loaded after or at the end of `create_scene`.
# If loading fails, the model is replaced by `placeholder_model`.
#
# ~~~
# Load this model in memory
fun load do end
+ # Errors raised at loading
+ var errors = new Array[Error]
+
# All `LeafModel` composing this model
#
# Usually, there is one `LeafModel` per material.
# At each frame, each material is asked to draw all the live `LeafModel` instaces.
fun leaves: Array[LeafModel] is abstract
+
+ # Sub-models with names, usually declared in the asset file
+ var named_parts = new Map[Text, Model]
end
# Model composed of one or many other `LeafModel`
# This method is called on many materials for many `actor` and `model` at each frame.
# It is expected to use a `GLProgram` and call an equivalent to `glDrawArrays`.
# However, it should not call `glClear` nor `GamnitDisplay::flip`.
- fun draw(actor: Actor, model: LeafModel) do end
+ fun draw(actor: Actor, model: LeafModel, camera: Camera) do end
end
# Mesh with all geometry data
end
# Source of light
-#
-# Instances of this class define a light source position and type.
-class Light
-
- # TODO point light, spotlight, directional light, etc.
+abstract class Light
# Center of this light source in world coordinates
var position = new Point3d[Float](0.0, 1000.0, 0.0)
end
+# Basic light projected from a single point
+class PointLight
+ super Light
+end
+
+# Source of light casting shadows
+abstract class LightCastingShadows
+ super Light
+
+ # View from the camera, used for shadow mapping, implemented by sub-classes
+ fun camera: Camera is abstract
+end
+
redef class App
# Live actors to be drawn on screen
var actors = new Array[Actor]
# Single light of the scene
- var light = new Light
+ var light: Light = new PointLight is writable
# TODO move `actors & light` to a scene object
# TODO support more than 1 light