Procházet zdrojové kódy

Updated camera example to use Orthographic Projection

Björn Ritzl před 1 rokem
rodič
revize
dd8ee1c413

+ 5 - 5
examples/render/camera/camera.collection

@@ -401,10 +401,10 @@ embedded_instances {
   "  type: \"camera\"\n"
   "  data: \"aspect_ratio: 1.0\\n"
   "fov: 45.0\\n"
-  "near_z: 0.1\\n"
-  "far_z: 1000.0\\n"
+  "near_z: -10.0\\n"
+  "far_z: 10.0\\n"
   "auto_aspect_ratio: 0\\n"
-  "orthographic_projection: 0\\n"
+  "orthographic_projection: 1\\n"
   "orthographic_zoom: 1.0\\n"
   "\"\n"
   "  position {\n"
@@ -421,8 +421,8 @@ embedded_instances {
   "}\n"
   ""
   position {
-    x: -360.0
-    y: -360.0
+    x: 0.0
+    y: 0.0
     z: 0.0
   }
   rotation {

+ 1 - 1
examples/render/camera/camera.md

@@ -15,5 +15,5 @@ bee
 
 camera
 : The camera. Contains:
-  - A *Camera* component.
+  - A *Camera* component. The camera component has Orthographic Projection enabled.
   - A script that controls the camera component.

+ 7 - 8
examples/render/camera/camera.script

@@ -1,11 +1,11 @@
 function init(self)
 	msg.post("#camera", "acquire_camera_focus") -- <1>
+	msg.post("@render:", "use_camera_projection") -- <2>
 end
 
 function on_message(self, message_id, message, sender)
-	if message_id == hash("follow") then -- <2>
-		go.set_parent(".", sender) -- <3>
-		go.set_position(vmath.vector3(-360, -360, 0)) -- <4>
+	if message_id == hash("follow") then -- <3>
+		go.set_parent(".", sender) -- <4>
 	elseif message_id == hash("unfollow") then -- <5>
 		go.set_parent("camera", nil, true)
 	end
@@ -13,9 +13,8 @@ end
 
 --[[
 1. Acquire camera focus for the camera component. When a camera has focus it will send view and projection updates to the render script.
-2. Start following the game object that sent the `follow` message.
-3. This is done by parenting the camera component to the game object that sent the message.
-4. Offset the camera so that it is centering on the game object (360 is half the screen width and height).
-5. Stop following any game object.
-5. This is done removing the parent game object while maintaining the current world transform.
+2. Tell the render script to use the view and projection provided by the camera.
+3. Start following the game object that sent the `follow` message.
+4. This is done by parenting the camera component to the game object that sent the message.
+5. Stop following any game object. This is done removing the parent game object while maintaining the current world transform.
 --]]