diff --git a/sceneview/src/main/java/io/github/sceneview/node/CubeNode.kt b/sceneview/src/main/java/io/github/sceneview/node/CubeNode.kt index 705b6d6e..a2fbf68e 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/CubeNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/CubeNode.kt @@ -12,10 +12,6 @@ open class CubeNode( engine: Engine, size: Size = Cube.DEFAULT_SIZE, center: Position = Cube.DEFAULT_CENTER, - /** - * Binds a material instance to all primitives. - */ - materialInstance: MaterialInstance? = null, /** * Binds a material instance to the specified primitive. * @@ -25,7 +21,7 @@ open class CubeNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance? = { materialInstance }, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -43,11 +39,30 @@ open class CubeNode( .size(size) .center(center) .build(engine), - materialInstance = materialInstance, materialInstances = materialInstances, parent = parent, renderableApply = renderableApply ) { + + constructor( + engine: Engine, + size: Size = Cube.DEFAULT_SIZE, + center: Position = Cube.DEFAULT_CENTER, + /** + * Binds a material instance to all primitives. + */ + materialInstance: MaterialInstance?, + parent: Node? = null, + renderableApply: RenderableManager.Builder.() -> Unit = {} + ) : this( + engine = engine, + size = size, + center = center, + materialInstances = { materialInstance }, + parent = parent, + renderableApply = renderableApply + ) + val center get() = geometry.center val size get() = geometry.size diff --git a/sceneview/src/main/java/io/github/sceneview/node/CylinderNode.kt b/sceneview/src/main/java/io/github/sceneview/node/CylinderNode.kt index d1fc975f..d8e9c5c8 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/CylinderNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/CylinderNode.kt @@ -9,14 +9,10 @@ import io.github.sceneview.math.Position open class CylinderNode( engine: Engine, - radius: Float, - height: Float, - center: Position, - sideCount: Int, - /** - * Binds a material instance to all primitives. - */ - materialInstance: MaterialInstance? = null, + radius: Float = Cylinder.DEFAULT_RADIUS, + height: Float = Cylinder.DEFAULT_HEIGHT, + center: Position = Cylinder.DEFAULT_CENTER, + sideCount: Int = Cylinder.DEFAULT_SIDE_COUNT, /** * Binds a material instance to the specified primitive. * @@ -26,7 +22,7 @@ open class CylinderNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance? = { materialInstance }, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -46,11 +42,34 @@ open class CylinderNode( .center(center) .sideCount(sideCount) .build(engine), - materialInstance = materialInstance, materialInstances = materialInstances, parent = parent, renderableApply = renderableApply ) { + + constructor( + engine: Engine, + radius: Float = Cylinder.DEFAULT_RADIUS, + height: Float = Cylinder.DEFAULT_HEIGHT, + center: Position = Cylinder.DEFAULT_CENTER, + sideCount: Int = Cylinder.DEFAULT_SIDE_COUNT, + /** + * Binds a material instance to all primitives. + */ + materialInstance: MaterialInstance?, + parent: Node? = null, + renderableApply: RenderableManager.Builder.() -> Unit = {} + ) : this( + engine = engine, + radius = radius, + height = height, + center = center, + sideCount = sideCount, + materialInstances = { materialInstance }, + parent = parent, + renderableApply = renderableApply + ) + val radius get() = geometry.radius val height get() = geometry.height val center get() = geometry.center diff --git a/sceneview/src/main/java/io/github/sceneview/node/GeometryNode.kt b/sceneview/src/main/java/io/github/sceneview/node/GeometryNode.kt index d99b7c2c..9bed94dd 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/GeometryNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/GeometryNode.kt @@ -36,10 +36,6 @@ open class GeometryNode( engine: Engine, vertices: List = listOf(), submeshes: List = listOf(), - /** - * Binds a material instance to all primitives. - */ - materialInstance: MaterialInstance? = null, /** * Binds a material instance to the specified primitive. * @@ -49,7 +45,7 @@ open class GeometryNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance? = { materialInstance }, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -67,12 +63,30 @@ open class GeometryNode( .vertices(vertices) .submeshes(submeshes) .build(engine), - materialInstance = materialInstance, materialInstances = materialInstances, parent = parent, renderableApply = renderableApply ) { - val vertexBuffer get() = geometry.vertexBuffer + + constructor( + engine: Engine, + vertices: List = listOf(), + submeshes: List = listOf(), + /** + * Binds a material instance to all primitives. + */ + materialInstance: MaterialInstance?, + parent: Node? = null, + renderableApply: RenderableManager.Builder.() -> Unit = {} + ) : this( + engine = engine, + vertices = vertices, + submeshes = submeshes, + materialInstances = { materialInstance }, + parent = parent, + renderableApply = renderableApply + ) + val indexBuffer get() = geometry.indexBuffer fun setVertices(vertices: List) = geometry.setVertices(vertices) @@ -82,10 +96,6 @@ open class GeometryNode( open class BaseGeometryNode( engine: Engine, val geometry: T, - /** - * Binds a material instance to all primitives. - */ - materialInstance: MaterialInstance? = null, /** * Binds a material instance to the specified primitive. * @@ -95,7 +105,7 @@ open class BaseGeometryNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance? = { materialInstance }, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -109,6 +119,23 @@ open class BaseGeometryNode( renderableApply: RenderableManager.Builder.() -> Unit = {} ) : RenderableNode(engine = engine, parent = parent) { + constructor( + engine: Engine, + geometry: T, + /** + * Binds a material instance to all primitives. + */ + materialInstance: MaterialInstance?, + parent: Node? = null, + renderableApply: RenderableManager.Builder.() -> Unit = {} + ) : this( + engine = engine, + geometry = geometry, + materialInstances = { materialInstance }, + parent = parent, + renderableApply = renderableApply + ) + init { RenderableManager.Builder(geometry.submeshes.size) .geometry(geometry) diff --git a/sceneview/src/main/java/io/github/sceneview/node/PlaneNode.kt b/sceneview/src/main/java/io/github/sceneview/node/PlaneNode.kt index 12501b68..b2b9fa2c 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/PlaneNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/PlaneNode.kt @@ -14,10 +14,6 @@ open class PlaneNode( size: Size = Plane.DEFAULT_SIZE, center: Position = Plane.DEFAULT_CENTER, normal: Direction = Plane.DEFAULT_NORMAL, - /** - * Binds a material instance to all primitives. - */ - materialInstance: MaterialInstance? = null, /** * Binds a material instance to the specified primitive. * @@ -27,7 +23,7 @@ open class PlaneNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance? = { materialInstance }, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -46,11 +42,32 @@ open class PlaneNode( .center(center) .normal(normal) .build(engine), - materialInstance = materialInstance, materialInstances = materialInstances, parent = parent, renderableApply = renderableApply ) { + + constructor( + engine: Engine, + size: Size = Plane.DEFAULT_SIZE, + center: Position = Plane.DEFAULT_CENTER, + normal: Direction = Plane.DEFAULT_NORMAL, + /** + * Binds a material instance to all primitives. + */ + materialInstance: MaterialInstance?, + parent: Node? = null, + renderableApply: RenderableManager.Builder.() -> Unit = {} + ) : this( + engine = engine, + size = size, + center = center, + normal = normal, + materialInstances = { materialInstance }, + parent = parent, + renderableApply = renderableApply + ) + val size get() = geometry.size val center get() = geometry.center val normal get() = geometry.normal diff --git a/sceneview/src/main/java/io/github/sceneview/node/SphereNode.kt b/sceneview/src/main/java/io/github/sceneview/node/SphereNode.kt index 15f3eeea..052421ad 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/SphereNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/SphereNode.kt @@ -9,14 +9,10 @@ import io.github.sceneview.math.Position open class SphereNode( engine: Engine, - radius: Float, - center: Position, - stacks: Int, - slices: Int, - /** - * Binds a material instance to all primitives. - */ - materialInstance: MaterialInstance? = null, + radius: Float = Sphere.DEFAULT_RADIUS, + center: Position = Sphere.DEFAULT_CENTER, + stacks: Int = Sphere.DEFAULT_STACKS, + slices: Int = Sphere.DEFAULT_SLICES, /** * Binds a material instance to the specified primitive. * @@ -26,7 +22,7 @@ open class SphereNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance? = { materialInstance }, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -46,11 +42,34 @@ open class SphereNode( .stacks(stacks) .slices(slices) .build(engine), - materialInstance = materialInstance, materialInstances = materialInstances, parent = parent, renderableApply = renderableApply ) { + + constructor( + engine: Engine, + radius: Float = Sphere.DEFAULT_RADIUS, + center: Position = Sphere.DEFAULT_CENTER, + stacks: Int = Sphere.DEFAULT_STACKS, + slices: Int = Sphere.DEFAULT_SLICES, + /** + * Binds a material instance to all primitives. + */ + materialInstance: MaterialInstance?, + parent: Node? = null, + renderableApply: RenderableManager.Builder.() -> Unit = {} + ) : this( + engine = engine, + radius = radius, + center = center, + stacks = stacks, + slices = slices, + materialInstances = { materialInstance }, + parent = parent, + renderableApply = renderableApply + ) + val radius get() = geometry.radius val center get() = geometry.center val stacks get() = geometry.stacks