Hi,
I am new to generating PTC and currently only have access to
3Delight 7.0.0
I have written the following but the viewer displays what looks like
a single point but re****ted it has read in 32768 points from the file.
Could someone comment if this is the way to generate PTC file? I am
hoping to create some volume rendering like renders using this
approach.
8<------8<------8<------8<------8<------8<------8<------8<------
#include <pointcloud.h>
#include <string>
#include <vector>
#include <iostream>
int main()
{
PtcPointCloud ptc;
const char *filename = "nicholas.ptc";
const int nvars = 1;
const char vartype0[] = "color";
const char *vartypes[nvars] = {vartype0};
const char varname0[] = "volcolor";
const char *varnames[nvars] = {varname0};
float world2eye[] = {1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1};
float world2ndc[] = {1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1};
float format[] = {256,256,1};
ptc = PtcCreatePointCloudFile ( filename,
nvars,
vartypes,
varnames,
world2eye,
world2ndc,
format );
int writeStatus;
float point[] = {0,0,0};
float normal[] = {0,0,1};
float radius = 2;
float data[] = {1,1,1};
const size_t nWidth = 32;
const size_t nHeight = 32;
const size_t nDepth = 32;
const float volumeCubeSize = 100.0f;
const float widthDelta = volumeCubeSize / (nWidth - 1);
const float heightDelta = volumeCubeSize / (nHeight - 1);
const float depthDelta = volumeCubeSize / (nDepth - 1);
const float startWidth = -volumeCubeSize * 0.5;
const float startHeight = -volumeCubeSize * 0.5;
const float startDepth = -volumeCubeSize * 0.5;
for (size_t i = 0 ; i < nWidth ; i++)
{
for (size_t j = 0 ; j < nHeight ; j++)
{
for (size_t k = 0 ; k < nDepth ; k++)
{
float x = startWidth + i * widthDelta;
float y = startHeight + j * heightDelta;
float z = startDepth + k * depthDelta;
printf("point is [%f,%f,%f]\n",x,y,z);
point[0] = x;
point[1] = y;
point[2] = z;
writeStatus = PtcWriteDataPoint ( ptc,
point,
normal,
radius,
data );
if (writeStatus != 1)
std::cerr << "Failed to write data point" << std::endl;
}
}
}
PtcFinishPointCloudFile(ptc);
return 0;
}
Regards


|