Git Product home page Git Product logo

csg-explorer's Introduction

Csg Explorer

A small library to efficiently render and define implicit shapes, described as CSGs of signed distance fields using. Python bindings included!

Example

This is the text file that defines the shape in the example. It can be found in data/test.csg.

# Syntax:
#   <node-name> = <add/remove> <softness> <primitive> <parameters...>
#   <node-name> += <add/remove> <softness> <other-node-name>

head = sphere 0.0 0.0 -0.1 0.4

orbits = sphere 0.2 0.2 0.25 0.1
orbits += sphere -0.2 0.2 0.25 0.1
head -= 0.7 0.05 orbits

eyes = sphere 0.16 0.16 0.18 0.03
eyes += sphere -0.16 0.16 0.18 0.03
head += eyes

nose = sphere 0.0 0.0 0.3 0.1
head += 1.0 0.05 nose

mouth = sphere -0.1 -0.2 0.25 0.05
mouth += 1.0 0.05 sphere 0.0 -0.2 0.25 0.05
mouth += 1.0 0.05 sphere 0.1 -0.2 0.25 0.05
head -= mouth

And this is the visualization of the generated CSG, compactly stored under-the-hood to provide fast evaluation and rendering.

Python binding

The CSG parser, evaluator and renderer can be directly called from python, with no performance loss over the C++ implementation.

from pycsg import *

csg = load_csg("data/test.csg")
render(csg)

Build

If you have Ninja installed.

python3 scripts/build.py release

Otherwise

mkdir build
cd build
cmake ..
make

csg-explorer's People

Contributors

giacomonazzaro avatar

Stargazers

Michael Cheng avatar

Watchers

James Cloos avatar  avatar

Forkers

happydpc

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.