Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chain vdb_view to vdb_render #1790

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions openvdb_cmd/vdb_view/Camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ Camera::Camera()
}


openvdb::Mat4s
Camera::getTransformationMatrix()
{
float matrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
return openvdb::Mat4s(matrix);
}


void
Camera::lookAt(const openvdb::Vec3d& p, double dist)
{
Expand Down
2 changes: 2 additions & 0 deletions openvdb_cmd/vdb_view/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Camera

void aim();

openvdb::Mat4s getTransformationMatrix();

void lookAt(const openvdb::Vec3d& p, double dist = 1.0);
void lookAtTarget();

Expand Down
11 changes: 11 additions & 0 deletions openvdb_cmd/vdb_view/Viewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ViewerImpl
void showNextGrid();

bool needsDisplay();
void printCameraTransformationMatrix();
void setNeedsDisplay();

void toggleRenderModule(size_t n);
Expand Down Expand Up @@ -992,6 +993,9 @@ ViewerImpl::keyCallback(int key, int action)
case 'i': case 'I':
toggleInfoText();
break;
case 'p': case 'P':
printCameraTransformationMatrix();
break;
case GLFW_KEY_LEFT:
showPrevGrid();
break;
Expand Down Expand Up @@ -1084,6 +1088,13 @@ ViewerImpl::needsDisplay()
}


void
ViewerImpl::printCameraTransformationMatrix()
{
std::cout << mCamera->getTransformationMatrix() << std::endl;
}


void
ViewerImpl::setNeedsDisplay()
{
Expand Down
1 change: 1 addition & 0 deletions openvdb_cmd/vdb_view/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ usage [[noreturn]] (const char* progName, int status)
" G (\"geometry\") look at center of geometry\n" <<
" H (\"home\") look at origin\n" <<
" I toggle on-screen grid info on/off\n" <<
" P print camera transformation matrix\n" <<
" left mouse tumble\n" <<
" right mouse pan\n" <<
" mouse wheel zoom\n" <<
Expand Down