GithubHelp home page GithubHelp logo

pygame-3d-wireframes's Introduction

Pygame 3D Wireframes with Software Rendering

Introduction

This sample project and library demonstrates basic rendering of wireframes in 3D in software only. No hardware acceleration is used. Currently, no z-buffering or clipping is performed. This may change if either I decide to implement them, or, if you decide to implement them, in which case you should open a pull request =). However, you can find a fast draft of the Liang-Barsky algorithm that I haven't tested in mathutil.py.

This is a continuation of a final project for CIS 192 at the University of Pennsylvania. The primary purpose of this project is to be educational. This is probably not intended for production usage, but you are more than welcome to use it for that purpose.

Setup and Installation

This project should work with the latest versions of numpy and pygame. You can refer to the websites of those respective packages for installation help.

Simply download the project sources and run main.py.

This project does not rely on hardware 3D, so it should run on any system.

Running the Sample Viewer

Simply running python main.py will launch a basic viewer, which uses WASD and mouse for basic interaction.

Run python main.py --help for command-line usage options.

Project and Library Structure

The sample viewer follows a MVC design. The file game.py contains the Game controller, which manipulates the underlying view, which is given as a constructor argument. There are currently two different kinds of cameras provided to render scenes: OrthographicViewport and PerspectiveViewport, utilizing orthographic projection and perspective projection, respectively.

Creating your own custom viewport is rather simple. Simply extend Viewport, and override the relevant functions (most likely just update_projection_matrix and to_view_coords).

A wireframe model (classes extending Model from model.py) is simply a collection of edges, and represents that object in its own coordinate system with its own scale. Drawable objects should extend Model (c.f. Cube in shapes.py).

Licensing

You can use the code of this project in full (or any part thereof) in any commercial or non-commercial code. You might want to check with your instructor if you want to use the code within a homework assignment.

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.