Giter Club home page Giter Club logo

pyengine3d's Introduction

PyEngine3D

Example of a simple landscape Example of a mountain landscape

The code here is explained in my medium.com post https://medium.com/quick-code/3d-graphics-using-the-python-standard-library-99914447760c


PyEngine3D is a simple module using only the python standard library to display and interact with 3D designs.


The main module can be found in the "graphics" directory, the other files are demos of different features.


The first step is to create an Engine object which requires a set of points and a set of triangles linking them together.

test = Engine3D([[1, 1, 1], [0, 0, 0], [2, 2, 2]], [[0, 1, 2]]) # this will create a single triangle between these points
test = Engine3D([[1, 1, 1], [0, 0, 0], [2, 2, 2]], [[0, 1, 2, "green"]]) # you can also change the color of the triangle (the default is green)

From your code, you can modify the display using the writePoints, writeTriangles, rotate, clear and render methods.

test.writePoints([[3, 3, 3], [0, 0, 0], [2, 2, 2]]) # change the points
test.writeTriangles([[2, 1, 0, "blue"]]) # the order of the points does not matter
test.rotate("y", 45) # rotate the object 45 degrees around the y axis
test.clear() # clear the display
test.render() # update the image

You can also use the following keys to interact with the display.

  1. Left mouse button + Drag -> Rotate the view
  2. Up arrow -> Zoom in
  3. Down arrow -> Zoom out
  4. w, a, s, d -> Move the view up, left, down or right

The module now also allows you to move points on the model (this is still a work in progress)

  1. Select a point using the right mouse button (holding)
  2. Select an axis to move along by pressing x, y or z
  3. Use the right and left arrow keys to move along the axis

If you would like to help me improve this project, you can contact me at [email protected]

pyengine3d's People

Contributors

hnhaefliger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.