vpSetVoxelSize(3)
β¨ vpSetVoxelSize(3) β¨
okay bestie, welcome to the VolPack library functions manual, and today's main character is vpSetVoxelSize π
πΈ NAME πΈ
vpSetVoxelSize β define the size of a voxel
π¦ SYNOPSIS π¦
#include <volpack.h>
vpResult
vpSetVoxelSize(vpc, bytes_per_voxel, num_voxel_fields, num_shade_fields,
num_classify_fields)
vpContext *vpc;
int bytes_per_voxel;
int num_voxel_fields;
int num_shade_fields;
int num_classify_fields;
π ARGUMENTS π
vpcβ the VolPack context, aka the one you got fromvpCreateContext.bytes_per_voxelβ how big one voxel is, in bytes. that's it, that's the size.num_voxel_fieldsβ how many fields live inside a voxel.num_shade_fieldsβ how many of those voxel fields get passed as arguments to the shading function.num_classify_fieldsβ how many voxel fields get passed as arguments to the opacity transfer function.
π DESCRIPTION π
so vpSetVoxelSize is literally here to define the size in bytes and the number of fields in a voxel. think of each voxel field like a field in a C struct β the contents of each one is user-defined, so you're the boss of what goes in there, no cap.
for setting the size and offset of each individual field, you want the vpSetVoxelField function (vpSetVoxelField(3)). and order matters, bestie: vpSetVoxelSize should be called before vpSetVoxelField and before any functions that access the contents of a voxel. do not skip the queue π
typically, some of the voxel fields get used as arguments to a shading function, and some of them β possibly the same ones β get used as arguments to an opacity transfer function (that's the classification part). the fields used for shading should come first, i.e. they should have the smallest offsets, followed by any fields that are only used for classification. why? because then the classification fields can be stripped off to save space during the precomputation stage for the fast rendering algorithm. the num_shade_fields parameter tells you the number of fields (starting from the first) that must not be stripped off. periodt.
the parameter num_clsfy_fields indicates the total number of fields that are used as parameters to the opacity transfer function. these fields don't necessarily have to be contiguous, although any fields that aren't also used for shading should be the last fields in the voxel. the way that layout saves you space is genuinely iconic β¨
β οΈ heads up: if the call to vpSetVoxelSize succeeds, any existing precomputed volume data structures in the context are destroyed. gone. bye. so know what you're doing π
β STATE VARIABLES β
you can grab the current voxel size parameters with these state variable codes (peep vpGeti(3) for the how-to): VP_BYTES_PER_VOXEL, VP_VOXEL_FIELD_COUNT, VP_SHADE_FIELD_COUNT, VP_CLASSIFY_FIELD_COUNT.
π ERRORS π
the normal return value is VP_OK. the following error return values are possible:
VPERROR_LIMIT_EXCEEDEDβ the number of voxel fields exceeds the implementation limit. you can raise this limit by editingvolpack.hand recompiling the library, so it's giving "fixable but effort" π«ΆVPERROR_BAD_VALUEβ eithernum_clsfy_fieldsornum_shade_fieldsis out of range.
π SEE ALSO π
VolPack(3), vpCreateContext(3), vpSetVoxelField(3)
and that's the whole vibe check, bestie π this was vpSetVoxelSize(3) from the VolPack manual β no date on the original page, so we're keeping it timeless, and the source is just VolPack itself. slay, go set some voxel sizes ππ¦
π¦ where this page comes from
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- Copyright (c) 1995-2008, Stanford University
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms