Giter Club home page Giter Club logo

paramesh's Introduction

paramesh

The bagel immersion of a Klein bottle

Generate a triangle mesh from a parametric equation. This is done by taking the surface and "cutting it up" into "rings" and "slices". Two angles, theta and phi step along the rings and the slices to form quads on the mesh, which are then broken up into two triangles.

For example, for a sphere we'd break it up like this:

More rings and slices will mean more triangles in the mesh. 32 rings and 32 slices seems to work pretty well for building a generally smooth mesh.

Thanks to Nicolas Guillemot (@nlguillemot) for pointing me towards this method for triangulating a sphere. I'm glad it generalizes so well to other surfaces!

Requirements

  • Some sort of vector math library. I used glm. You can easily sub your own in by editing mesh.hpp. (I'll make this more standalone when I have time; it's extracted from a much larger assignment, and it made more sense to use a separate library there!)
  • A C++ compiler that supports at least C++11.

Usage

mesh_generators.cpp contains some sample functions for generating meshes. You can easily create your own mesh-generating function (or a general function) by using those functions as a model.

Making a Mesh-Generating Function
  1. Create a list of vertices and triangles for the mesh
  2. Create a lambda vec3 f(float u, v) where u, v define angles in radians. u=theta is the angle between horizontal cuts in the surface, and v=phi is the angle between vertical cuts in the surface
  3. Call GeneratePoints with your lambda
  4. Call GenerateFaces to generate the triangles for the mesh
  5. Call GenerateVertexNormals
  6. Copy over the number of vertices, number of triangles, and the lists to the mesh

After, you can use the resulting TriangleMesh type directly, or you can output to a file by calling WriteMesh.

paramesh's People

Stargazers

rainbow at the corner avatar TANGUY Arnaud avatar Shuo Qi  avatar  avatar Felipe Gutierrez avatar  avatar Vic P. avatar rodrigo figueroa avatar Aiekick avatar Umar Rajguru avatar Bill Quith avatar  avatar andrea denisse avatar Xiaoxiao LONG avatar LoneAtom avatar Vanessa McHale avatar  avatar  avatar Stefan Zellmann avatar Simon Racz avatar  avatar Luis Hidalgo avatar Daniel Krikun avatar Simon Geilfus avatar Dmitry Ledentsov avatar Mykola Konyk avatar Victor Zverovich avatar Karim Naaji avatar  avatar Mark Hindess avatar Mark Sta Ana avatar Mark Moissette avatar Dmitri Shuralyov avatar Dimitri Diakopoulos avatar jiangplus avatar PickleJesus123 avatar D. Zack Garza avatar Mikola Lysenko avatar Chris A. avatar

Watchers

James Cloos avatar Jessica Paquette 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.