Runespoor is a flexible, straight forward, multi-paradigm game engine that is built from the ground up with developer experience in mind.Utilizing a game loop system similar to pygame, you are able to abstract elements of your game away from the game loop as much as you'd like.
Project description
Runespoor Python 3D Game Engine
A python 3D game engine written in c++ using SDL, Assimp, OpenGL(GLAD), and GLM.
To install:
pip install Runespoor
Please note:
-
Runespoor is still in development and only dev versions are available right now. Everything is subject to change, be fixed, and improve.
-
When building from source
pkg-config
must be installed. In addition to this,GLM
must be installed and present in your c/c++ package manager's include directory. Successful attempts to compile have been made on windows withvcpkg
as the package manager.
About:
Runespoor is a flexible, straight forward, multi-paradigm game engine that is built from the ground up with developer experience in mind. Utilizing a game loop system similar to pygame, you are able to abstract elements of your game away from the game loop as much as you'd like.
For a taste of the api check out the test file:
from Runespoor import (
Vec3, Camera, Mesh, Object, Window, EVENT_FLAG,
Material, Shader, ShaderType, EVENT_STATE, Quaternion
)
import math
from copy import copy
# The meshes used in this testfile are not provided with the library or source files.
dim = (1280, 720)
focal_length = 10000
camera = Camera(Vec3(0.0,0.0,0.0), Vec3(0.0,0.0,0.0), *dim, focal_length, math.radians(60))
window = Window("FBX Car Test", camera, *dim, False)
# Materials are equivalent to shader programs.
default_material = Material()
# # If you wanted to create a new shader program, normally you would do something like this:
#
# default_material = Material(
# Shader.from_file("path/to/vertexshader.glsl", ShaderType.FRAGMENT),
# Shader.from_file("path/to/fragmentshader.glsl", ShaderType.VERTEX)
# )
#
# # Then to set a uniform:
#
# default_material.set_uniform("uniform_name", some_value, "i")
#
# # The third argument is a magic string that represents the type. in this case the type is an integer.
car_meshes = Mesh.from_file("./meshes/fbx_car/svj_PACKED.fbx")
car = Object(car_meshes,
Vec3(0.0,-100.0,500), Vec3(0,0,0), Vec3(1,1,1), material=default_material)
car2 = Object(car_meshes,
Vec3(300,0,500), Vec3(10,3.57,23.2), material=default_material)
teapot = Object(Mesh.from_file("./meshes/teapot/teapot.obj"),
Vec3(-100,0,200), Vec3(0,0,0), material=default_material)
pirate_ship = Object(Mesh.from_file("./meshes/pirate_ship/pirate_ship.obj"),
Vec3(-100,-100,300), Vec3(0,10,0), material=default_material)
window.add_object_list([
car,
car2,
teapot,
pirate_ship
])
window.lock_mouse(True)
vel_yaw = 0.0
vel = 0.0
frict = 0.1
accel = 5
cam_dist = 300.0
magic_turn_dampener = 4
mouse_sensitivity = 10
counter = 0
counter_speed = 1
while not window.event.check_flag(EVENT_FLAG.QUIT) and window.event.get_flag(EVENT_FLAG.KEY_ESCAPE) != EVENT_STATE.PRESSED:
if window.dt > 0:
print(f"FRAMERATE: {1.0/window.dt:.1f} fps")
else:
print("FRAMERATE: inf fps")
# Use WASD keys.
if window.event.get_flag(EVENT_FLAG.KEY_d) == EVENT_STATE.PRESSED:
# ROTATE RIGHT
vel_yaw -= 0.3
if window.event.get_flag(EVENT_FLAG.KEY_a) == EVENT_STATE.PRESSED:
# ROTATE LEFT
vel_yaw += 0.3
if window.event.get_flag(EVENT_FLAG.KEY_s) == EVENT_STATE.PRESSED:
# BACKWARDS
vel -= accel
if window.event.get_flag(EVENT_FLAG.KEY_w) == EVENT_STATE.PRESSED:
# FORWARD
vel += accel
# apply a quaternion rotation arround the vector vec3(1,1,0)
teapot.rotation = Quaternion.from_axis_angle(Vec3(1,1,0), math.radians(counter))
# Clamp and rotate, then apply friction.
vel_yaw = min(max(vel_yaw, -100), 100) if abs(vel_yaw) > frict else 0
car.rotation.rotate_yaw(-vel_yaw/magic_turn_dampener * window.dt)
vel_yaw -= math.copysign(frict, vel_yaw)
# Clamp the velocity.
vel = min(max(vel, -1000), 1000) if abs(vel) > frict else 0
# Move the car forwards with its forwards vector with a magnitude of `vel` and apply friction
car.position += -car.rotation.forward * vel * window.dt # window.dt is deltatime
vel -= math.copysign(frict, vel)
# Rotate the camera
cam_rot = Quaternion.from_quat(camera.rotation)
yaw_rot = 0 # capture the yaw rot so we can apply it to the quat later in the case where the camera is clamped
if window.event.check_flag(EVENT_FLAG.MOUSE_MOTION):
cam_rot.rotate_yaw(yaw_rot := -math.radians(window.event.mouse.rel_x * mouse_sensitivity * window.dt))
cam_rot.rotate(cam_rot.right, math.radians(window.event.mouse.rel_y * mouse_sensitivity * window.dt))
# zoom in and out
if window.event.check_flag(EVENT_FLAG.MOUSE_WHEEL):
cam_dist -= window.event.mouse.wheel.y * 10
# apply/clamp, position, and camera rotation
if cam_rot.up.y >= 0.7:
# Position the camera behind the car based on its forward vector
camera.position = car.position - (cam_rot.forward * cam_dist)
camera.rotation = cam_rot
else:
camera.rotation.rotate_yaw(yaw_rot)
# Position the camera behind the car based on its forward vector
camera.position = car.position - (camera.rotation.forward * cam_dist)
# Re-render the scene.
window.update()
# This also refreshes window.event
counter += counter_speed
Then when we run it, it looks something like this:
Important: How to Import 3D Assets:
For now, your 3d assets. must be structured a specific way to be picked up by the asset importer.
The 3d asset file must be accompanied by an adjacent \textures\
folder where you must store all image assets for your 3d asset file. This may or may not be changed in the future, the asset importing system is not finalized.
Your assets might look something like this:
asset_1_name_of_this_folder_doesnt_matter\
my_3d_thing.obj
textures\
name_of_texture_file.png
asset_2_name_of_this_folder_doesnt_matter_either\
my_other_3d_thing.fbx
textures\
name_of_other_texture_file.png
Then you would import yout assets like so:
asset1 = Mesh.from_file("...../asset_1_name_of_this_folder_doesnt_matter/my_3d_thing.fbx")
asset2 = Mesh.from_file("...../asset_2_name_of_this_folder_doesnt_matter_either/my_other_3d_thing.fbx")
And voila! Your 3D assets are now imported and ready to be used in objects and rendered to the screen.
TODO:
-
Add
from_raw
constructor to mesh to make procedural meshes possible. -
Add window/fullscreen scaling.
-
Add Matrix datastructures for GLM.
-
Add
Quaternion
type toset_uniform
Future Plans:
- Switch to Vulkan.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for Runespoor-1.0.0.dev19-pp310-pypy310_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f212b7dd6ec4af836222d0f9637dcc3bc6b87d6732397838b9747b377857b6e4 |
|
MD5 | f745df6a266f73808732c292ff0f3034 |
|
BLAKE2b-256 | f6ab1ddc59e20ea41becaad9e4fd780900e5e1f2b5a99d10206a0fc3d367f67f |
Hashes for Runespoor-1.0.0.dev19-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd4a578acac50e82582abfb2f3dca6bd7438cb6b2d5e04c564645609f2da8aef |
|
MD5 | fc874c1593809f5d4b8ecb5c735de156 |
|
BLAKE2b-256 | 2701ff0e89716b97c592baa3fdc4625d66258ffe763d016c1f30755751f4e94d |
Hashes for Runespoor-1.0.0.dev19-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9aba663a8171ec9fe087d4e638df6154f497982236b1f7c59548c2d0d413752d |
|
MD5 | 1a0ce5d4028b90ba00b935127a9643da |
|
BLAKE2b-256 | 0945faa192de1d4159fd05896278427297ecb30ebc181efda25f954638963dee |
Hashes for Runespoor-1.0.0.dev19-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cedc6851acad4eec1f062e2f59aa7fb616561ad1adb5916ff59314c0a394da7b |
|
MD5 | a61a1c8fd007e6b5f82626f3b69d468e |
|
BLAKE2b-256 | a1d99059902d122e8704e7b221e3dfbdcc7d0432dbf6aff1664e80ed0a84e231 |
Hashes for Runespoor-1.0.0.dev19-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b304d71dcbac25f344738acb6d49309b81c31cd9db68d63cea1930a49747b427 |
|
MD5 | 223dee75aea7c479fefc0f59a2fc5649 |
|
BLAKE2b-256 | 510eaba57c11db03520b9b5036a7557ee75d68df2f39add2f2f22511bbee6884 |
Hashes for Runespoor-1.0.0.dev19-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00d71460fb183f16b9073571b141f4cf871c09c52ea6440ae1d0bedfe1af9b5d |
|
MD5 | c2441d68a97fe5d1b9a60a46aa4e6e9e |
|
BLAKE2b-256 | d8bc683ae65180c4bd25c55e995407f84dfaaed00a048b025199c3264d6bf733 |
Hashes for Runespoor-1.0.0.dev19-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 505d40e9b5ab338053fc2f31dd1ba6a15189f54207b1f275b4e0921d9da070aa |
|
MD5 | bfc4e82777835423b80358ab946d0712 |
|
BLAKE2b-256 | f0b5e3de8821dc890432a7efbe88e3aac947db965010a5be5a70d9b9bca2d0a8 |
Hashes for Runespoor-1.0.0.dev19-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75eec1a0286d686f58dd50423340009896f56121a4bc7f8088c0f68eee9536d0 |
|
MD5 | a498ec1822041d69be73ea90d839ecfe |
|
BLAKE2b-256 | 79ad42a64933bdf6288a2f6d3facaee2b5b13b499a96d67e86387f3780e64674 |
Hashes for Runespoor-1.0.0.dev19-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3748e53cace4786396fbe7123bdd0e1d2b90f11938d0c495679c093d3faf1f1f |
|
MD5 | 0a79e100e87a6c35cf43fe1de94a30fc |
|
BLAKE2b-256 | d9228a162cad811a0e96fa182bbe7f5a4a1b514803e3e684de9d83a813cf8e41 |
Hashes for Runespoor-1.0.0.dev19-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4e08235660aa62b69a446e2326cf7c7979e52712a9bde9b613e23891511f4d2 |
|
MD5 | 1212bdd2b0c70138a61528e9e7c00a57 |
|
BLAKE2b-256 | d52d2cbf1b05347f4ae3d074520b250096c93ff63a7b8b8993bbed36d47c6a67 |
Hashes for Runespoor-1.0.0.dev19-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a44e5ac54108519bc8b24576182b77b0791ce1359c4919354f548badc1129f2 |
|
MD5 | 82d1495cff6e8050048219ff788ae54e |
|
BLAKE2b-256 | a8c237f7ba4a393820535e9b266b87730c3b19797705915e9d9133b66b8c19ae |
Hashes for Runespoor-1.0.0.dev19-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66c3548518c03bb9f228218cb1c1016017b2cd0b19947eda0f22f30990aa40cc |
|
MD5 | f61874e2ae7518de0d6c06ed451f07cd |
|
BLAKE2b-256 | a37effab9613ae510abb096ade0ca4d19df8557330cfff75d4aac76cc49742a7 |
Hashes for Runespoor-1.0.0.dev19-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0260efaebc8a53d59920d4bd2e8a6dd5cb581f93c784df99ff23196d3ec02596 |
|
MD5 | 07ca32a97187e449e2de4ed7165c3ed2 |
|
BLAKE2b-256 | e5504bfb970455292d324552738763d498f7d5fadf3ed6da716b367f3bcb91eb |
Hashes for Runespoor-1.0.0.dev19-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e506cce9d6b0ad469e655485d9092a0493f8f9b1237b92a2e58b607abb5a0132 |
|
MD5 | a8d7d5efbd68c7d311dcf04fa85f06b4 |
|
BLAKE2b-256 | 45b8d1c725cda9baef45b221ba6d1bea41e39232b81aff7b780c8524fc68a8bc |
Hashes for Runespoor-1.0.0.dev19-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfee8556ea4cfacd45b2a59435f9e187652a9dbe7f3f816d12f4829f563aaf22 |
|
MD5 | 0a9eb30d0ecaf88be252c2c68c923948 |
|
BLAKE2b-256 | a78cedfa33c8c6604d797319698f7db0ce68dba0e29946a870d309c93ca4f4bb |
Hashes for Runespoor-1.0.0.dev19-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df475ee2fb348368dbff024361a325acd1d8836d8fa182f3b0c8a46297c672b4 |
|
MD5 | 5d68ea9a995a205ef8c4037d6770b557 |
|
BLAKE2b-256 | 37ea60ae102329d69ca231d1a68b77220c726dca4141c824235c13f0b189e2b2 |
Hashes for Runespoor-1.0.0.dev19-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98744cb2441ea1323dd824d579429238a38037580b23d1dc77b289d92a73ef8d |
|
MD5 | 05cbc37701f2d66d4efd9f2cfa9aecc4 |
|
BLAKE2b-256 | 170c7940507a8b817b7f3c5c14365bbf825f7d464387478d55f76c34fdef8d2e |
Hashes for Runespoor-1.0.0.dev19-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c0ce2895599a815f03820afed84e63bc437b9c61a7e6c983af52b879ce7c1cd |
|
MD5 | 348f5b5631e5dfe7bae0a4456bcde2be |
|
BLAKE2b-256 | 4a3091971a0008b97944edde45c70f52850fe1079000a9b14da156bb6c8f0c41 |