-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scenegraph visitor system for rendering and material overrides.
- Loading branch information
1 parent
32c6b2a
commit dfca2e4
Showing
13 changed files
with
221 additions
and
170 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module d4.scene.CollectPointsVisitor; | ||
|
||
import d4.math.Vector3; | ||
import d4.math.Matrix4; | ||
import d4.scene.ISceneVisitor; | ||
import d4.scene.Mesh; | ||
import d4.scene.Node; | ||
|
||
class CollectPointsVisitor : ISceneVisitor { | ||
public: | ||
this() { | ||
m_result = []; | ||
} | ||
|
||
void visitNode( Node node ) { | ||
m_currentWorldMatrix = node.worldMatrix(); | ||
} | ||
|
||
void visitMesh( Mesh mesh ) { | ||
foreach ( vertex; mesh.vertices ) { | ||
m_result ~= m_currentWorldMatrix.transformLinear( vertex.position ); | ||
} | ||
} | ||
|
||
Vector3[] result() { | ||
return m_result; | ||
} | ||
|
||
private: | ||
Vector3[] m_result; | ||
Matrix4 m_currentWorldMatrix; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module d4.scene.FixedMaterialRenderVisitor; | ||
|
||
import d4.renderer.IMaterial; | ||
import d4.renderer.Renderer; | ||
import d4.scene.ISceneVisitor; | ||
import d4.scene.Mesh; | ||
import d4.scene.Node; | ||
|
||
class FixedMaterialRenderVisitor : ISceneVisitor { | ||
public: | ||
this( Renderer renderer, IMaterial material ) { | ||
m_renderer = renderer; | ||
m_material = material; | ||
} | ||
|
||
void visitNode( Node node ) { | ||
m_renderer.worldMatrix = node.worldMatrix; | ||
} | ||
|
||
void visitMesh( Mesh mesh ) { | ||
m_renderer.activateMaterial( m_material ); | ||
m_renderer.renderTriangleList( mesh.vertices, mesh.indices ); | ||
} | ||
|
||
private: | ||
Renderer m_renderer; | ||
IMaterial m_material; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module d4.scene.ISceneElement; | ||
|
||
import d4.scene.ISceneVisitor; | ||
|
||
interface ISceneElement { | ||
void accept( ISceneVisitor visitor ); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module d4.scene.ISceneVisitor; | ||
|
||
import d4.scene.Mesh; | ||
import d4.scene.Node; | ||
|
||
interface ISceneVisitor { | ||
void visitMesh( Mesh mesh ); | ||
void visitNode( Node node ); | ||
} |
Oops, something went wrong.