Notifications
Clear all

[Closed] transform alignment vs dir property

I’m trying to build a matrix mimicking what happens when a user sets the ‘.dir’ property for an object.

You’ll see in my test script below the Red point helpers do NOT seem to match the Green point helpers. The goal is to make them match by creating a matrix knowing just the up vector. What am I doing wrong here?

When you set the DIR property what is happening on the back end to the other two axis’s vectors, being the Font and Side vecs.


delete objects
clearlistener()

fn getSphereicalPts detail:1 = 
(
	local tmpGeo = createInstance GeoSphere baseType:2 segs:detail radius:10.0
	local tmpMesh = tmpGeo.mesh
	local numVerts = tmpMesh.numVerts
	local pts = for i = 1 to numVerts collect (getVert tmpMesh i)
	free tmpGeo
	free tmpMesh
	pts
)

fn getMatrixFromUpVec up pos = 
(
	local front = [1,0,0]
	local side = normalize (cross up front)
	local front = normalize (cross side up) -- orthogonalized up
	local tm = matrix3 front side up pos
	tm
)

fn distributeObj &pts =
(
	for p in pts do
	(
		local up = normalize p
		
		/* Method 1 */
		local cp = point size:2 axistripod:true wirecolor:green
		cp.dir = up
		cp.pos = p
		
		/* Method 2 */
		local tm = getMatrixFromUpVec up p
		point transform:tm size:1 axistripod:true wirecolor:red
	)
)

pts = getSphereicalPts()
distributeObj pts