-
Notifications
You must be signed in to change notification settings - Fork 12
Extending the RenderingState class
An extended RenderingState object should contain all information to render a frame. The base class already stores information about the spatial 3D transformation of an object. Additionally, it keeps references to 2 (in the base class uninitialized) arrays: channelproperties and nonchannelproperties. The extending class should initialize and fill these arrays with required parameters.
Assuming that a very simple 3rd party rendering engine is used which renders a 3D object based on a single parameter, say brightness. Typically, the extending class would first define a static final constant with the index into the nonchannelproperties array:
public static final int BRIGHTNESS = 0;The constructor would initialize the nonchannelproperties array:
public ExtRenderingState(int frame, CombinedTransform fwdTransform) {
super(frame, fwdTransform);
nonChannelProperties = new double[1];
channelProperties = null;
}
public ExtRenderingState(
int frame,
double brightness,
CombinedTransform fwdTransform) {
this(frame, fwdTransform);
nonChannelProperties[BRIGHTNESS] = brightness;
}Finally, the clone() method needs to be overridden:
@Override
public ExtRenderingState clone() {
ExtRenderingState kf = new ExtRenderingState(0, null);
kf.setFrom(this);
return kf;
}