Giter Club home page Giter Club logo

pyemblite's Introduction

pyemblite

Python wrapper for Embree-3. Source code adapted from pyembree Embree-2 wrapper.

Quick Start

Example:

import numpy as np
import trimesh
from trimesh.primitives import Sphere
from pyemblite.mesh_construction import TriangleMesh
from pyemblite.rtcore_scene import EmbreeScene

# Create Embree scene which holds meshes.
scene = EmbreeScene()

# Create a mesh using trimesh (https://github.com/mikedh/trimesh).
tmesh = Sphere(radius=5.0, subdivisions=1)

# Create Embree triangle mesh geometry
emesh = TriangleMesh(scene, tmesh.vertices, tmesh.faces)

# Commit the scene (builds spatial acceleration structures).
scene.commit()

# Generate ray origins and ray directions
ray_orgs = (
    np.zeros((tmesh.vertices.shape[0], 3), dtype=np.float32)
    +
    tmesh.centroid
).astype(np.float32)
ray_dirs = (tmesh.vertices - tmesh.centroid).astype(np.float32)
ray_dirs /= np.linalg.norm(ray_dirs, axis=1)[np.newaxis, 1]

# Query the index of the first face which gets hit by ray
# (index of -1 indicates ray did not hit a face)
primID = scene.run(ray_orgs, ray_dirs, query='INTERSECT')

# Query the distance from the ray origin where face which gets hit by ray
# Intersection points are ray_orgs + tfar * ray_dirs
tfar = scene.run(ray_orgs, ray_dirs, query='DISTANCE')
print(tfar)

# Query all info, intersect_info is a dict with keys:
# ['u', 'v', 'Ng', 'tfar', 'primID', 'geomID']
intersect_info = scene.run(ray_orgs, ray_dirs, output=True)

Installation

Install from latest github source:

python -m pip install --no-deps --no-build-isolation --user git+https://github.com/AppliedMathematicsANU/pyemblite.git#egg=pyemblite

If you're on windows, you need to have embree3 installed. Use the most recent version, make sure you unzip the contents of the zip file into a folder where the MS build tools can find them.

You can always add the embree3 folder to your library and include path by changing the LIB and INCLUDE environment variables:

set INCLUDE="C:\Path\to\embree\include\dir:%INCLUDE%"

set LIB="C:\Path\to\embree\lib\dir:%LIB%"

You also still need to have build tools installed (some kind of C/C++ compiler). One way to achieve this is to install Visual Studio Build tools. Visual studio build tools likely require the installation of visual studio community edition first. This link should (hopefully) get you started:

https://visualstudio.microsoft.com/downloads/

Finally, you'll need to manually copy the Embree3.dll from (standard path when installed) C:\Program Files\Intel\Embree3\bin to C:\windows\system32 and (if you are on windows as you likely are these days) also to C:\windows\sysWOW64 . That should do it...

Requirements

Requires:

Testing

Run tests (unit-tests and doctest module docstring tests) using:

python -m pyemblite.test

Latest source code

Source at github:

https://github.com/AppliedMathematicsANU/pyemblite

License information

See the file LICENSE.txt for terms & conditions, for usage and a DISCLAIMER OF ALL WARRANTIES.

pyemblite's People

Contributors

shane-j-latham avatar odf avatar rolandfleddermannanu 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.