Simple python 3D vector3 math library wrapping some types from GLM library using pybind11.

Overview

vmath

Simple python 3D vector3 math library wrapping some types from GLM library using pybind11.

Description

Both pure python version and C++ version provided.

Not a direct glm wrapping. There are some Object-Oriented enhencements to the types.

Should be useful for other pybind11 bindings that use glm types, the conversion will be automatic (if done right).

Types:

  • Vector3 - glm::vec3
  • Quaternion - glm::quat
  • Matrix4 - glm::mat4
  • Transform - translation-rotation-scale
  • Vector2 - glm::vec2
  • Vector4 - glm::vec4
  • Ray - position-direction

Main source files comes from:

  • toy/wrap/wrap_vmath.h
  • toy/wrap/wrap_vmath.cpp
  • toy/glm_util.h
  • toy/glm_util.cpp

Documentation

See vmath.py for interfaces.

See src/wrap_vmath.cpp for pybind11 binding code.

Usage

Main classes:

  • Vector3: 3D Vector3.
  • Matrix4: 4x4 column major matrix4, M1 * M2 means first apply M2, then apply M1.
  • Quaternion: Quaternion for rotation.
  • Transform: Transform represented as Translation-Rotation-Scale.
>>> from vmath import Vector3, Matrix4, Quaternion, Transform
>>> v1 = Vector3(1.0, 2.0, 3.0)
>>> v2 = Vector3(4.0, 5.0, 6.0)
>>> v1 + v2
Vector3(5.0000, 7.0000, 9.0000)

>>> q = Quaternion.from_euler_angles(Vector3(0.0, 0.8, 0.0))
>>> q
Quaternion(0.9211, 0.0000, 0.3894, 0.0000)

>>> xf = Transform(v1, q, Vector3(1.0, 1.0, 1.0))
>>> m = xf.to_matrix4()
>>> print(m)
Matrix4<0.6967, 0.0000, 0.7174, 1.0000
       0.0000, 1.0000, 0.0000, 2.0000
       -0.7174, 0.0000, 0.6967, 3.0000
       0.0000, 0.0000, 0.0000, 1.0000>

>>> m.decompose()
Transform(Vector3(1.0000, 2.0000, 3.0000), Quaternion(0.9211, 0.0000, 0.3894, 0.0000), Vector3(1.0000, 1.0000, 1.0000))

>>> m.transform_vector3(v1)
Vector3(2.8488, 2.0000, 1.3728)
>>> m.transform_point(v1)
Vector3(3.8488, 4.0000, 4.3728)

Euler angles should be stored in Vector3(pitch, yaw, roll), order yaw-pitch-roll. Therefore the corresponding rotation matrix4 is M(yaw) * M(pitch) * M(roll).

Automatic conversion

One may want to use pybind11 binded glm types in multiple different extension modules, or embedded modules.

The conversion should just works thanks to internal pybind11 mechanisms, but with some carvets. Some notes:

  • Don't mix Debug and Release extension modules. The types won't be recongnised as the same by pybind11.

  • If one want more control, just drop the cpp files in the target project and compile _vmath as builtin (embedded) as vmath.

Build

Checkout pip_install_debug.bat file. One need to provide GLM path to build the extension.

Note

The interface of the types between the pure python module and extension module is somewhat different.

License

MIT License.

Projeto Flappy Bird temática doom, projeto python e pygame

Doom-Bird Tecnologias usadas Requisitos para inicializar o jogo: Python faça o download em: https://www.python.org/downloads/ Após instalar o Python d

João Guilherme 1 Dec 08, 2021
Lint game data metafiles against GTA5.xsd for Rockstar's game engine (RAGE)

rage-lint Lint RAGE (only GTA5 at the moment) meta/XML files for validity based off of the GTA5.xsd generated from game code. This script accepts a se

GoatGeek 11 Sep 18, 2022
A minimal open source mtg-like tcg game made in python that can be played on a terminal emulator using a keyboard.

A minimal open source mtg-like tcg game made in python that can be played on a terminal emulator using a keyboard.

Amos 3 Aug 29, 2021
A python game engine.

PursuedPyBear, also known as ppb, exists to be an educational resource. Most obviously used to teach computer science, it can be a useful tool for any topic that a simulation can be helpful.

PPB 235 Jan 08, 2023
To solve games using AI, we will introduce the concept of a game tree followed by minimax algorithm.

To solve games using AI, we will introduce the concept of a game tree followed by minimax algorithm.

Vaibhaw 7 Oct 13, 2022
A two-player strategy game played on a rectangular grid made up of smaller square cells of chocolate 🍫 or cookies 🍪

Chomp Game ©️ Chomp is a two-player strategy game played on a rectangular grid made up of smaller square cells of chocolate 🍫 or cookies 🍪 , which c

Farivar Tabatabaei 2 Feb 02, 2022
An interactive pygame implementation of Conway's Game of Life

Game of Life An interactive pygame implementation of Conway's Game of Life Installation Clone the repo and navigate into it. git clone https://github.

Ethan 1 Dec 05, 2021
An open source Python library for the Snake retro game.

An open source Python library for the Snake retro game.

3 Jul 13, 2021
MCTS (among other things) for 2048

2048 Created by Chad Palmer for CPSC 474, Fall 2021 Overview: This is an application which can play 2048 and simulate games of 2048 with a variety of

Chad Palmer 1 Dec 16, 2021
A near-exact clone of google chrome's no internet game, or the "google dinosaur game", with some additions and extras.

dinoGame A near-exact clone of google chrome's no internet game, or the "google dinosaur game", with some additions and extras. Installation Download

1 Oct 26, 2021
A set of tools to help you with running a Project Zomboid game server (Linux only)

Project Zomboid Server Tools A set of tools to help you with running a Project Zomboid game server (Linux only). Features Install Project Zomboid Dedi

24 Dec 25, 2022
Average Clicker Game (AVG) is a Python made game using tkinter

Average-Clicker-Game Average Clicker Game (AVG) is a Python clicker game not made with pygame but with tkinter, it has worker, worker upgrades, times

Zacky2613 1 Dec 21, 2021
A game that depicts a real astronaut's struggles

Interstel-quickscooping-game Right from the beginning of our (i.e, me and me alone) journey in the creation of this game, our goal was to give a game

Sharath V 3 Jul 12, 2021
A Python based program that displays Your Minecraft Server's Status Infos.

Minecraft-server-Status This (very) small python script allows you to view any Minecraft server's status Information Usage Download the file, install

Jonas_Jones 2 Oct 05, 2022
Snake Game in Python

Snake game is one of the most popular arcade games of all time. In this game, the main objective of the player is to catch the maximum number of fruits without hitting the wall or itself.

Pavan Ananth Sharma 4 Jul 05, 2022
Python Interactive Mini Games

Python Interactive Mini Games Mini projects from Coursera's An Introduction to I

Ashish Choudhary 1 Jan 16, 2022
You can play TicTacToe with the engine running UI.py with python3

TicTacToe An "Engine" for TicTacToe You can play TicTacToe with the engine running UI.py with python3. The file engine.py is designed so you can make

Ahnaf Syndeed 3 Feb 20, 2022
Editor for Bioware's Original Neverwinter Nights Game

neveredit This is an import of an old sourceforge project. Neveredit is an editor for Bioware's Neverwinter Nights game. It also includes all the low

Peter Gorniak 2 Apr 12, 2022
Minecraft Bedrock Server Control GUI

A control dashboard to monitor and control your minecraft bedrock dedicated server through an easy user interface. Created by Nathan-Busse 13 January 2022 Made with Python 3.8

Nathan Busse 3 Dec 11, 2022
Simplerpg - python terminal game made from scratch.

Simplerpg - python terminal game made from scratch.

reversee 3 Sep 17, 2022