api.cpp File Reference

#include "stdafx.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <malloc.h>
#include <alloca.h>
#include <assert.h>
#include <algorithm>
#include "pbrt.h"
#include <pthread.h>
#include <semaphore.h>
#include "parallel.h"
#include "geometry.h"
#include "spectrum.h"
#include <map>
#include "transform.h"
#include "memory.h"
#include "primitive.h"
#include "probes.h"
#include "shape.h"
#include "rng.h"
#include "material.h"
#include "renderer.h"
#include "integrator.h"
#include "accelerators/bvh.h"
#include "accelerators/grid.h"
#include "accelerators/kdtreeaccel.h"
#include "cameras/environment.h"
#include "cameras/orthographic.h"
#include "cameras/perspective.h"
#include "film.h"
#include "sampler.h"
#include "paramset.h"
#include "filter.h"
#include "kdtree.h"
#include "scene.h"
#include "volume.h"
#include "light.h"
#include "texture.h"
#include "mipmap.h"
#include "reflection.h"
#include "renderers/surfacepoints.h"

Go to the source code of this file.

Classes

struct  TransformSet
struct  RenderOptions
struct  GraphicsState
class  TransformCache

Defines

#define MAX_TRANSFORMS   2
#define START_TRANSFORM_BITS   (1 << 0)
#define END_TRANSFORM_BITS   (1 << 1)
#define ALL_TRANSFORMS_BITS   ((1 << MAX_TRANSFORMS) - 1)
#define STATE_UNINITIALIZED   0
#define STATE_OPTIONS_BLOCK   1
#define STATE_WORLD_BLOCK   2
#define VERIFY_INITIALIZED(func)
#define VERIFY_OPTIONS(func)
#define VERIFY_WORLD(func)
#define FOR_ACTIVE_TRANSFORMS(expr)
#define WARN_IF_ANIMATED_TRANSFORM(func)

Functions

Reference< ShapeMakeShape (const string &name, const Transform *object2world, const Transform *world2object, bool reverseOrientation, const ParamSet &paramSet)
Reference< MaterialMakeMaterial (const string &name, const Transform &mtl2world, const TextureParams &mp)
Reference< Texture< float > > MakeFloatTexture (const string &name, const Transform &tex2world, const TextureParams &tp)
Reference< Texture< Spectrum > > MakeSpectrumTexture (const string &name, const Transform &tex2world, const TextureParams &tp)
LightMakeLight (const string &name, const Transform &light2world, const ParamSet &paramSet)
AreaLightMakeAreaLight (const string &name, const Transform &light2world, const ParamSet &paramSet, const Reference< Shape > &shape)
VolumeRegionMakeVolumeRegion (const string &name, const Transform &volume2world, const ParamSet &paramSet)
SurfaceIntegratorMakeSurfaceIntegrator (const string &name, const ParamSet &paramSet)
VolumeIntegratorMakeVolumeIntegrator (const string &name, const ParamSet &paramSet)
PrimitiveMakeAccelerator (const string &name, const vector< Reference< Primitive > > &prims, const ParamSet &paramSet)
CameraMakeCamera (const string &name, const ParamSet &paramSet, const TransformSet &cam2worldSet, float transformStart, float transformEnd, Film *film)
SamplerMakeSampler (const string &name, const ParamSet &paramSet, const Film *film, const Camera *camera)
FilterMakeFilter (const string &name, const ParamSet &paramSet)
FilmMakeFilm (const string &name, const ParamSet &paramSet, Filter *filter)
void pbrtInit (const Options &opt)
void pbrtCleanup ()
void pbrtIdentity ()
void pbrtTranslate (float dx, float dy, float dz)
void pbrtTransform (float tr[16])
void pbrtConcatTransform (float tr[16])
void pbrtRotate (float angle, float dx, float dy, float dz)
void pbrtScale (float sx, float sy, float sz)
void pbrtLookAt (float ex, float ey, float ez, float lx, float ly, float lz, float ux, float uy, float uz)
void pbrtCoordinateSystem (const string &name)
void pbrtCoordSysTransform (const string &name)
void pbrtActiveTransformAll ()
void pbrtActiveTransformEndTime ()
void pbrtActiveTransformStartTime ()
void pbrtTransformTimes (float start, float end)
void pbrtPixelFilter (const string &name, const ParamSet &params)
void pbrtFilm (const string &type, const ParamSet &params)
void pbrtSampler (const string &name, const ParamSet &params)
void pbrtAccelerator (const string &name, const ParamSet &params)
void pbrtSurfaceIntegrator (const string &name, const ParamSet &params)
void pbrtVolumeIntegrator (const string &name, const ParamSet &params)
void pbrtRenderer (const string &name, const ParamSet &params)
void pbrtCamera (const string &name, const ParamSet &params)
void pbrtWorldBegin ()
void pbrtAttributeBegin ()
void pbrtAttributeEnd ()
void pbrtTransformBegin ()
void pbrtTransformEnd ()
void pbrtTexture (const string &name, const string &type, const string &texname, const ParamSet &params)
void pbrtMaterial (const string &name, const ParamSet &params)
void pbrtMakeNamedMaterial (const string &name, const ParamSet &params)
void pbrtNamedMaterial (const string &name)
void pbrtLightSource (const string &name, const ParamSet &params)
void pbrtAreaLightSource (const string &name, const ParamSet &params)
void pbrtShape (const string &name, const ParamSet &params)
void pbrtReverseOrientation ()
void pbrtVolume (const string &name, const ParamSet &params)
void pbrtObjectBegin (const string &name)
void pbrtObjectEnd ()
void pbrtObjectInstance (const string &name)
void pbrtWorldEnd ()

Variables

Options PbrtOptions
static int currentApiState = STATE_UNINITIALIZED
static TransformSet curTransform
static int activeTransformBits = ALL_TRANSFORMS_BITS
static map< string, TransformSetnamedCoordinateSystems
static RenderOptionsrenderOptions = NULL
static GraphicsState graphicsState
static vector< GraphicsStatepushedGraphicsStates
static vector< TransformSetpushedTransforms
static vector< uint32_t > pushedActiveTransformBits
static TransformCache transformCache

Define Documentation

#define ALL_TRANSFORMS_BITS   ((1 << MAX_TRANSFORMS) - 1)

Definition at line 132 of file api.cpp.

Referenced by pbrtActiveTransformAll(), pbrtWorldBegin(), and pbrtWorldEnd().

#define END_TRANSFORM_BITS   (1 << 1)

Definition at line 131 of file api.cpp.

Referenced by pbrtActiveTransformEndTime().

#define FOR_ACTIVE_TRANSFORMS ( expr   ) 
Value:
for (int i = 0; i < MAX_TRANSFORMS; ++i) \
        if (activeTransformBits & (1 << i)) { expr }

Definition at line 298 of file api.cpp.

Referenced by pbrtConcatTransform(), pbrtIdentity(), pbrtLookAt(), pbrtRotate(), pbrtScale(), pbrtTransform(), and pbrtTranslate().

#define MAX_TRANSFORMS   2
#define START_TRANSFORM_BITS   (1 << 0)

Definition at line 130 of file api.cpp.

Referenced by pbrtActiveTransformStartTime().

#define STATE_OPTIONS_BLOCK   1

Definition at line 264 of file api.cpp.

Referenced by pbrtInit(), and pbrtWorldEnd().

#define STATE_UNINITIALIZED   0

Definition at line 263 of file api.cpp.

Referenced by pbrtCleanup(), and pbrtInit().

#define STATE_WORLD_BLOCK   2

Definition at line 265 of file api.cpp.

Referenced by pbrtCleanup(), and pbrtWorldBegin().

#define VERIFY_INITIALIZED ( func   ) 
Value:
if (currentApiState == STATE_UNINITIALIZED) { \
    Error("pbrtInit() must be before calling \"%s()\". " \
          "Ignoring.", func); \
    return; \
} else

Definition at line 278 of file api.cpp.

Referenced by pbrtConcatTransform(), pbrtCoordinateSystem(), pbrtCoordSysTransform(), pbrtIdentity(), pbrtLookAt(), pbrtRotate(), pbrtScale(), pbrtTransform(), and pbrtTranslate().

#define VERIFY_OPTIONS ( func   ) 
Value:
VERIFY_INITIALIZED(func); \
if (currentApiState == STATE_WORLD_BLOCK) { \
    Error("Options cannot be set inside world block; " \
          "\"%s\" not allowed.  Ignoring.", func); \
    return; \
} else

Definition at line 284 of file api.cpp.

Referenced by pbrtAccelerator(), pbrtCamera(), pbrtFilm(), pbrtPixelFilter(), pbrtRenderer(), pbrtSampler(), pbrtSurfaceIntegrator(), pbrtTransformTimes(), pbrtVolumeIntegrator(), and pbrtWorldBegin().

#define VERIFY_WORLD ( func   ) 
#define WARN_IF_ANIMATED_TRANSFORM ( func   ) 
Value:
do { if (curTransform.IsAnimated()) \
         Warning("Animated transformations set; ignoring for \"%s\"" \
                 "and using the start transform only", func); \
} while (false)

Definition at line 301 of file api.cpp.

Referenced by pbrtLightSource(), pbrtMakeNamedMaterial(), pbrtTexture(), and pbrtVolume().


Function Documentation

Primitive* MakeAccelerator ( const string &  name,
const vector< Reference< Primitive > > &  prims,
const ParamSet paramSet 
)
AreaLight* MakeAreaLight ( const string &  name,
const Transform light2world,
const ParamSet paramSet,
const Reference< Shape > &  shape 
)

Definition at line 493 of file api.cpp.

References CreateDiffuseAreaLight(), ParamSet::ReportUnused(), and Warning().

Referenced by pbrtShape().

Camera* MakeCamera ( const string &  name,
const ParamSet paramSet,
const TransformSet cam2worldSet,
float  transformStart,
float  transformEnd,
Film film 
)
Film* MakeFilm ( const string &  name,
const ParamSet paramSet,
Filter filter 
)

Definition at line 654 of file api.cpp.

References CreateImageFilm(), ParamSet::ReportUnused(), and Warning().

Referenced by RenderOptions::MakeCamera().

Filter* MakeFilter ( const string &  name,
const ParamSet paramSet 
)
Reference<Texture<float> > MakeFloatTexture ( const string &  name,
const Transform tex2world,
const TextureParams tp 
)
Light* MakeLight ( const string &  name,
const Transform light2world,
const ParamSet paramSet 
)
Reference<Material> MakeMaterial ( const string &  name,
const Transform mtl2world,
const TextureParams mp 
)
Sampler* MakeSampler ( const string &  name,
const ParamSet paramSet,
const Film film,
const Camera camera 
)
Reference<Shape> MakeShape ( const string &  name,
const Transform object2world,
const Transform world2object,
bool  reverseOrientation,
const ParamSet paramSet 
)
Reference<Texture<Spectrum> > MakeSpectrumTexture ( const string &  name,
const Transform tex2world,
const TextureParams tp 
)
SurfaceIntegrator* MakeSurfaceIntegrator ( const string &  name,
const ParamSet paramSet 
)
VolumeIntegrator* MakeVolumeIntegrator ( const string &  name,
const ParamSet paramSet 
)
VolumeRegion* MakeVolumeRegion ( const string &  name,
const Transform volume2world,
const ParamSet paramSet 
)
void pbrtAccelerator ( const string &  name,
const ParamSet params 
)
void pbrtActiveTransformAll (  ) 

Definition at line 766 of file api.cpp.

References activeTransformBits, and ALL_TRANSFORMS_BITS.

void pbrtActiveTransformEndTime (  ) 

Definition at line 771 of file api.cpp.

References activeTransformBits, and END_TRANSFORM_BITS.

void pbrtActiveTransformStartTime (  ) 

Definition at line 776 of file api.cpp.

References activeTransformBits, and START_TRANSFORM_BITS.

void pbrtAreaLightSource ( const string &  name,
const ParamSet params 
)

Definition at line 973 of file api.cpp.

References GraphicsState::areaLight, GraphicsState::areaLightParams, and VERIFY_WORLD.

void pbrtAttributeBegin (  ) 
void pbrtAttributeEnd (  ) 
void pbrtCamera ( const string &  name,
const ParamSet params 
)
void pbrtCleanup (  ) 

Definition at line 680 of file api.cpp.

References currentApiState, Error(), STATE_UNINITIALIZED, and STATE_WORLD_BLOCK.

Referenced by main().

void pbrtConcatTransform ( float  tr[16]  ) 

Definition at line 716 of file api.cpp.

References FOR_ACTIVE_TRANSFORMS, and VERIFY_INITIALIZED.

void pbrtCoordinateSystem ( const string &  name  ) 

Definition at line 749 of file api.cpp.

References namedCoordinateSystems, and VERIFY_INITIALIZED.

void pbrtCoordSysTransform ( const string &  name  ) 

Definition at line 755 of file api.cpp.

References namedCoordinateSystems, VERIFY_INITIALIZED, and Warning().

void pbrtFilm ( const string &  type,
const ParamSet params 
)

Definition at line 795 of file api.cpp.

References RenderOptions::FilmName, RenderOptions::FilmParams, and VERIFY_OPTIONS.

void pbrtIdentity (  ) 

Definition at line 693 of file api.cpp.

References FOR_ACTIVE_TRANSFORMS, and VERIFY_INITIALIZED.

void pbrtInit ( const Options opt  ) 

Definition at line 668 of file api.cpp.

References currentApiState, Error(), SampledSpectrum::Init(), STATE_OPTIONS_BLOCK, and STATE_UNINITIALIZED.

Referenced by main().

void pbrtLightSource ( const string &  name,
const ParamSet params 
)
void pbrtLookAt ( float  ex,
float  ey,
float  ez,
float  lx,
float  ly,
float  lz,
float  ux,
float  uy,
float  uz 
)

Definition at line 738 of file api.cpp.

References FOR_ACTIVE_TRANSFORMS, LookAt(), VERIFY_INITIALIZED, and Warning().

void pbrtMakeNamedMaterial ( const string &  name,
const ParamSet params 
)
void pbrtMaterial ( const string &  name,
const ParamSet params 
)
void pbrtNamedMaterial ( const string &  name  ) 

Definition at line 956 of file api.cpp.

References GraphicsState::currentNamedMaterial, and VERIFY_WORLD.

void pbrtObjectBegin ( const string &  name  ) 
void pbrtObjectEnd (  ) 

Definition at line 1096 of file api.cpp.

References RenderOptions::currentInstance, Error(), pbrtAttributeEnd(), and VERIFY_WORLD.

void pbrtObjectInstance ( const string &  name  ) 
void pbrtPixelFilter ( const string &  name,
const ParamSet params 
)

Definition at line 788 of file api.cpp.

References RenderOptions::FilterName, RenderOptions::FilterParams, and VERIFY_OPTIONS.

void pbrtRenderer ( const string &  name,
const ParamSet params 
)
void pbrtReverseOrientation (  ) 

Definition at line 1071 of file api.cpp.

References GraphicsState::reverseOrientation, and VERIFY_WORLD.

void pbrtRotate ( float  angle,
float  dx,
float  dy,
float  dz 
)

Definition at line 726 of file api.cpp.

References FOR_ACTIVE_TRANSFORMS, Rotate(), and VERIFY_INITIALIZED.

void pbrtSampler ( const string &  name,
const ParamSet params 
)

Definition at line 802 of file api.cpp.

References RenderOptions::SamplerName, RenderOptions::SamplerParams, and VERIFY_OPTIONS.

void pbrtScale ( float  sx,
float  sy,
float  sz 
)

Definition at line 732 of file api.cpp.

References FOR_ACTIVE_TRANSFORMS, Scale(), and VERIFY_INITIALIZED.

void pbrtShape ( const string &  name,
const ParamSet params 
)
void pbrtSurfaceIntegrator ( const string &  name,
const ParamSet params 
)
void pbrtTexture ( const string &  name,
const string &  type,
const string &  texname,
const ParamSet params 
)
void pbrtTransform ( float  tr[16]  ) 

Definition at line 706 of file api.cpp.

References FOR_ACTIVE_TRANSFORMS, and VERIFY_INITIALIZED.

void pbrtTransformBegin (  ) 
void pbrtTransformEnd (  ) 
void pbrtTransformTimes ( float  start,
float  end 
)
void pbrtTranslate ( float  dx,
float  dy,
float  dz 
)

Definition at line 699 of file api.cpp.

References FOR_ACTIVE_TRANSFORMS, Translate(), and VERIFY_INITIALIZED.

void pbrtVolume ( const string &  name,
const ParamSet params 
)
void pbrtVolumeIntegrator ( const string &  name,
const ParamSet params 
)
void pbrtWorldBegin (  ) 
void pbrtWorldEnd (  ) 

Variable Documentation

int activeTransformBits = ALL_TRANSFORMS_BITS [static]
int currentApiState = STATE_UNINITIALIZED [static]

Definition at line 266 of file api.cpp.

Referenced by pbrtCleanup(), pbrtInit(), pbrtWorldBegin(), and pbrtWorldEnd().

Definition at line 267 of file api.cpp.

Definition at line 271 of file api.cpp.

map<string, TransformSet> namedCoordinateSystems [static]
vector<uint32_t> pushedActiveTransformBits [static]

Definition at line 272 of file api.cpp.

Referenced by pbrtAttributeBegin(), pbrtAttributeEnd(), and pbrtWorldEnd().

vector<TransformSet> pushedTransforms [static]
RenderOptions* renderOptions = NULL [static]

Definition at line 270 of file api.cpp.

Definition at line 275 of file api.cpp.

Generated on Sat Aug 28 20:00:12 2010 for pbrt by  doxygen 1.6.3