-
What is the last argument "options" for SplintGen::generate()
Here's the definition for SplintGen::generate()
int generate(
double startDepth, // depth of top of 1st layer prior to rotation
double x, // x-component of vector perpendicular to splinter layers
double y, // y-component of vector perpendicular to splinter layers
double z, // z-component of vector perpendicular to splinter layers
int options);
Anyone has idea what the last argument means? My program keeps crashing in this function and I have no idea what's wrong. Thanks.
-
You can set that to _SG_OPT_ALLOW_NONCONVEX as defined in SplintGen.h.
-
Thanks. I'm still experiencing segmentation fault when generate() is called. Pretty sure I'm reading the pixel values correctly, so I'm thinking it's either something wrong with addLayer or generate(), but I had a hard time figuring out. Could you please take a look at this code? Maybe I'm packing the rgba to int incorrectly? Or any of my argument doesn't make sense? Thanks!
This is pretty much what I did:
// ........ read the pixels, and get xRes, yRes, channel size
Pixelux::SplintGen sGen;
sGen.initialize();
sGen.enableDiagnostics("/mcp/diag.txt");
int *texture = new int[xRes*yRes];
unsigned char r, g, b, a;
int offset = 0;
for (int y = 0; y < yRes; y++)
for (int x = 0; x < xRes; x++, offset++)
{
r = pixels[offset*channels];
g = pixels[offset*channels];
b = pixels[offset*channels];
a = 255;
//std::cout << std::setbase(10) << "\t\tpixel[" << x << "][" << y << "] = {" << r << ", " << g << ", " << b << ", " << a << "}" << std::endl;
int texel = 0x00 | r;
texel <<= 8;
texel += 0x00 | g;
texel <<= 8;
texel += 0x00 | b;
texel <<= 8;
texel += 0x00 | a;
//std::cout << "\t\ttexel = " << std::setbase(16) << texel << std::endl;
texture[offset] = texel;
}
int result = sGen.addLayer(
xRes, // width of the texture (in texels)
yRes, // height of the texture (in texels)
texture, // each 32-bit int is 1 texel (8 bits each of RGBA)
500, // the texture's full width in splinter space
500, // the texture's full height in splinter space
500, // thickness of this layer in splinter space
0, // x-coord of texture's left side in splntr space
0);
std::cout << "\taddLayer() = " << result << std::endl;
result = sGen.generate(
500, // depth of top of 1st layer prior to rotation
0, // x-component of vector perpendicular to splinter layers
0, // y-component of vector perpendicular to splinter layers
1, // z-component of vector perpendicular to splinter layers
SG_OPT_ALLOW_NONCONVEX); // ?? what does this option means
-
The weird thing is, if I just declare an instance of SplintGen and return, I get segmentation fault too.
int main(...)
{
SplintGen sGen;
return 0;
}
-
If I create an instance like this:
SplintGen *sGen = new SplintGen;
...
delete sGen;
The program will work correctly. So I think this is a bug in this class.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks