Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ if (${PLYPATH} MATCHES "PLYPATH-NOTFOUND")
MESSAGE(SEND ERRORS "ply reader header not found")
endif (${PLYPATH} MATCHES "PLYPATH-NOTFOUND")

add_library(plyloader ${PLYPATH}/ply.c)
# install(FILES ${PLYPATH}/ply.h DESTINATION include/)

#TODO best way to just include embre folder ?
set(GVT_THIRDPARTY_EMBREESHADERS "${CMAKE_SOURCE_DIR}/third-party/embree-shaders")

Expand Down Expand Up @@ -429,7 +432,7 @@ endif(GVT_CORE)
if (GVT_RENDER)
set(GVT_RENDER_LIBS ${GVT_RENDER_LIBS})

set(GVT_RENDER_LIBS ${GVT_RENDER_LIBS} tinyobjloader ${ICET_CORE_LIBS} ${ICET_MPI_LIBS})
set(GVT_RENDER_LIBS ${GVT_RENDER_LIBS} tinyobjloader plyloader ${ICET_CORE_LIBS} ${ICET_MPI_LIBS})
include_directories(${TINYOBJPATH} ${PLYPATH})

# find_package(Boost REQUIRED COMPONENTS system)
Expand Down
Binary file added data/wavelet_color/wavelet.ply
Binary file not shown.
11 changes: 11 additions & 0 deletions pygvt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ display bunny.ppm
display wavelet.ppm
display block0.ppm
```
```
Set GVT model directory. This is optional.
export GVT_MODELS=/work/03378/hpark/maverick/gvtmodels

source test_example_plyapp.sh
display wavelet_color.ppm
display EnzoPlyData.ppm

If GVT_MODELS is set, open enzocolor.ppm.
display enzocolor.ppm
```
71 changes: 71 additions & 0 deletions pygvt/example_plyapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import gvt
import reader as rd
import sys
import os
import numpy as np
import argparse

# parse command line
parser = argparse.ArgumentParser(description='A PYGVT example to render a model in obj/ply/vtp format.')
parser.add_argument('dirname', help='directory name')
parser.add_argument('--image-size', nargs=2, default=[512, 512], help='image width and height')
parser.add_argument('--light-color', nargs=3, default=[100.0, 100.0, 100.0], help='light color')
parser.add_argument('--diffuse-color', nargs=3, default=[1.0, 1.0, 1.0], help='diffuse color for surfaces')
parser.add_argument('--camera-distance', nargs=1, type=float, default=[1.0], help='camera distance factor (the larger the farther)')
args = parser.parse_args()

# set filename
# filename = args.filename
dirname = args.dirname

# initialize gvt
gvt.gvtInit()

# create a mesh
model_name = os.path.basename(dirname).split(".")[0]

bounds = np.zeros((6,), dtype=np.float32)
gvt.readPly(dirname, False, bounds)

bounds = np.reshape(bounds, (2,3))
diagonal = np.linalg.norm(bounds[1] - bounds[0])
center = (bounds[0] + bounds[1]) * 0.5

print("bounds_min: ", bounds[0])
print("bounds_max: ", bounds[1])
print("diagonal: ", diagonal)
print("center: ", center)

# camera
camera_pos = (center + (np.array([0.0, 0.0, 1.0], dtype=np.float32) * (args.camera_distance[0] * diagonal))).astype(np.float32)
camera_focus = center.astype(np.float32)

gvt.addCamera("Camera", camera_pos, camera_focus,
# up
np.array([0.0, 1.0, 0.0], dtype=np.float32),
# fov, depth, samples, jitter
0.785398, 1, 1, 0.5)

# light source
# TODO: make this configurable
# locate a point light at the camera position
# light_pos = (r.center + (np.array([0.0, 1.0, 0.0], dtype=np.float32) * r.diagonal)).astype(np.float32)
light_pos = camera_pos
# TODO: make this configurable
light_color = np.array(args.light_color, dtype=np.float32)

gvt.addPointLight("PointLight", light_pos, light_color)

# set image size
gvt.addFilm("film", args.image_size[0], args.image_size[1], model_name)

# add renderer
gvt.addRenderer("render", 4, 0) # name, adapter, schedule;
gvt.render("render");

# dump the image to a ppm file
gvt.writeimage("render", model_name);

print("created " + model_name + ".ppm")


7 changes: 5 additions & 2 deletions pygvt/example_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
parser.add_argument('--image-size', nargs=2, default=[512, 512], help='image width and height')
parser.add_argument('--light-color', nargs=3, default=[100.0, 100.0, 100.0], help='light color')
parser.add_argument('--diffuse-color', nargs=3, default=[1.0, 1.0, 1.0], help='diffuse color for surfaces')
parser.add_argument('--camera-distance', nargs=1, default=1.0, help='camera distance factor (the larger the farther)')
parser.add_argument('--camera-distance', nargs=1, type=float, default=[1.0], help='camera distance factor (the larger the farther)')
args = parser.parse_args()

# set filename
Expand Down Expand Up @@ -43,8 +43,11 @@
gvt.addInstance(mesh_name, np.array([1.0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 1.0], dtype=np.float32))

# camera
camera_pos = (r.center + (np.array([0.0, 0.0, 1.0], dtype=np.float32) * (args.camera_distance * r.diagonal))).astype(np.float32)
camera_pos = (r.center + (np.array([0.0, 0.0, 1.0], dtype=np.float32) * (args.camera_distance[0] * r.diagonal))).astype(np.float32)
camera_focus = r.center.astype(np.float32)
# print("diagonal:", r.diagonal)
print("camera pos:", camera_pos)
print("camera focus: ", camera_focus)

gvt.addCamera("Camera", camera_pos, camera_focus,
# up
Expand Down
8 changes: 3 additions & 5 deletions pygvt/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
compile_args.append('-stdlib=libc++')
mpi_mac="-mt"


extensions = [
Extension("gvt",["src/gvt/gvt.pyx"],
include_dirs = [
Expand All @@ -72,15 +71,14 @@
numpy.get_include()],
libraries = [
"gvtRender","gvtCore",
"plyloader",
"IceTGL","IceTMPI","IceTCore",
"embree",
"boost_system"+mpi_mac,
"mpi",
"mpicxx",
"irc",
"imf",


"imf"
],
library_dirs = [
embree_lib,
Expand All @@ -99,5 +97,5 @@
cmdclass = {"build_ext": build_ext},
version="1.0.0",
ext_modules = extensions
#ext_modules = cythonize(extensions)
# ext_modules = cythonize(extensions)
)
Loading