Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions docs/en/manuals/camera.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ Orthographic Projection
Orthographic Zoom
: (**Orthographic camera only**) - The zoom used for the orthographic projection (> 1 = zoom in, < 1 = zoom out).

Orthographic Mode
: (**Orthographic camera only**) - Controls how the orthographic camera determines zoom relative to the window size and your design resolution (the values in `game.project` → `display.width/height`).
- `Fixed` (uses constant zoom): Uses the current `Orthographic Zoom` value as-is.
- `Auto Fit` (contain): Automatically adjusts zoom so the full design area fits inside the window. May show extra content on sides or top/bottom.
- `Auto Cover` (cover): Automatically adjusts zoom so the design area covers the entire window. May crop on sides or top/bottom.
Available only when `Orthographic Projection` is enabled.


## Using the camera

Expand Down Expand Up @@ -83,9 +90,11 @@ The scripting `camera` module has multiple functions that can be used to manipul
camera.get_aspect_ratio(camera) -- get aspect ratio
camera.get_far_z(camera) -- get far z
camera.get_fov(camera) -- get field of view
camera.get_orthographic_mode(camera) -- get orthographic mode (one of camera.ORTHO_MODE_*)
camera.set_aspect_ratio(camera, ratio) -- set aspect ratio
camera.set_far_z(camera, far_z) -- set far z
camera.set_near_z(camera, near_z) -- set near z
camera.set_orthographic_mode(camera, camera.ORTHO_MODE_AUTO_FIT) -- set orthographic mode
... And so forth
```

Expand Down Expand Up @@ -125,7 +134,7 @@ The view matrix provided by the camera defines the position and orientation of t

### Render script

Starting with Defold 1.9.6, when using the default render script Defold will automatically set the last enabled camera that should be used for rendering. Before this change, a script somewhere in the project needed to explicitly send the `use_camera_projection` message to the renderer to notify it that the view and projection from camera components should be used. This is no longer necessary, but it is still possible to do so for backwards compatibility purposes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change was a long time ago, so it's not necessary to mention version anymore

When using the default render script Defold will automatically set the last enabled camera that should be used for rendering. Before this change, a script somewhere in the project needed to explicitly send the `use_camera_projection` message to the renderer to notify it that the view and projection from camera components should be used. This is no longer necessary, but it is still possible to do so for backwards compatibility purposes.

Alternatively, you can set a specific camera that should be used for rendering in a render script. This could be useful in cases where you need to control more specifically which camera should be used for rendering, for example in a multiplayer game.

Expand Down Expand Up @@ -163,6 +172,22 @@ You can zoom in and out when using an orthographic camera by changing the *Ortho
go.set("#camera", "orthographic_zoom", 2)
```

When using an orthographic camera you can also switch how zoom is determined using the `Orthographic Mode` setting or via script:

```lua
-- get current mode (one of camera.ORTHO_MODE_FIXED, _AUTO_FIT, _AUTO_COVER)
local mode = camera.get_orthographic_mode("#camera")

-- switch to auto-fit (contain) to always keep the full design area visible
camera.set_orthographic_mode("#camera", camera.ORTHO_MODE_AUTO_FIT)

-- switch to auto-cover to ensure the design area covers the window
camera.set_orthographic_mode("#camera", camera.ORTHO_MODE_AUTO_COVER)

-- switch back to fixed mode to control zoom manually via orthographic_zoom
camera.set_orthographic_mode("#camera", camera.ORTHO_MODE_FIXED)
```

### Adaptive zoom

The concept behind adaptive zoom is to adjust the camera zoom value when the resolution of the display change from the initial resolution set in *game.project*.
Expand Down Expand Up @@ -202,6 +227,8 @@ end

A complete example of adaptive zoom can be seen in [this sample project](https://github.com/defold/sample-adaptive-zoom).

Note: With an orthographic camera you can now achieve contain/cover behavior without custom code by setting `Orthographic Mode` to `Auto Fit` (contain) or `Auto Cover` (cover). In these modes the effective zoom is computed automatically based on window size and your design resolution.


### Following a game object

Expand Down Expand Up @@ -264,13 +291,13 @@ A camera has a number of different properties that can be manipulated using `go.
: The orthographic camera zoom (`number`).

`aspect_ratio`
: Added in Defold 1.4.8. The ratio between the frustum width and height. Used when calculating the projection of a perspective camera. (`number`).
: The ratio between the frustum width and height. Used when calculating the projection of a perspective camera. (`number`).

`view`
: Added in Defold 1.4.8. The calculated view matrix of the camera. READ ONLY. (`matrix4`).
: The calculated view matrix of the camera. READ ONLY. (`matrix4`).

`projection`
: Added in Defold 1.4.8. The calculated projection matrix of the camera. READ ONLY. (`matrix4`).
: The calculated projection matrix of the camera. READ ONLY. (`matrix4`).


## Third-party camera solutions
Expand Down
10 changes: 8 additions & 2 deletions docs/en/manuals/debugging-game-and-system-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The game log shows all of the output from the engine, native extensions and your
System logs are generated by the operating system and it can provide additional information that can help you pinpoint a problem. The system logs can contain stack traces for crashes and low memory warnings.

::: important
The game log will only show information in debug builds. The log will be completely empty in release builds.
Console/on-screen logging only shows information in Debug builds. In Release builds the console log is empty, but you can enable file logging in Release by setting the project setting "Write Log File" to "Always". See details below.
:::

## Reading the game log from the editor
Expand Down Expand Up @@ -87,7 +87,13 @@ This will install the app on your device, start it and automatically attach a LL

## Reading the game log from the log file

If you enable the *Write Log* setting in *game.project*, any game output will be written to disk, to a file called "`log.txt`". Here is how you extract the file if you run the game on device:
Use the project setting "Write Log File" in *game.project* to control file logging:

- "Never": Do not write a log file.
- "Debug": Write a log file only for Debug builds.
- "Always": Write a log file for both Debug and Release builds.

When enabled, any game output will be written to disk to a file named "`log.txt`". Here is how you extract the file if you run the game on device:

iOS
: Connect your device to a computer with macOS and Xcode installed.
Expand Down
Binary file removed docs/en/manuals/images/camera/camera_id.png
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never used image

Binary file not shown.
Binary file modified docs/en/manuals/images/camera/create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/en/manuals/images/camera/create@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions docs/en/manuals/project-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ Publisher name.
#### Developer
Developer name.

#### Write Log
When checked, the engine will write a log file. If running more than one instance from the editor the file will be named *instance_2_log.txt* with `2` being the instance index. If running a single instance or from a bundle the file will be named *log.txt* The location of the log file will be one of the following paths (tried in order):
#### Write Log File
Controls when the engine writes a log file. Options:

- "Never": Do not write a log file.
- "Debug": Write a log file only for Debug builds.
- "Always": Write a log file for both Debug and Release builds.

If running more than one instance from the editor the file will be named *instance_2_log.txt* with `2` being the instance index. If running a single instance or from a bundle the file will be named *log.txt*. The location of the log file will be one of the following paths (tried in order):

1. The path specified in *project.log_dir* (hidden setting)
2. The system log path:
Expand Down
14 changes: 14 additions & 0 deletions docs/en/manuals/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ msg.post("@render:", "use_fixed_projection", { near = -1, far = 1, zoom = 2 })

When using the default render script and there are enabled [Camera components](/manuals/camera) available in the project, they will take precedence over any other view / projections set in the render script. To read more about how to work with camera components in render scripts, please consult the [Camera documentation](/manuals/camera).

Orthographic cameras support an `Orthographic Mode` that controls how the camera adapts to the window:
- `Fixed` uses the camera’s `Orthographic Zoom` value.
- `Auto Fit` (contain) keeps the full design area visible.
- `Auto Cover` (cover) fills the window and may crop.

You can switch modes in the Editor or at runtime via the Camera API:

```lua
-- Use auto-fit behavior with an orthographic camera
camera.set_orthographic_mode("main:/go#camera", camera.ORTHO_MODE_AUTO_FIT)
-- Query current mode
local mode = camera.get_orthographic_mode("main:/go#camera")
```

## Frustum culling

The render API in Defold lets developers perform something called frustum culling. When frustum culling is enabled any graphics that lies outside of a defined bounding box or frustum will be ignored. In a large game world where only a portion is visible at a time, frustum culling can dramatically reduce the amount of data that needs to be sent to the GPU for rendering, thus increasing performance and saving battery (on mobile devices). It is common to use the view and projection of the camera to create the bounding box. The default render script uses the view and projection (from the camera) to calculate a frustum.
Expand Down
25 changes: 19 additions & 6 deletions docs/pl/manuals/project-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,25 @@ Tytuł aplikacji
#### Version
Wersja aplikacji

#### Write Log
Kiedy opcja zapisu logów jest zaznaczona, silnik zapisze wszystkie logi do pliku *log.txt* w głównej lokalizacji Twojego projektu. Gdy uruchomisz grę na systemie iOS, plik można będzie otworzyć przez iTunes w zakładce *Apps* w sekcji *File Sharing*. W systemie Android natomiast, plik jest przechowywany w zewnętrznej lokalizacji aplikacji (ang. app's external storage). Podczas uruchamiania aplikacji deweloperskiej *dmengine*, możesz podejrzeć logi używając komendy:

```bash
$ adb shell cat /mnt/sdcard/Android/data/com.defold.dmengine/files/log.txt
```
#### Write Log File
Określa, kiedy silnik zapisuje log do pliku. Opcje:

- "Never": nie zapisuj pliku logu.
- "Debug": zapisuj plik logu tylko dla buildów Debug.
- "Always": zapisuj plik logu zarówno dla buildów Debug, jak i Release.

Jeśli uruchamiasz więcej niż jedną instancję z edytora, plik będzie nazwany *instance_2_log.txt*, gdzie `2` to indeks instancji. Jeśli uruchamiasz pojedynczą instancję lub paczkę, plik będzie nazwany *log.txt*. Lokalizacja pliku logu będzie jedną z poniższych (sprawdzane w tej kolejności):

1. Ścieżka określona w *project.log_dir* (ukryte ustawienie)
2. Systemowa ścieżka logów:
* macOS/iOS: `NSDocumentDirectory`
* Android: `Context.getExternalFilesDir()`
* Inne: katalog aplikacji
3. Ścieżka wsparcia aplikacji:
* macOS/iOS: `NSApplicationSupportDirectory`
* Windows: `CSIDL_APPDATA` (np. `C:\Users\<username>\AppData\Roaming`)
* Android: `Context.getFilesDir()`
* Linux: zmienna środowiskowa `HOME`

#### Compress Archive
Umożliwia kompresowanie archiwów podczas budowania paczki. Zauważ, że dotyczy to wszystkich platform oprócz systemu Android, gdzie plik apk zawiera od razy skompresowane dane.
Expand Down
33 changes: 30 additions & 3 deletions docs/ru/manuals/camera.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ Orthographic Projection
Orthographic Zoom
: (**Только для ортографической камеры**) — масштаб ортографической проекции (> 1 = приближение, < 1 = отдаление).

Orthographic Mode
: (**Только для ортографической камеры**) — управляет тем, как ортографическая камера определяет зум относительно размера окна и ваших значений дизайна (`game.project` → `display.width/height`).
- `Fixed` (постоянный зум): используется текущее значение `Orthographic Zoom`.
- `Auto Fit` (вписать): автоматически подбирает зум так, чтобы вся дизайн-область помещалась в окно. Возможен дополнительный контент по бокам/сверху/снизу.
- `Auto Cover` (заполнить): автоматически подбирает зум так, чтобы дизайн-область заполняла окно целиком. Возможна обрезка по бокам/сверху/снизу.
Доступно только при включённой `Orthographic Projection`.


## Использование камеры

Expand Down Expand Up @@ -83,9 +90,11 @@ render.set_camera()
camera.get_aspect_ratio(camera) -- получить соотношение сторон
camera.get_far_z(camera) -- получить дальнюю плоскость отсечения
camera.get_fov(camera) -- получить угол обзора
camera.get_orthographic_mode(camera) -- получить ортографический режим (одно из camera.ORTHO_MODE_*)
camera.set_aspect_ratio(camera, ratio) -- установить соотношение сторон
camera.set_far_z(camera, far_z) -- установить дальнюю плоскость отсечения
camera.set_near_z(camera, near_z) -- установить ближнюю плоскость отсечения
camera.set_orthographic_mode(camera, camera.ORTHO_MODE_AUTO_FIT) -- установить ортографический режим
... и другие
```

Expand Down Expand Up @@ -163,6 +172,22 @@ end
go.set("#camera", "orthographic_zoom", 2)
```

Также для ортографической камеры можно выбрать способ определения зума с помощью параметра `Orthographic Mode` или из кода:

```lua
-- текущий режим (одно из: camera.ORTHO_MODE_FIXED, _AUTO_FIT, _AUTO_COVER)
local mode = camera.get_orthographic_mode("#camera")

-- включить режим "вписать" (contain), чтобы дизайн-область всегда полностью помещалась в окно
camera.set_orthographic_mode("#camera", camera.ORTHO_MODE_AUTO_FIT)

-- включить режим "заполнить" (cover), чтобы окно всегда было заполнено
-- camera.set_orthographic_mode("#camera", camera.ORTHO_MODE_AUTO_COVER)

-- вернуть "фиксированный" режим и управлять масштабом вручную через orthographic_zoom
-- camera.set_orthographic_mode("#camera", camera.ORTHO_MODE_FIXED)
```

### Адаптивный зум

Адаптивный зум — это изменение значения зума камеры при изменении разрешения экрана относительно первоначального разрешения, заданного в *game.project*.
Expand Down Expand Up @@ -202,6 +227,8 @@ end

Полный пример адаптивного зума доступен в [этом примерном проекте](https://github.com/defold/sample-adaptive-zoom).

Примечание: Для ортографической камеры типичное поведение «вписать/заполнить» можно получить без пользовательского кода, установив `Orthographic Mode` в `Auto Fit` (вписать) или `Auto Cover` (заполнить). В этих режимах эффективный зум рассчитывается автоматически на основе размера окна и заданного разрешения дизайна.


### Следование за игровым объектом

Expand Down Expand Up @@ -264,13 +291,13 @@ end
: Масштаб ортографической камеры (`number`).

`aspect_ratio`
: Добавлено в Defold 1.4.8. Соотношение ширины и высоты усечённой пирамиды. Используется при вычислении проекции перспективной камеры. (`number`).
: Соотношение ширины и высоты усечённой пирамиды. Используется при вычислении проекции перспективной камеры. (`number`).

`view`
: Добавлено в Defold 1.4.8. Вычисленная матрица вида камеры. ТОЛЬКО ДЛЯ ЧТЕНИЯ. (`matrix4`).
: Вычисленная матрица вида камеры. ТОЛЬКО ДЛЯ ЧТЕНИЯ. (`matrix4`).

`projection`
: Добавлено в Defold 1.4.8. Вычисленная матрица проекции камеры. ТОЛЬКО ДЛЯ ЧТЕНИЯ. (`matrix4`).
: Вычисленная матрица проекции камеры. ТОЛЬКО ДЛЯ ЧТЕНИЯ. (`matrix4`).


## Сторонние решения для камеры
Expand Down
10 changes: 8 additions & 2 deletions docs/ru/manuals/debugging-game-and-system-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ brief: В этом руководстве объясняется, как чит
Системные логи создаются операционной системой и могут содержать дополнительную информацию, которая может помочь вам выявить проблему. Системные логи могут содержать трассировки стека для сбоев и предупреждений о нехватке памяти.

::: important
В логе игры будет отображаться информация только в отладочных сборках. В сборках релизов лог будет полностью пустым.
Вывод в консоль/на экран показывается только в Debug-сборках. В Release-сборках консольный лог пуст, но вы можете включить запись лога в файл для Release, установив в настройках проекта параметр "Write Log File" в значение "Always". Подробнее см. ниже.
:::

## Чтение лога игры из редактора
Expand Down Expand Up @@ -87,7 +87,13 @@ $ ios-deploy --debug --bundle <path_to_game.app> # ВНИМАНИЕ: не .ipa

## Чтение лога игры из файла лога

Если вы включите параметр *Write Log* в *game.project*, любой вывод игры будет записываться на диск в файл с именем "log.txt". Вот как можно извлечь файл, если вы запускаете игру на устройстве:
Используйте параметр проекта "Write Log File" в *game.project*, чтобы управлять записью лога в файл:

- "Never": не записывать лог в файл.
- "Debug": записывать файл лога только для Debug-сборок.
- "Always": записывать файл лога как для Debug, так и для Release-сборок.

Если запись включена, весь вывод игры будет записываться на диск в файл "`log.txt`". Вот как можно извлечь файл, если вы запускаете игру на устройстве:

iOS
: Подключите ваше устройство к компьютеру с установленными macOS и Xcode.
Expand Down
Binary file modified docs/ru/manuals/images/camera/create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/ru/manuals/images/camera/create@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading