Просмотр исходного кода

Add basic orthographic editor camera support

Daniele Bartolini 8 лет назад
Родитель
Сommit
4e8a2899d5

+ 60 - 35
samples/core/editors/level_editor/camera.lua

@@ -7,6 +7,7 @@ function FPSCamera:init(world, unit)
 	self._unit = unit
 	self._translation_speed = 47
 	self._rotation_speed = 0.38
+	self._perspective_local_pose = Matrix4x4Box(Matrix4x4.identity())
 end
 
 function FPSCamera:unit()
@@ -17,23 +18,13 @@ function FPSCamera:camera()
 	return World.camera_instances(self._world, self._unit)
 end
 
-function FPSCamera:position()
+function FPSCamera:local_pose()
 	local sg = World.scene_graph(self._world)
-	local camera_position = SceneGraph.world_position(sg, self._unit)
-	return camera_position
+	return SceneGraph.local_pose(sg, self._unit)
 end
 
-function FPSCamera:world_pose()
-	local sg = World.scene_graph(self._world)
-	return SceneGraph.world_pose(sg, self._unit)
-end
-
-function FPSCamera:set_translation_speed(speed)
-	self._translation_speed = speed
-end
-
-function FPSCamera:set_rotation_speed(speed)
-	self._rotation_speed = speed
+function FPSCamera:is_orthographic()
+	return World.camera_projection_type(self._world, self._unit) == "orthographic"
 end
 
 function FPSCamera:mouse_wheel(delta)
@@ -43,12 +34,36 @@ end
 function FPSCamera:camera_ray(x, y)
 	local near = World.camera_screen_to_world(self._world, self._unit, Vector3(x, y, 0))
 	local far = World.camera_screen_to_world(self._world, self._unit, Vector3(x, y, 1))
-	local dir = Vector3.normalize(far - near)
-	return self:position(), dir
+	local dir = World.camera_projection_type(self._world, self._unit) == "orthographic"
+		and Matrix4x4.z(self:local_pose())
+		or Vector3.normalize(far - near)
+	return near, dir
+end
+
+function FPSCamera:set_perspective()
+	if not self:is_orthographic() then
+		return
+	end
+
+	local sg = World.scene_graph(self._world)
+	SceneGraph.set_local_pose(sg, self._unit, self._perspective_local_pose:unbox())
+	World.camera_set_projection_type(self._world, self._unit, "perspective")
+end
+
+function FPSCamera:set_orthographic(world_center, world_radius, dir, up)
+	if not self:is_orthographic() then
+		self._perspective_local_pose:store(self:local_pose())
+	end
+
+	local sg = World.scene_graph(self._world)
+	SceneGraph.set_local_rotation(sg, self._unit, Quaternion.look(dir, up))
+	SceneGraph.set_local_position(sg, self._unit, world_center - dir * Vector3.dot(dir, world_radius))
+	World.camera_set_orthographic_size(self._world, self._unit, 10)
+	World.camera_set_projection_type(self._world, self._unit, "orthographic")
 end
 
 function FPSCamera:screen_length_to_world_length(position, length)
-	local right = Matrix4x4.x(self:world_pose())
+	local right = Matrix4x4.x(self:local_pose())
 	local a = World.camera_world_to_screen(self._world, self._unit, position)
 	local b = World.camera_world_to_screen(self._world, self._unit, position + right)
 	return length / Vector3.distance(a, b)
@@ -59,32 +74,42 @@ function FPSCamera:update(dt, dx, dy, keyboard)
 
 	local camera_local_pose = SceneGraph.local_pose(sg, self._unit)
 	local camera_right_vector = Matrix4x4.x(camera_local_pose)
+	local camera_up_vector = Matrix4x4.y(camera_local_pose)
+	local camera_view_vector = Matrix4x4.z(camera_local_pose)
 	local camera_position = Matrix4x4.translation(camera_local_pose)
 	local camera_rotation = Matrix4x4.rotation(camera_local_pose)
-	local view_dir = Matrix4x4.z(camera_local_pose)
 
+	-- Rotation
 	if dx ~= 0 or dy ~= 0 then
-		-- Rotation
-		local rotation_speed = self._rotation_speed * dt
-		local rotation_around_world_up = Quaternion(Vector3(0, 1, 0), -dx * rotation_speed)
-		local rotation_around_camera_right = Quaternion(camera_right_vector, -dy * rotation_speed)
-		local rotation = Quaternion.multiply(rotation_around_world_up, rotation_around_camera_right)
-
-		local old_rotation = Matrix4x4.from_quaternion(camera_rotation)
-		local delta_rotation = Matrix4x4.from_quaternion(rotation)
-		local new_rotation = Matrix4x4.multiply(old_rotation, delta_rotation)
-		Matrix4x4.set_translation(new_rotation, camera_position)
-
-		-- Fixme
-		SceneGraph.set_local_pose(sg, self._unit, new_rotation)
+		if not self:is_orthographic() then
+			local rotation_speed = self._rotation_speed * dt
+			local rotation_around_world_up = Quaternion(Vector3(0, 1, 0), -dx * rotation_speed)
+			local rotation_around_camera_right = Quaternion(camera_right_vector, -dy * rotation_speed)
+			local rotation = Quaternion.multiply(rotation_around_world_up, rotation_around_camera_right)
+
+			local old_rotation = Matrix4x4.from_quaternion(camera_rotation)
+			local delta_rotation = Matrix4x4.from_quaternion(rotation)
+			local new_rotation = Matrix4x4.multiply(old_rotation, delta_rotation)
+			Matrix4x4.set_translation(new_rotation, camera_position)
+
+			-- Fixme
+			SceneGraph.set_local_pose(sg, self._unit, new_rotation)
+		end
 	end
 
 	-- Translation
 	local translation_speed = self._translation_speed * dt
-	if keyboard.wkey then camera_position = camera_position + view_dir * translation_speed end
-	if keyboard.skey then camera_position = camera_position + view_dir * -1 * translation_speed end
-	if keyboard.akey then camera_position = camera_position + camera_right_vector * -1 * translation_speed end
-	if keyboard.dkey then camera_position = camera_position + camera_right_vector * translation_speed end
 
+	if self:is_orthographic() then
+		if keyboard.wkey then camera_position = camera_position + camera_up_vector * translation_speed end
+		if keyboard.skey then camera_position = camera_position + camera_up_vector * -translation_speed end
+		if keyboard.akey then camera_position = camera_position + camera_right_vector * -translation_speed end
+		if keyboard.dkey then camera_position = camera_position + camera_right_vector * translation_speed end
+	else
+		if keyboard.wkey then camera_position = camera_position + camera_view_vector * translation_speed end
+		if keyboard.skey then camera_position = camera_position + camera_view_vector * -translation_speed end
+		if keyboard.akey then camera_position = camera_position + camera_right_vector * -translation_speed end
+		if keyboard.dkey then camera_position = camera_position + camera_right_vector * translation_speed end
+	end
 	SceneGraph.set_local_position(sg, self._unit, camera_position)
 end

+ 28 - 0
samples/core/editors/level_editor/level_editor.lua

@@ -1581,3 +1581,31 @@ function LevelEditor:destroy(id)
 	self._selection:remove(id)
 	self._selection:send()
 end
+
+function LevelEditor:camera_view_perspective()
+	self._fpscamera:set_perspective()
+end
+
+function LevelEditor:camera_view_front()
+	self._fpscamera:set_orthographic(Vector3(0, 0, 0), Vector3(1, 1, 1), Vector3(0, 0, 1), Vector3(0, 1, 0))
+end
+
+function LevelEditor:camera_view_back()
+	self._fpscamera:set_orthographic(Vector3(0, 0, 0), Vector3(1, 1, 1), Vector3(0, 0, -1), Vector3(0, 1, 0))
+end
+
+function LevelEditor:camera_view_right()
+	self._fpscamera:set_orthographic(Vector3(0, 0, 0), Vector3(1, 1, 1), Vector3(-1, 0, 0), Vector3(0, 1, 0))
+end
+
+function LevelEditor:camera_view_left()
+	self._fpscamera:set_orthographic(Vector3(0, 0, 0), Vector3(1, 1, 1), Vector3(1, 0, 0), Vector3(0, 1, 0))
+end
+
+function LevelEditor:camera_view_top()
+	self._fpscamera:set_orthographic(Vector3(0, 0, 0), Vector3(1, 1, 1), Vector3(0, -1, 0), Vector3(0, 0, 1))
+end
+
+function LevelEditor:camera_view_bottom()
+	self._fpscamera:set_orthographic(Vector3(0, 0, 0), Vector3(1, 1, 1), Vector3(0, 1, 0), Vector3(0, 0, 1))
+end

+ 83 - 83
tools/gresources.c

@@ -2319,89 +2319,89 @@ static const SECTION union { const guint8 data[43484]; const double alignment; v
   0x2f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
   0x6c, 0x65, 0x76, 0x65, 0x6c, 0x5f, 0x65, 0x64, 
   0x69, 0x74, 0x6f, 0x72, 0x2e, 0x78, 0x6d, 0x6c, 
-  0x2a, 0x0b, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
-  0x78, 0xda, 0x8d, 0x56, 0xdb, 0x72, 0xe3, 0x20, 
-  0x0c, 0x7d, 0xef, 0x57, 0x64, 0x78, 0xa7, 0x49, 
-  0x76, 0x37, 0x33, 0xdd, 0x99, 0x24, 0x7d, 0xdb, 
-  0x2f, 0x68, 0x3f, 0x00, 0x63, 0xd5, 0x66, 0x06, 
-  0x83, 0xcb, 0x25, 0x69, 0xfe, 0x7e, 0xc1, 0x76, 
-  0x9b, 0x8b, 0x05, 0xe6, 0xcd, 0x70, 0x8e, 0x25, 
-  0x21, 0x21, 0x1d, 0xf6, 0xaf, 0x5f, 0x9d, 0x5c, 
-  0x9d, 0xc0, 0x58, 0xa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0xe5, 0x41, 0xf2, 
-  0x0c, 0x43, 0xad, 0x48, 0xd1, 0xb4, 0x0e, 0x9f, 
-  0x24, 0x51, 0x19, 0xa2, 0x3e, 0x18, 0x0e, 0xd9, 
-  0x6b, 0x79, 0x12, 0x41, 0x17, 0xd1, 0x89, 0x31, 
-  0xfe, 0x4c, 0x2b, 0xa3, 0xcf, 0x76, 0x3c, 0x45, 
-  0x7e, 0x2c, 0x43, 0xe5, 0x9b, 0x30, 0xde, 0xe2, 
-  0x91, 0xaf, 0xe3, 0x25, 0x41, 0xeb, 0xdb, 0x8b, 
-  0x15, 0xdc, 0x5e, 0x79, 0x69, 0x0d, 0x51, 0x8d, 
-  0x50, 0x90, 0x88, 0xd0, 0x31, 0xe3, 0x0a, 0xc6, 
-  0xa4, 0xd4, 0xac, 0xa6, 0xd2, 0xb3, 0x7c, 0x7f, 
-  0x7a, 0x85, 0x79, 0x09, 0x1a, 0xed, 0xa8, 0x84, 
-  0x13, 0x24, 0x06, 0xab, 0x57, 0xb4, 0x09, 0x05, 
-  0xca, 0x9a, 0x6e, 0x41, 0xa2, 0x1d, 0xdf, 0x31, 
-  0xe5, 0x93, 0x03, 0x7b, 0x90, 0x6f, 0x61, 0xad, 
-  0x5f, 0x16, 0x82, 0xf8, 0x84, 0xa1, 0x92, 0xc5, 
-  0x40, 0x75, 0xb3, 0xc8, 0x66, 0x95, 0xf6, 0xee, 
-  0xb1, 0xdd, 0xc2, 0x6b, 0xea, 0xb8, 0x77, 0x5a, 
-  0xcb, 0xeb, 0x23, 0x6b, 0x5a, 0x91, 0x71, 0x1f, 
-  0x57, 0xcf, 0x19, 0xf2, 0xad, 0x9e, 0x33, 0xe0, 
-  0xaa, 0x9e, 0x33, 0x08, 0x55, 0xcf, 0x39, 0xeb, 
-  0x51, 0x3d, 0x71, 0x46, 0x4a, 0x3d, 0xe7, 0x01, 
-  0x25, 0xd5, 0x73, 0x99, 0x8a, 0xaa, 0x27, 0x1e, 
-  0x4f, 0x42, 0x3d, 0x67, 0xe4, 0xfb, 0x7b, 0xb6, 
-  0x9e, 0x92, 0x1f, 0xbe, 0xc2, 0xeb, 0xf7, 0xe9, 
-  0x3f, 0xfa, 0xf3, 0x02, 0xc5, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+  0x65, 0x0c, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
+  0x78, 0xda, 0x8d, 0x97, 0xcd, 0x92, 0xdb, 0x20, 
+  0x0c, 0xc7, 0xef, 0xfb, 0x14, 0x19, 0xee, 0x6c, 
+  0x92, 0xb6, 0x99, 0xd9, 0xce, 0x24, 0xd9, 0x5b, 
+  0x9f, 0xa0, 0x7d, 0x00, 0x8c, 0x15, 0x87, 0x29, 
+  0x46, 0x94, 0x8f, 0x64, 0xf3, 0xf6, 0x05, 0xdb, 
+  0xd9, 0x38, 0x6b, 0xc0, 0xbe, 0x05, 0xfe, 0x3f, 
+  0x0b, 0x21, 0x04, 0x52, 0xf6, 0xef, 0x1f, 0xad, 
+  0x5c, 0x5d, 0xc0, 0x58, 0x81, 0xea, 0x40, 0xb6, 
+  0xaf, 0x1b, 0xb2, 0x02, 0xc5, 0xb1, 0x16, 0xaa, 
+  0x39, 0x90, 0x3f, 0xbf, 0x7f, 0xd1, 0x37, 0xf2, 
+  0x7e, 0x7c, 0xd9, 0x7b, 0x71, 0xdc, 0xb7, 0xa0, 
+  0x7c, 0xc5, 0xcc, 0x4a,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, 0x4c, 0xa9, 0xaf, 0x8d, 0x47, 0x9a, 0xc8, 
+  0x35, 0x1e, 0x53, 0x87, 0xb2, 0x8d, 0xc7, 0x3c, 
+  0x9a, 0x6c, 0x3c, 0xd2, 0xfe, 0x64, 0x1a, 0x8f, 
+  0x09, 0xfc, 0x9c, 0x67, 0xeb, 0x21, 0xf8, 0xe1, 
+  0x57, 0xf8, 0xe3, 0xf0, 0xf2, 0x1f, 0x39, 0x4b, 
+  0x74, 0xf1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 

+ 87 - 44
tools/level_editor/level_editor.vala

@@ -95,50 +95,58 @@ namespace Crown
 
 		const Gtk.ActionEntry[] action_entries =
 		{
-			{ "menu-file",            null,  "_File",              null,             null,         null                   },
-			{ "new",                  null,  "New",                "<ctrl>N",        null,         on_new                 },
-			{ "open",                 null,  "Open...",            "<ctrl>O",        null,         on_open                },
-			{ "save",                 null,  "Save",               "<ctrl>S",        null,         on_save                },
-			{ "save-as",              null,  "Save As...",         "<shift><ctrl>S", null,         on_save_as             },
-			{ "import",               null,  "Import",             null,             null,         null                   },
-			{ "import-sprites",       null,  "Sprites...",         null,             null,         on_import_sprites      },
-			{ "import-meshes",        null,  "Meshes...",          null,             null,         on_import_meshes       },
-			{ "import-sounds",        null,  "Sounds...",          null,             null,         on_import_sounds       },
-			{ "import-textures",      null,  "Textures...",        null,             null,         on_import_textures     },
-			{ "preferences",          null,  "Preferences",        null,             null,         on_preferences         },
-			{ "quit",                 null,  "Quit",               "<ctrl>Q",        null,         on_quit                },
-			{ "menu-edit",            null,  "_Edit",              null,             null,         null                   },
-			{ "undo",                 null,  "Undo",               "<ctrl>Z",        null,         on_undo                },
-			{ "redo",                 null,  "Redo",               "<shift><ctrl>Z", null,         on_redo                },
-			{ "duplicate",            null,  "Duplicate",          "<ctrl>D",        null,         on_duplicate           },
-			{ "delete",               null,  "Delete",             "<ctrl>K",        null,         on_delete              },
-			{ "menu-grid",            null,  "Grid",               null,             null,         null                   },
-			{ "grid-custom",          null,  "Custom",             "<ctrl>G",        null,         on_custom_grid	      },
-			{ "menu-rotation-snap",   null,  "Rotation Snap",      null,             null,         null                   },
-			{ "rotation-snap-custom", null,  "Custom",             "<ctrl>H",        null,         on_rotation_snap       },
-			{ "menu-create",          null,  "Create",             null,             null,         null                   },
-			{ "menu-primitives",      null,  "Primitives",         null,             null,         null                   },
-			{ "primitive-cube",       null,  "Cube",               null,             null,         on_create_cube         },
-			{ "primitive-sphere",     null,  "Sphere",             null,             null,         on_create_sphere       },
-			{ "primitive-cone",       null,  "Cone",               null,             null,         on_create_cone         },
-			{ "primitive-cylinder",   null,  "Cylinder",           null,             null,         on_create_cylinder     },
-			{ "primitive-plane",      null,  "Plane",              null,             null,         on_create_plane        },
-			{ "camera",               null,  "Camera",             null,             null,         on_create_camera       },
-			{ "light",                null,  "Light",              null,             null,         on_create_light        },
-			{ "sound-source",         null,  "Sound Source",       null,             null,         on_create_sound_source },
-			{ "menu-engine",          null,  "En_gine",            null,             null,         null                   },
-			{ "menu-view",            null,  "View",               null,             null,         null                   },
-			{ "resource-browser",     null,  "Resource Browser",   "<ctrl>P",        null,         on_resource_browser    },
-			{ "restart",              null,  "_Restart",           null,             null,         on_engine_restart      },
-			{ "reload-lua",           null,  "Reload Lua",         "F7",             null,         on_reload_lua          },
-			{ "menu-run",             null,  "_Run",               null,             null,         null                   },
-			{ "test-level",           "run", "Test Level",         "F5",             "Test Level", on_test_level          },
-			{ "run-game",             null,  "Run Game",           null,             null,         on_run_game            },
-			{ "menu-help",            null,  "Help",               null,             null,         null                   },
-			{ "manual",               null,  "Manual",             "F1",             null,         on_manual              },
-			{ "report-issue",         null,  "Report an Issue",    null,             null,         on_report_issue        },
-			{ "open-last-log",        null,  "Open last.log",      null,             null,         on_open_last_log       },
-			{ "about",                null,  "About",              null,             null,         on_about               }
+			{ "menu-file",            null,  "_File",              null,             null,         null                       },
+			{ "new",                  null,  "New",                "<ctrl>N",        null,         on_new                     },
+			{ "open",                 null,  "Open...",            "<ctrl>O",        null,         on_open                    },
+			{ "save",                 null,  "Save",               "<ctrl>S",        null,         on_save                    },
+			{ "save-as",              null,  "Save As...",         "<shift><ctrl>S", null,         on_save_as                 },
+			{ "import",               null,  "Import",             null,             null,         null                       },
+			{ "import-sprites",       null,  "Sprites...",         null,             null,         on_import_sprites          },
+			{ "import-meshes",        null,  "Meshes...",          null,             null,         on_import_meshes           },
+			{ "import-sounds",        null,  "Sounds...",          null,             null,         on_import_sounds           },
+			{ "import-textures",      null,  "Textures...",        null,             null,         on_import_textures         },
+			{ "preferences",          null,  "Preferences",        null,             null,         on_preferences             },
+			{ "quit",                 null,  "Quit",               "<ctrl>Q",        null,         on_quit                    },
+			{ "menu-edit",            null,  "_Edit",              null,             null,         null                       },
+			{ "undo",                 null,  "Undo",               "<ctrl>Z",        null,         on_undo                    },
+			{ "redo",                 null,  "Redo",               "<shift><ctrl>Z", null,         on_redo                    },
+			{ "duplicate",            null,  "Duplicate",          "<ctrl>D",        null,         on_duplicate               },
+			{ "delete",               null,  "Delete",             "<ctrl>K",        null,         on_delete                  },
+			{ "menu-grid",            null,  "Grid",               null,             null,         null                       },
+			{ "grid-custom",          null,  "Custom",             "<ctrl>G",        null,         on_custom_grid	          },
+			{ "menu-rotation-snap",   null,  "Rotation Snap",      null,             null,         null                       },
+			{ "rotation-snap-custom", null,  "Custom",             "<ctrl>H",        null,         on_rotation_snap           },
+			{ "menu-create",          null,  "Create",             null,             null,         null                       },
+			{ "menu-primitives",      null,  "Primitives",         null,             null,         null                       },
+			{ "primitive-cube",       null,  "Cube",               null,             null,         on_create_cube             },
+			{ "primitive-sphere",     null,  "Sphere",             null,             null,         on_create_sphere           },
+			{ "primitive-cone",       null,  "Cone",               null,             null,         on_create_cone             },
+			{ "primitive-cylinder",   null,  "Cylinder",           null,             null,         on_create_cylinder         },
+			{ "primitive-plane",      null,  "Plane",              null,             null,         on_create_plane            },
+			{ "camera",               null,  "Camera",             null,             null,         on_create_camera           },
+			{ "light",                null,  "Light",              null,             null,         on_create_light            },
+			{ "sound-source",         null,  "Sound Source",       null,             null,         on_create_sound_source     },
+			{ "menu-camera",          null,  "Camera",             null,             null,         null                       },
+			{ "camera-view-perspective", null,  "Perspective",     "KP_5",           null,         on_camera_view_perspective },
+			{ "camera-view-front",    null,  "View Front",         "KP_1",           null,         on_camera_view_front       },
+			{ "camera-view-back",     null,  "View Back",          "<ctrl>KP_1",     null,         on_camera_view_back        },
+			{ "camera-view-right",    null,  "View Right",         "KP_3",           null,         on_camera_view_right       },
+			{ "camera-view-left",     null,  "View Left",          "<ctrl>KP_3",     null,         on_camera_view_left        },
+			{ "camera-view-top",      null,  "View Top",           "KP_7",           null,         on_camera_view_top         },
+			{ "camera-view-bottom",   null,  "View Bottom",        "<ctrl>KP_7",     null,         on_camera_view_bottom      },
+			{ "menu-engine",          null,  "En_gine",            null,             null,         null                       },
+			{ "menu-view",            null,  "View",               null,             null,         null                       },
+			{ "resource-browser",     null,  "Resource Browser",   "<ctrl>P",        null,         on_resource_browser        },
+			{ "restart",              null,  "_Restart",           null,             null,         on_engine_restart          },
+			{ "reload-lua",           null,  "Reload Lua",         "F7",             null,         on_reload_lua              },
+			{ "menu-run",             null,  "_Run",               null,             null,         null                       },
+			{ "test-level",           "run", "Test Level",         "F5",             "Test Level", on_test_level              },
+			{ "run-game",             null,  "Run Game",           null,             null,         on_run_game                },
+			{ "menu-help",            null,  "Help",               null,             null,         null                       },
+			{ "manual",               null,  "Manual",             "F1",             null,         on_manual                  },
+			{ "report-issue",         null,  "Report an Issue",    null,             null,         on_report_issue            },
+			{ "open-last-log",        null,  "Open last.log",      null,             null,         on_open_last_log           },
+			{ "about",                null,  "About",              null,             null,         on_about                   }
 		};
 
 		const Gtk.RadioActionEntry[] grid_entries =
@@ -1207,6 +1215,41 @@ namespace Crown
 			_action_group.get_action("place").activate();
 		}
 
+		private void on_camera_view_perspective(Gtk.Action action)
+		{
+			_engine.send_script("LevelEditor:camera_view_perspective()");
+		}
+
+		private void on_camera_view_front(Gtk.Action action)
+		{
+			_engine.send_script("LevelEditor:camera_view_front()");
+		}
+
+		private void on_camera_view_back(Gtk.Action action)
+		{
+			_engine.send_script("LevelEditor:camera_view_back()");
+		}
+
+		private void on_camera_view_right(Gtk.Action action)
+		{
+			_engine.send_script("LevelEditor:camera_view_right()");
+		}
+
+		private void on_camera_view_left(Gtk.Action action)
+		{
+			_engine.send_script("LevelEditor:camera_view_left()");
+		}
+
+		private void on_camera_view_top(Gtk.Action action)
+		{
+			_engine.send_script("LevelEditor:camera_view_top()");
+		}
+
+		private void on_camera_view_bottom(Gtk.Action action)
+		{
+			_engine.send_script("LevelEditor:camera_view_bottom()");
+		}
+
 		private void on_resource_browser(Gtk.Action action)
 		{
 			_resource_browser.show_all();

+ 10 - 0
tools/level_editor/level_editor.xml

@@ -73,6 +73,16 @@
 			<menuitem action="light"></menuitem>
 			<menuitem action="sound-source"></menuitem>
 		</menu>
+		<menu action="menu-camera">
+			<menuitem action="camera-view-perspective"></menuitem>
+			<separator></separator>
+			<menuitem action="camera-view-front"></menuitem>
+			<menuitem action="camera-view-back"></menuitem>
+			<menuitem action="camera-view-right"></menuitem>
+			<menuitem action="camera-view-left"></menuitem>
+			<menuitem action="camera-view-top"></menuitem>
+			<menuitem action="camera-view-bottom"></menuitem>
+		</menu>
 		<menu action="menu-view">
 			<menuitem action="resource-browser"></menuitem>
 			<separator></separator>