-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated Tetris example to use View and improved stone selection logic * Updated text localisation example to use View and removed unneccisary values from MyGame class * Updated Timer example to use View and GLOBAL_CLOCK * Convert template platformer to use a View, and greatly imrpove multiple aspects of the example. * Updated tiled map examples to use View, and corrected many mistakes with the examples * Updated tank example and fixed more glaring issues * Added aliases for window properties commonly used in views * Updated sprite enemies in platformer to use a View, and added ability to reset game. * Updated pymunk joint builder to use View and fixed assertion error * Updated the perspective example to use View, and Camera. Plus created two new grips for use in the example. * Update transform_multi example to not use custom window * Updated all standard examples to use a View over a custom Window * Renaming all `MyGame` instances to `GameVIew` * Linting, and testing pass * tank example cleanup * updating minimap rst * Updated view to store a per-instance background color rather than an alias to the window's.
- Loading branch information
1 parent
150af62
commit 95fa66f
Showing
162 changed files
with
3,056 additions
and
1,763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from __future__ import annotations | ||
|
||
from pyglet.math import Vec3 | ||
|
||
from arcade.camera import CameraData | ||
from arcade.math import quaternion_rotation | ||
from arcade.types import Point3 | ||
|
||
|
||
def look_at(camera: CameraData, target: Point3, up: Point3 | None = None) -> tuple[Point3, Point3]: | ||
""" | ||
Calculate the neccisary forward and up vectors to have the camera look towards | ||
the target point. | ||
Uses the camera's up if none is provided. | ||
Args: | ||
camera: The CameraData to work from | ||
target: The point in 3D world space to look at | ||
up: An optional up axis to refer to when calculating the true up vector. | ||
""" | ||
px, py, pz = camera.position | ||
tx, ty, tz = target | ||
dx, dy, dz = tx - px, ty - py, tz - pz | ||
|
||
up = up or camera.up | ||
|
||
f = Vec3(dx, dy, dz).normalize() | ||
r = f.cross(up) | ||
u = r.cross(f).normalize() | ||
|
||
return f, u | ||
|
||
|
||
def orbit(camera: CameraData, origin: Point3, axis: Point3, angle: float) -> Point3: | ||
""" | ||
Find the new position for the camera when rotated around the origin | ||
Args: | ||
camera: The CameraData to work from | ||
origin: The point around which to orbit | ||
axis: The axis to rotate around, like the stick on a spinning top. | ||
angle: The angle in degrees to rotate by | ||
""" | ||
px, py, pz = camera.position | ||
tx, ty, tz = origin | ||
|
||
rx, ry, rz = quaternion_rotation(axis, (px - tx, py - ty, pz - tz), angle) | ||
return tx + rx, ty + ry, tz + rz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.