Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

colors for show_interior_samples.py #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
31 changes: 27 additions & 4 deletions show_interior_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import OpenGL.GL as gl
import pypangolin as pango
import numpy as np

if __name__ == "__main__":

Expand All @@ -19,6 +20,19 @@
data = deep_sdf.data.read_sdf_samples_into_ram(npz_filename)

xyz_neg = data[1][:, 0:3].numpy().astype(ctypes.c_float)
sdf_neg = data[1][:, 3].numpy().astype(ctypes.c_float)
rgb_neg = np.zeros_like(xyz_neg).astype(ctypes.c_float)

xyz_pos = data[0][:, 0:3].numpy().astype(ctypes.c_float)
sdf_pos = data[0][:, 3].numpy().astype(ctypes.c_float)
rgb_pos = np.zeros_like(xyz_pos).astype(ctypes.c_float)

s = 10.
rgb_neg[:,0] = np.minimum(s*sdf_neg / sdf_neg.min(), np.ones_like(sdf_neg))
rgb_neg[:,1] = 1. - rgb_neg[:,0]

rgb_pos[:,2] = np.minimum( s*sdf_pos / sdf_pos.max(), np.ones_like(sdf_pos))
rgb_pos[:,1] = 1. - rgb_pos[:,2]

win = pango.CreateWindowAndBind("Interior Samples | " + npz_filename, 640, 480)
gl.glEnable(gl.GL_DEPTH_TEST)
Expand Down Expand Up @@ -49,16 +63,25 @@
gl.glClear(gl.GL_COLOR_BUFFER_BIT + gl.GL_DEPTH_BUFFER_BIT)
d_cam.Activate(s_cam)

gl.glEnableClientState(gl.GL_VERTEX_ARRAY)

gl.glColor3ub(255, 255, 255)

gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
gl.glVertexPointer(
3, gl.GL_FLOAT, 0, xyz_neg.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
)

gl.glColorPointer(
3, gl.GL_FLOAT, 0, rgb_neg.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
)
gl.glDrawArrays(gl.GL_POINTS, 0, xyz_neg.shape[0])

gl.glVertexPointer(
3, gl.GL_FLOAT, 0, xyz_pos.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
)
gl.glColorPointer(
3, gl.GL_FLOAT, 0, rgb_pos.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
)
gl.glDrawArrays(gl.GL_POINTS, 0, xyz_pos.shape[0])
gl.glDisableClientState(gl.GL_COLOR_ARRAY)
gl.glDisableClientState(gl.GL_VERTEX_ARRAY)

pango.FinishFrame()