<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Sonya, <br>
<br>
Usually you use an cosine-matrix for this. It allows to determine
the quaternion which translates one coordinate frame (i.e. 3
independent vectors) into another, but I think osg doesn't have
this.<br>
I think you can use the makeRotate by applying the resulting
quaternion to the vec3(0,0,1) and (1,0,0) and using the makeRotate
with the results somehow to get the inverse. <br>
<br>
Cheers<br>
Sebastian <br>
<blockquote cite="mid:DUB124-W52BBE6C1AEFC52F5E7E3A5C8970@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr"><font size="2" color="#000000">Dear All,</font>
<div><font size="2" color="#000000"><br>
</font></div>
<div><font size="2" color="#000000">I load a model with the
following code in my program, p1 and p2 are osg::Vec3 type
variables and simply representing</font></div>
<div><font size="2" color="#000000">the each ends of object in
spatial space ( I also use them to find the direction
vector). What I want to achive is: to place </font></div>
<div><font size="2" color="#000000">that model </font><font
size="2" color="#000000">up vector always aligned facing
upward ( this doesn't mean that it must coincidence/be
parallel with global </font></div>
<div><font size="2" color="#000000">Z axis) to achieve that If
I apply the quaternions then </font><span style="font-size:
10pt;">object is positioned with correct direction vector
(calulated via </span></div>
<div><span style="font-size: 10pt;">p1, p2) but rolled with
arbitrary angle along that direction </span><span
style="font-size: 10pt;">vector, which violates my
conditional goal.</span></div>
<div><span style="font-size: 10pt;"><br>
</span></div>
<div><span style="font-size: 10pt;">It also seems that it's not
a supprise that it produces that result bcoz nowhere I
specify the crucial right or up vector with </span></div>
<div><span style="font-size: 10pt;">quaternion which is required
to position the object in 3D space. So </span><span
style="font-size: 10pt;">How am I supposed to correct that
effect either with </span></div>
<div><span style="font-size: 10pt;">quaternions or matrices ? </span></div>
<div><font size="2" color="#000000"><br>
</font></div>
<div><font size="2" color="#000000">
<div> loadedModel =
osgDB::readNodeFile("quad.obj");</div>
<div> osg::Vec3Array* verlist=
static_cast<osg::Vec3Array*
>(rubber_line->getVertexArray());</div>
<div> osg::Vec3 p1 = (*verlist)[0];</div>
<div> osg::Vec3 p2 = (*verlist)[1];</div>
<div><br>
</div>
<div>
osg::ref_ptr<osg::PositionAttitudeTransform> Transf
= new osg::PositionAttitudeTransform;</div>
<div> Transf->setPosition( p1 );</div>
<div><br>
</div>
<div> osg::Quat quad;</div>
<div> osg::Matrix matrix, mat2;</div>
<div><br>
</div>
<div>
quad.makeRotate(osg::Vec3(0,1,0),p2-p1);</div>
<div><br>
</div>
<div><span style="font-size: 10pt;">
Transf->setAttitude(quad);</span></div>
<div> Transf->addChild(loadedModel);</div>
<div> rootnode->addChild(Transf);</div>
<div><br>
</div>
<div><br>
</div>
</font></div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
osg-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>
<a class="moz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a>
</pre>
</blockquote>
<br>
</body>
</html>