Bouncy Castle Rendering Toolkit 1.0

org.bouncycastle.graphics.rt.objects
Class Patch

java.lang.Object
  |
  +--org.bouncycastle.graphics.rt.Renderable
        |
        +--org.bouncycastle.graphics.rt.Bounded
              |
              +--org.bouncycastle.graphics.rt.objects.Patch
All Implemented Interfaces:
ColorCalculator, NormalCalculator, Partitionable, Traceable

public class Patch
extends Bounded
implements NormalCalculator

A parametric bicubic surface.

A sample piece of RML for a patch:

      <Patch maxSubdivideLevel="6" basis="Bezier">
          <GeomX>
              1.400000, 1.337500, 1.437500, 1.500000,
              1.400000, 1.337500, 1.437500, 1.500000,
              0.784000, 0.749000, 0.805000, 0.840000,
              0.000000, 0.000000, 0.000000, 0.000000
          </GeomX>
          <GeomY>
              2.250000, 2.381250, 2.381250, 2.250000,
              2.250000, 2.381250, 2.381250, 2.250000,
              2.250000, 2.381250, 2.381250, 2.250000,
              2.250000, 2.381250, 2.381250, 2.250000
          </GeomY>
          <GeomZ>
              0.000000, 0.000000, 0.000000, 0.000000,
              0.784000, 0.749000, 0.805000, 0.840000,
              1.400000, 1.337500, 1.437500, 1.500000,
              1.400000, 1.337500, 1.437500, 1.500000
          </GeomZ>
      </Patch>
 


Field Summary
static java.lang.String B_SPLINE
           
static java.lang.String BEZIER
           
static java.lang.String CARDINAL
           
 
Fields inherited from class org.bouncycastle.graphics.rt.Bounded
bBox
 
Fields inherited from class org.bouncycastle.graphics.rt.Renderable
color, objToRay, rayToObj, selfShadowing, shader
 
Constructor Summary
Patch(java.lang.String basisName, int maxSubdivisionLevel, Matrix4f geomX, Matrix4f geomY, Matrix4f geomZ)
           
Patch(java.lang.String basisName, Matrix4f geomX, Matrix4f geomY, Matrix4f geomZ)
           
 
Method Summary
static Patch getInstance(RMLReader in)
           
 void getN(Hit hit, Vector3f n)
          returns the normal to the patch
protected  void init(java.lang.String basisName, int maxSubdivisionLevel, Matrix4f geomX, Matrix4f geomY, Matrix4f geomZ)
           
 HitList intersections(Ray r)
           
 boolean isIntersected(Ray r)
           
 boolean isShadowing(Ray r)
           
protected  void processObject(java.lang.Object obj)
           
protected  void readObject(RMLReader in)
          initialise a renderable object from a RMLReader.
 org.bouncycastle.graphics.rt.objects.Patch.SubNode subdivide(org.bouncycastle.graphics.rt.objects.Patch.SubNode root, Matrix4f geomX, Matrix4f geomY, Matrix4f geomZ, float minu, float maxu, float minv, float maxv, int maxsublevel, int level)
          void patchc(o, txt, l, n, pcol, type) object *o; texture *txt; vector *l, *n; pixel *pcol; int type; { int w, h, indx; tiletxt *tp; tp = txt->u.t; w = o->obj.pch->u * tp->scalew; h = o->obj.pch->v * tp->scaleh; indx = (w % tp->pixw + (h % tp->pixh) * tp->pixw) * 3; pcol->r = (unsigned char)tp->map[indx] / 255.0; pcol->g = (unsigned char)tp->map[indx + 1] / 255.0; pcol->b = (unsigned char)tp->map[indx + 2] / 255.0; }
 void transform(Matrix4f trans)
          apply the given 4x4 transform to the object.
 
Methods inherited from class org.bouncycastle.graphics.rt.Bounded
bBox, setBBox, setBBox
 
Methods inherited from class org.bouncycastle.graphics.rt.Renderable
createObjectSpaceRay, getColor, getColor, getShader, isSelfShadowing, processParameters, setColor, setColor, setSelfShadowing, setShader, toObjectSpace, toObjectSpace, transformNormal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEZIER

public static final java.lang.String BEZIER

CARDINAL

public static final java.lang.String CARDINAL

B_SPLINE

public static final java.lang.String B_SPLINE
Constructor Detail

Patch

public Patch(java.lang.String basisName,
             Matrix4f geomX,
             Matrix4f geomY,
             Matrix4f geomZ)

Patch

public Patch(java.lang.String basisName,
             int maxSubdivisionLevel,
             Matrix4f geomX,
             Matrix4f geomY,
             Matrix4f geomZ)
Method Detail

isIntersected

public boolean isIntersected(Ray r)
Overrides:
isIntersected in class Bounded

intersections

public HitList intersections(Ray r)

isShadowing

public boolean isShadowing(Ray r)
Overrides:
isShadowing in class Bounded

getN

public void getN(Hit hit,
                 Vector3f n)
returns the normal to the patch
Specified by:
getN in interface NormalCalculator

subdivide

public org.bouncycastle.graphics.rt.objects.Patch.SubNode subdivide(org.bouncycastle.graphics.rt.objects.Patch.SubNode root,
                                                                    Matrix4f geomX,
                                                                    Matrix4f geomY,
                                                                    Matrix4f geomZ,
                                                                    float minu,
                                                                    float maxu,
                                                                    float minv,
                                                                    float maxv,
                                                                    int maxsublevel,
                                                                    int level)
void patchc(o, txt, l, n, pcol, type) object *o; texture *txt; vector *l, *n; pixel *pcol; int type; { int w, h, indx; tiletxt *tp; tp = txt->u.t; w = o->obj.pch->u * tp->scalew; h = o->obj.pch->v * tp->scaleh; indx = (w % tp->pixw + (h % tp->pixh) * tp->pixw) * 3; pcol->r = (unsigned char)tp->map[indx] / 255.0; pcol->g = (unsigned char)tp->map[indx + 1] / 255.0; pcol->b = (unsigned char)tp->map[indx + 2] / 255.0; }

transform

public void transform(Matrix4f trans)
Description copied from class: Bounded
apply the given 4x4 transform to the object.
Overrides:
transform in class Bounded

getInstance

public static Patch getInstance(RMLReader in)
                         throws java.io.IOException

readObject

protected void readObject(RMLReader in)
                   throws java.io.IOException
Description copied from class: Renderable
initialise a renderable object from a RMLReader.
Overrides:
readObject in class Renderable

processObject

protected void processObject(java.lang.Object obj)
Overrides:
processObject in class Renderable

init

protected void init(java.lang.String basisName,
                    int maxSubdivisionLevel,
                    Matrix4f geomX,
                    Matrix4f geomY,
                    Matrix4f geomZ)

Bouncy Castle Rendering Toolkit 1.0