Simplex3D Integration

0 views
Skip to first unread message

Hicks, Matt

unread,
Jun 28, 2010, 7:04:13 PM6/28/10
to sgin...@googlegroups.com
Sending this to the mailing list just so everyone else can be in the loop.

Lex, if you could port over math.Ray and math.mutable.Ray to using Simplex3D that would be a good example for me to use to know how to make some other changes to the system.  Also, render.Renderer would be appreciated if you get to it.  I'm finding it difficult to exactly what the best replacements are for some of the current classes and was hoping you'd be able to give recommendations.

Thanks

Lex

unread,
Jun 28, 2010, 9:11:53 PM6/28/10
to sgine-dev
Here is a direct port of immutable.Ray:

{{{
import simplex3d.math.doublem._
import simplex3d.math.doublem.DoubleMath._

class Ray protected(val origin: Vec3d, val direction: Vec3d) {
def pointAtDistance(d: Double) = Vec3d(
origin.x + (direction.x * d),
origin.y + (direction.y * d),
origin.z + (direction.z * d)
)

def transform(m: inMat3x4d) = new Ray(
m.transformPoint(origin),
normalize(m.transformVector(direction))
)

// Not sure what this does
def translate() :Vec3d = {
val t = -origin.z / direction.z
Vec3d(
origin.x + direction.x * t,
origin.y + direction.y * t,
origin.z + direction.z * t
)
}

override def toString() =
"Ray(origin=" + origin + ", direction=" + direction + ")"
}

object Ray {
def apply(origin: Vec3d, direction: Vec3d) = new Ray(origin,
direction)
}
}}}

I will think more about a smoother way to integrate the two API,
meanwhile I hope it helps you a little.

On Jun 28, 7:04 pm, "Hicks, Matt" <mhi...@captiveimagination.com>
wrote:

Hicks, Matt

unread,
Jun 28, 2010, 10:04:08 PM6/28/10
to sgin...@googlegroups.com
Great, that was extremely helpful.  I've committed that along with some changes to mutable.Ray but I'm not sure what the alternative is to this:

        matrix.transformLocal(origin)
        matrix.transformLocal(direction, 0.0).normalize()

If you look at mutable.Ray.transform you can see that it's supposed to apply locally to the Ray like the immutable Ray does creating new origin and direction vectors.

BTW, if you want access to commit to the repo just let me know...it might make this a bit easier than you having to send code to me via e-mail?

Hicks, Matt

unread,
Jun 29, 2010, 6:23:34 PM6/29/10
to sgin...@googlegroups.com
Lex, if you could take a look at Renderer it would be helpful.  I've got much of the engine compiling now but there doesn't seem to be an easy way to do some of the things I'm trying to do in Renderer.

Lex

unread,
Jun 30, 2010, 12:33:17 AM6/30/10
to sgine-dev
The org.sgine.render.Renderer does not have comments and I am not sure
what some methods do. Like translateLocal - what are the x and y
arguments and what exactly gets translated. And most importantly, why
is it synchronized.
We should discuss it online, so I can get a better understanding of
the renderer or simply adress your problems directly.

On Jun 29, 6:23 pm, "Hicks, Matt" <mhi...@captiveimagination.com>
Reply all
Reply to author
Forward
0 new messages