Examples/DSO Examples

From PixieWiki

Jump to: navigation, search

Please add your example DSO files here.

[edit] Implicit Surfaces

Pixie supports raytraced implicit surfaces via the RiGeometry binding. The .cpp file below shows how to create an implicit sphere DSO in Pixie.

Media:GSHimplicit.cpp

Media:GSHimplicit.rib

The .cpp file should be compiled as follows. The exact flags to create a shared library on your platform will vary, replace -dynamiclib with -shared or similar. You may also have to use malloc.h instead of stdlib.h. You should also replace the output file extensions with something relevant for your platform (eg. replace .dylib with .so for linux).

On OSX:

g++ -dynamiclib -o GSHimplicit.dylib GSHimplicit.cpp

or for linux:

g++ -shared -o GSHimplicit.so GSHimplicit.cpp

or for VC6 on Windows:

I've had some reports that you may need to rename the file to be a .c file.

cl -LD GSHimplicit.c

The resulting dso will need to be in Pixie's procedural search path, for ease, keep it in the same directory as the rib file. You will also need to edit the rib file to have the correct shared object extension for your platform.

Notes: Implicit surfaces don't displace. The surface parameterizations you might expect do not exist unless you supply them.

Requests: Could someone please elaborate on this topic and provide more concrete details. For example, please provide more detailed and explicit instructions for compiling DSOs with VC++ or DEV-CPP for the novice. Then please remove this request.

[edit] DSOs with VC++7

Building the example DSOs using the MSVC++ IDE is fairly simple.

  • Create a new project with File->New Project...
    • On the left side of the dialog box, under Project Types, choose Visual C++ Projects->Win32.
    • On the right side, under Templates, choose Win32 Console Project.
    • Fill in your project name (the example here uses "TestDSO") and the project location.
    • The Win32 Application Wizard should open. Click on Application Settings on the left side.
      • Choose DLL as the Application Type.
      • Select the "Empty project" choice and hit OK.
  • In your new Project, right-click on Source Files to add a new C++ source file.
  • Add the contents of Media:GSHimplicit.cpp to your source file. You'll need to make a couple of minor changes to get it to compile:
    • Change each instance of "EXTERN" to "EXPORT" in the file.
    • Add "EXPORT" in front of each of the forward declarations, so it should like:
   EXPORT void *implicitInit(int frame,float *bmin,float *bmax);
   EXPORT float implicitEval(float *dF,void *data,const float *point,float rayTime);
   EXPORT void implicitEvalNormal(float *dF,void *data,const float *point,float rayTime);
   EXPORT void implicitTini(void *data);
  • You should be able to build (Ctrl-Shift-B) the project with zero errors or warnings.
  • The resulting DLL file, ''TestDSO.dll'', can be found in /Debug directory underneath your project directory. Move it to the directory with Media:GSHimplicit.rib
  • You should be able to run the rib file with rndr GSHimplicit.rib from within your rib directory.

[edit] Procedural DSOs

See http://www.affine.org/menger.html for an example of DSO code. I've tested this with Pixie and discovered that the detail level with Pixie is always 0. This probably needs correcting, but for now, just be aware.