I tried to get into using Pixie through its C interface (the long term plan is to use the interface through JNA and embed Pixie as a renderer in Moonlight|3D). However, I managed to crash Pixie with a rather minimal example and cannot say what I'm doing wrong. I'm using Pixie 2.2.2 (provided through a Gentoo ebuild). The complete code for the program is:
RiFormat(640, 480, 1);
RiDisplayV("test.tif", RI_FRAMEBUFFER, RI_RGB, 0, NULL, NULL);
RiDisplayV("+test.tif", RI_FILE, RI_RGB, 0, NULL, NULL);
RiSurfaceV(RI_CONSTANT, 0, NULL, NULL);
RiTranslate(0, 0, 1);
RiSphereV(0.3f, -0.3f, 0.3f, 360.0f, 0, NULL, NULL);
RiLightSourceV("ambientlight", 0, NULL, NULL);
The program crashes within the RiPerspective call. Not passing the fov parameter makes it work. Passing an equivalent scene to rndr works fine. Is there anything obvious that I might be doing wrong? I am unfortunately a complete newbie when it comes to using Renderman compatibles.
That's because you haven't terminated the token-value list passed to RiProjection() with a RI_NULL (I presume that was what you meant because your code doesn't contain any RiPerspective() calls and it shouldn't as this is not commonly used to define a viewing transformation for the image).
Any Ri..() call that accepts a token-value list needs to end with RI_NULL. Or you could use the vector Ri..V() version (which btw. works great with STL vector<>).
So this is not a Pixie issue but a PEBKAC one. ;)
Note that it is advisable to use RI_NULL instead of NULL, to terminate token value lists in the RI.
This is because the former will work correctly on 64 bit systems as well.
At least this is the case for PRMan & 3Delight -- I just presume Pixie works the same way (doing a comparison with RI_NULL to find the end of the list). RI_NULL might be different from NULL, depending on architecture, compiler & OS.
I just noticed you terminate the other token-value Ri..() calls with two NULLs. Maybe that is a symptom of you already using a 64bit platform to compiler? :)
One RI_NULL should be enough.
Ignore my last comment.
I looked again and noticed that you use the Ri..V() versions.
Here, too though, you should use RI_NULL, RI_NULL to terminate the list, to be 64bit savvy although I guess if the number of tokens is 0, the pointers shouldn't even be touched by the function. :)
Most people just use the token-value version, if no additional tokens are passed, i.e.:
RiSurfaceV( RI_CONSTANT, 0, RI_NULL, RI_NULL );
RiSurface( RI_CONSTANT, RI_NULL );
Thank you for the list of replies! I was actually expecting this to be user a simple error. As I said, I'm getting starting with the Renderman interface.
And you are right: I wrote RiPerspective instead of RiProjection because this function constantly reminds me of gluPerspecitve (OpenGL is just a little bit too similar to RI :-) ). I noticed it too late to fix the post, though.
However, I changed the line
and the crash still happens. This is the gdb backtrace that I keep getting:
#0 0x00007f2b50cc4452 in CRendererContext::RiProjectionV () from /usr/lib/libri.so.0
#1 0x00007f2b50ce9bdd in RiProjection () from /usr/lib/libri.so.0
#2 0x0000000000400dd9 in main ()
When I deliberately misspell the fov parameter I get the following program output:
Invalid perspective projection parameter (fo).
Invalid perspective projection parameter ().
The program still crashes inside the same function, but now inside a call to strcmp() (sorry, don't have line number information right now).
I'd love to see this turn out as a user error on my part (less work for everybody), but I'm still at a loss...
I forgot, there's another issue: token-value pairs need to be passed as pointers both.
So your code should look like this:
RtFloat fov = 30;
Sorry for missing this in my first reply. :)
This fixed it for me. The value needs to be passed as a pointer. Now it also works when I call it from Java. Thanks!
If anybody is interested, I can release the Java wrapper that I'm using.
There are btw. two projects on SF, Affogato & LiquidMaya, whose source should provide a rich source of how-to's, if you are binding a RMan renderer to a 3D modeling/animation app.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.