Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1036

My fight with quaternions

$
0
0

So, I've been trying to write a script to create and eventually animate complex geometrical objects. I did this in MaxScript for 3D Studio Max years ago, and I want to explore further using Daz (cannot afford 3DS)!

The basic idea is to create a list of vertices which I create as spheres - great, that part works. Then a list of connection information for the edges of thje objects which I create a cylinder at the origin of one of the verrtices (spheres) of the right length and then rotate it so that the other end matches the other vertex (sphere). This is the relevant bit of code for the rotation:

var vecNewEndPoint = new DzVec3( dx, dy, dz );

var quatNewRot = vecEndPoint.getRotationTo( vecNewEndPoint );

oNode.setLocalRot( quatNewRot );

Works great about 75% of the time. The other 25% of the time, it exactly reverses the direction (see image). If I go into those reversed cylinders and change the Z-rotation to 180 or if I switch the origin point with the target point, the problem is solved. However, I cannot predict when it will happen.

I'm super new to Daz scripting. Any ideas?

Thanks for any help or direction!

 


Viewing all articles
Browse latest Browse all 1036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>