|
JPBRT 0.5 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jpbrt.core.Shape
public abstract class Shape
Shape
represents a geometric primitive.
All shapes are defined in object coordinate space; for example, all spheres are defined in a coordinate system where the center of the sphere is at the origin. In order to place sphere at another position in the scene, a transformation that describes the mapping from object space to world space must be provided.
References:
M. Pharr, G. Humphreys. (2004). Physically Based Rendering. Morgan Kaufmann.
Page 90.
Field Summary | |
---|---|
Transform |
objectToWorld
Transformation from object to world space. |
boolean |
reverseOrientation
Indicates whether the surface normal directions should be reversed from the default. |
int |
shapeId
|
boolean |
transformSwapsHandedness
Caches the result of the Transform.swapsHandedness() call. |
Transform |
worldToObject
inverse of the transformation from object to world space. |
Constructor Summary | |
---|---|
Shape(Transform o2w,
Transform w2o,
boolean reverseOrientation)
Creates a new shape. |
Method Summary | |
---|---|
boolean |
canIntersect()
Returns true if the shape is intersectable. |
abstract float |
getArea()
This method may only be called with intersectable shapes. |
abstract BBox |
getObjectBounds()
Returns a bounding box in object coordinates. |
DifferentialGeometry |
getShadingGeometry(Transform obj2world,
DifferentialGeometry dg)
Some shapes (notably triangle meshes) support the idea of having two types of geometry at a point on the surface: the true geometry, which accurately reflects the local properties of the surface, and the shading geometry, which may have normals and tangents that are different than those in the true differential geometry. |
BBox |
getWorldBounds()
Returns a bounding box in world coordinates. |
abstract boolean |
intersect(Ray r,
float[] thit,
float[] rayEpsilon,
DifferentialGeometry dg)
Returns geometric information about the first ray-shape intersection, if any, in the [mint,maxt] parametric range along the ray. |
abstract boolean |
intersectP(Ray ray)
Determines whether the ray intersects with the shape without returning any details about the intersection itself. |
float |
pdf(Point Pshape)
Takes a point on the surface of the shape and returns the value of the corresponding Probability Distribution Function. |
float |
pdf(Point p,
Vector wi)
Given a point on the surface p and direction wi , the method
determines the probability that the shape would have chosen the direction
wi . |
void |
refine(java.util.List<Shape> r)
If a shape can not be intersected directly, it must provide a refine method which splits the shape into a group of new shapes, some of which may be intersectable and some of which may need further refinement. |
Point |
sample(float u1,
float u2,
Normal Ns)
Chooses a point on the surface using some sampling distribution with respect to surface area on the shape and returns its position and writes its normal in the output variable Ns . |
Point |
sample(Point P,
float u1,
float u2,
Normal Ns)
Chooses a point on the surface visible from the given surface point P using some sampling distribution function, returns its position
and writes its normal in the output variable Ns . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Transform objectToWorld
public Transform worldToObject
public boolean reverseOrientation
public boolean transformSwapsHandedness
Transform.swapsHandedness()
call.
This value is needed by the DifferentialGeometry
constructor
that will be called each time a ray intersection is found.
public int shapeId
Constructor Detail |
---|
public Shape(Transform o2w, Transform w2o, boolean reverseOrientation)
o2w
- Object-to-world transformation.reverseOrientation
- Whether surface normals should be reversed.Method Detail |
---|
public BBox getWorldBounds()
public abstract BBox getObjectBounds()
public boolean canIntersect()
Not every shape needs to capable of determining whether a ray intersects it. For example, a complex surfce might first be tesselated into triangles, which can then be intersected directly. Another possibility is a shape that is a placeholder for a larger amount of geometry that is stored on disk.
The default implementation returns true, so that only shapes which are non-intersectable need to override this method.
public abstract boolean intersectP(Ray ray)
public abstract boolean intersect(Ray r, float[] thit, float[] rayEpsilon, DifferentialGeometry dg)
r
- The ray used for intersection testing.thit
- Output parameter (array of length one) which stores the
distance from the origin of the ray to the intersection.dg
- Information about the local geometry is stored here if an
intersection was found.
public void refine(java.util.List<Shape> r)
The default implementation throws an InternalError; thus shapes that are intersectable (which is the common case) do not have to provide an empty instance of this method.
r
- public DifferentialGeometry getShadingGeometry(Transform obj2world, DifferentialGeometry dg)
Implementations which return a new differential geometry object must use the provided object-to-world transformation rather than their own in order to support multiple object instancing in a scene.
The default implementation of this method returns the passed in differential geometry object.
public abstract float getArea()
public Point sample(float u1, float u2, Normal Ns)
Ns
.
This method takes two uniform random numbers in the range (0,1) which are used to select the point on the surface area. In almost all cases the shape will sample uniformly by area on its surface.
Note: The implementation in this class throws
UnsupportedOperationException
.
References: pbrt-v2, page 716.
u1
- Uniform random number 1.u2
- Uniform random number 2.Ns
- The normal of the selected point.
public float pdf(Point Pshape)
Note: The implementation in this class returns the reciprocal of the surface area.
Pshape
- A point on the surface of the shape.
public Point sample(Point P, float u1, float u2, Normal Ns)
P
using some sampling distribution function, returns its position
and writes its normal in the output variable Ns
.
Only the portion of the shape is sampled that is potentially visible from
the given point P
. This is particularly useful for lighting,
since the caller can pass in the point to be lit.
This method takes two uniform random numbers in the range (0,1) which are used to select the point on the surface area.
Note: The implementation in this class ignores the given point P
and just calls method sample(float,float,Normal)
.
References: pbrt-v2, page 716.
P
- The point from which the surface of the shape is being integrated
over.u1
- Uniform random number 1.u2
- Uniform random number 2.Ns
- The normal of the selected point.
public float pdf(Point p, Vector wi)
p
and direction wi
, the method
determines the probability that the shape would have chosen the direction
wi
.
The method determines if the ray (p
, wi
) intersects the
shape. If the ray doesn't intersect the shape at all, the probability
that the shape would have chosen the direction wi
can be assumed
to be zero.
References: pbrt-v2, page 717.
p
- wi
-
|
Copyright 2010 © by the authors and contributors of the JPBRT project. Some rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |