Skip to content

Instantly share code, notes, and snippets.

@g-pechorin
Last active December 20, 2015 14:58
Show Gist options
  • Save g-pechorin/6150354 to your computer and use it in GitHub Desktop.
Save g-pechorin/6150354 to your computer and use it in GitHub Desktop.
Oh ... it does "print money"
sealed trait Function3D {
def apply(vec: Vector3): Float
override def toString = getClass.getSimpleName + ":" + parameterString
def encodeXML: Elem
/**
* Cheap trick to enforce toString
*/
def parameterString: String
}
trait AggregateFunction3D extends Function3D {
var children: List[Function3D]
override def encodeXML: Elem =
<function type={getClass.getName} parameters={parameterString}>
<children>
{children.map(_.encodeXML)}
</children>
</function>
}
trait LeafFunction3D extends Function3D {
override def encodeXML: Elem =
<function type={getClass.getName} parameters={parameterString}/>
}
trait ModifierFunction3D extends Function3D {
var input: Function3D = null
override def encodeXML: Elem =
<function type={getClass.getName} parameters={parameterString}>
<input>
{input.encodeXML}
</input>
</function>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment