Last active
December 20, 2015 14:58
-
-
Save g-pechorin/6150354 to your computer and use it in GitHub Desktop.
Oh ... it does "print money"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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