XJRT Rendering Toolkit 1.0b06

org.autochthonous.graphics.rt.objects
Class Patch

java.lang.Object
  extended byorg.autochthonous.graphics.rt.Renderable
      extended byorg.autochthonous.graphics.rt.Bounded
          extended byorg.autochthonous.graphics.rt.objects.Patch
All Implemented Interfaces:
java.lang.Cloneable, 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.autochthonous.graphics.rt.Bounded
bBox
 
Fields inherited from class org.autochthonous.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.autochthonous.graphics.rt.objects.Patch.SubNode subdivide(org.autochthonous.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.autochthonous.graphics.rt.Bounded
bBox, setBBox, setBBox
 
Methods inherited from class org.autochthonous.graphics.rt.Renderable
clone, createObjectSpaceRay, getColor, getColor, getShader, hasShader, isSelfShadowing, processParameters, setColor, setColor, setSelfShadowing, setShader, toObjectSpace, toObjectSpace, transformNormal
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.autochthonous.graphics.rt.Traceable
clone
 

Field Detail

BEZIER

public static final java.lang.String BEZIER
See Also:
Constant Field Values

CARDINAL

public static final java.lang.String CARDINAL
See Also:
Constant Field Values

B_SPLINE

public static final java.lang.String B_SPLINE
See Also:
Constant Field Values
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)
Specified by:
isIntersected in interface Traceable
Specified by:
isIntersected in class Bounded

intersections

public HitList intersections(Ray r)
Specified by:
intersections in interface Traceable

isShadowing

public boolean isShadowing(Ray r)
Specified by:
isShadowing in interface Traceable
Specified by:
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.autochthonous.graphics.rt.objects.Patch.SubNode subdivide(org.autochthonous.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
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
Throws:
java.io.IOException

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)

XJRT Rendering Toolkit 1.0b06