Commit 7d661d95 authored by David Llewellyn-Jones's avatar David Llewellyn-Jones

Added new OpenVDB wrapper files.

parent a9d1d85a
This diff is collapsed.
This diff is collapsed.
///////////////////////////////////////////////////////////////////
// Functy
// 3D graph drawing utility
//
// David Llewellyn-Jones
// http://www.flypig.co.uk
//
// Summer 2014
///////////////////////////////////////////////////////////////////
#ifndef EXPORTVDB_H
#define EXPORTVDB_H
///////////////////////////////////////////////////////////////////
// Includes
#include "vis.h"
#include "function.h"
#include "longpoll.h"
///////////////////////////////////////////////////////////////////
// Defines
#define EXPORTVOXEL_SLICE_EXP (4)
///////////////////////////////////////////////////////////////////
// Structures and enumerations
typedef struct _ExportVDBPersist ExportVDBPersist;
///////////////////////////////////////////////////////////////////
// Global variables
///////////////////////////////////////////////////////////////////
// Function prototypes
ExportVDBPersist * NewExportVDBPersist (char const * szFilename, int nResolution, VisPersist * psVisData);
void DeleteExportVDBPersist (ExportVDBPersist * psExportVDBData);
void FilledCuboidSliceVDB (unsigned char * pcData, int nResolution, int nChannels, Vector3 * avCorners, float fZSlice);
bool ExportStartVDB (LongPollPersist * psLongPollData, void * psData);
bool ExportStepVDB (LongPollPersist * psLongPollData, void * psData);
bool ExportFinishVDB (LongPollPersist * psLongPollData, void * psData);
bool ExportCancelVDB (LongPollPersist * psLongPollData, void * psData);
///////////////////////////////////////////////////////////////////
// Function definitions
#endif /* EXPORTVDB_H */
///////////////////////////////////////////////////////////////////
// Enzyme
// 3D Functy/Dandelion/programming game
//
// Provides access to the LEAP API in C (via the C++ library)
//
// David Llewellyn-Jones
//
// December 2013
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Includes
#include <stdlib.h>
#include <openvdb/openvdb.h>
#include <openvdb/tools/LevelSetUtil.h>
extern "C" {
#include "ovdbc.h"
} /* extern "C" */
#include <glib.h>
using namespace std;
///////////////////////////////////////////////////////////////////
// Defines
///////////////////////////////////////////////////////////////////
// Structures and enumerations
struct _OVDBCPersist {
openvdb::FloatGrid::Ptr psGrid;
GString * szOutfile;
openvdb::FloatGrid::Accessor sAccessor;
};
///////////////////////////////////////////////////////////////////
// Global variables
///////////////////////////////////////////////////////////////////
// Function prototypes
///////////////////////////////////////////////////////////////////
// Function definitions
extern "C" {
OVDBCPersist * NewOVDBCPersist (char const * szOutfile) {
OVDBCPersist * psOVDBCData;
psOVDBCData = g_new0 (OVDBCPersist, 1);
openvdb::initialize ();
psOVDBCData->psGrid = openvdb::FloatGrid::create (2.0);
g_string_assign (psOVDBCData->szOutfile, szOutfile);
psOVDBCData->sAccessor = psOVDBCData->psGrid.getAccessor();
return psOVDBCData;
}
void DeleteOVDBCPersist (OVDBCPersist * psOVDBCData) {
psOVDBCData->psGrid->setTransform (openvdb::math::Transform::createLinearTransform (0.5));
psOVDBCData->psGrid->setGridClass (openvdb::GRID_FOG_VOLUME);
psOVDBCData->psGrid->setName ("LevelSetSVX");
openvdb::io::File file (psOVDBCData->szOutfile->str);
openvdb::GridPtrVec psGrids;
psGrids.push_back (psOVDBCData->psGrid);
//openvdb::tools::sdfToFogVolume<openvdb::FloatGrid>(grid.operator*());
file.write (psGrids);
file.close ();
if (psOVDBCData->szOutfile) {
g_string_free (psOVDBCData->szOutfile, TRUE);
}
g_free (psOVDBCData);
}
void SetGridValue (Vector3 const * const pvPos, OVDBCPersist * psOVDBCData) {
psOVDBCData->sAccessor.setValue (*vPos, 1.0);
}
} /* extern "C" */
///////////////////////////////////////////////////////////////////
// Enzyme
// 3D Functy/Dandelion/programming game
//
// Provides access to the LEAP API in C (via the C++ library)
//
// David Llewellyn-Jones
//
// December 2013
///////////////////////////////////////////////////////////////////
#ifndef OVDBC_H
#define OVDBC_H
///////////////////////////////////////////////////////////////////
// Includes
///////////////////////////////////////////////////////////////////
// Defines
///////////////////////////////////////////////////////////////////
// Structures and enumerations
typedef struct _OVDBCPersist OVDBCPersist;
///////////////////////////////////////////////////////////////////
// Global variables
///////////////////////////////////////////////////////////////////
// Function prototypes
///////////////////////////////////////////////////////////////////
// Function definitions
OVDBCPersist * NewOVDBCPersist (char const * szOutfile);
void DeleteOVDBCPersist (OVDBCPersist * psOVDBCData);
void SetGridValue (Vector3 const * const pvPos, OVDBCPersist * psOVDBCData);
#endif /* OVDBC_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment