Re: [script] Comparing two transforms
| Date : Tue, 09 Jan 2007 17:39:18 -0500 |
| To : XSI(at)Softimage.COM |
| From : Joey Ponthieux <j.g.ponthieux(at)LaRC.NASA.GOV> |
| Subject : Re: [script] Comparing two transforms |
var oSphere = ActiveSceneRoot.FindChild( "Sphere" ); var oCube = ActiveSceneRoot.FindChild( "Cube" ); oCube.Kinematics.Local.Transform = oSphere.Kinematics.Local.Transform;
why can't you compare these two transform parameters with something like:
if (oCube.Kinematics.Local.Transform.IsEqualTo(oSphere.Kinematics.Local.Transform)) { LogMessage("Transforms match .......");
}
I've run into several things like this over the last year and can't help but wonder why such simple logical abilities in the scripting code seem to be missing, but I realize it's probably due to my lack of experience with XSI. Can't help but wonder though.....
Joey Ponthieux NCI Information Systems Inc. NASA Langley research Center ____________________________________________________________ Opinions stated here-in are strictly those of the author and do not represent the opinions of NASA or any other party.
guillaume laforge wrote:
Hi Bernard,
Maybe take a look to the matrix way. You can loop into the matrix to compare the values. It is a little bit shorter and maybe faster ?
function CompareMatrix( oObjA, oObjB ) { var oTransA = oObjA.Kinematics.Global.Transform; var oMatrixA = XSIMath.CreateMatrix4(); oTransA.GetMatrix4( oMatrixA );
var oTransB = oObjB.Kinematics.Global.Transform; var oMatrixB = XSIMath.CreateMatrix4(); oTransB.GetMatrix4( oMatrixB );
for ( var row = 0 ; row < 4 ; row++ )
{
for( var col = 0 ; col < 4 ; col++ )
{
if( Math.round( oMatrixA.Value( row, col ) ) != Math.round( oMatrixB.Value( row, col )) )
return false ;
}
}
return true ;
}
1/2
-- Guillaume Laforge freelance TD | cg Artist my blog ! http://vol2blog.blogspot.com/ <http://vol2blog.blogspot.com/>
On 1/9/07, *Bernard Lebel* <3dbernard(at)gmail.com <mailto:3dbernard(at)gmail.com>> wrote:
Salut Christopher ;-)
Thanks for the advice.
Right now I'm using a somewhat ugly but effective approach:
def compareTransforms( oTransform1, oTransform2 ):
"""
RETURN VALUE: boolean
"""
bSame = True
if round( oTransform1.PosX, 4 ) != round( oTransform2.PosX, 4 ):
bSame = False
elif round( oTransform1.PosY, 4 ) != round( oTransform2.PosY ,
4 ):
bSame = False
elif round( oTransform1.PosZ, 4 ) != round( oTransform2.PosZ, 4 ):
bSame = False
elif round( oTransform1.RotX, 4 ) != round( oTransform2.RotX, 4 ):
bSame = False
elif round( oTransform1.RotY, 4 ) != round( oTransform2.RotY, 4 ):
bSame = False
elif round( oTransform1.RotZ, 4 ) != round( oTransform2.RotZ ,
4 ):
bSame = False
elif round( oTransform1.SclX, 4 ) != round( oTransform2.SclX, 4 ):
bSame = False
elif round( oTransform1.SclY, 4 ) != round( oTransform2.SclY, 4 ):
bSame = False
elif round( oTransform1.SclZ, 4 ) != round( oTransform2.SclZ, 4 ):
bSame = False
#~ if not bSame:
#~ xsi.logmessage( '< bb_ReplaceModels > :: Not same
transforms.', c.siWarning )
#~ else:
#~ xsi.logmessage( ' < bb_ReplaceModels > :: Same
transforms.' )
return bSame
I wish there was a one-liner way to do this.
Bernard
On 1/9/07, Christopher Crouzet < christopher.crouzet(at)gmail.com
<mailto:christopher.crouzet(at)gmail.com>> wrote:
> A such function that compare two CTransformation objects exists
in the C++
> API.
>
> However, in scripting language I don't see anything equivalent
(in 5.1),
> except the 'Equals' method that applies on SIVector3 and SIQuaternion
> objects which means that you have to first extract them from the
> SITransformation object by using the 'GetRotation',
'GetTranslation' and
> 'GetScaling' methods.
>
>
> Hope it helps,
> Christopher.
>
> (wouhou, my first post on this list, hello everyone !!)
>
>
>
> On 1/9/07, Bernard Lebel < 3dbernard(at)gmail.com
<mailto:3dbernard(at)gmail.com>> wrote:
> >
> > Hello,
> >
> > Is there a quick way, say a one-liner, to determine if two
transforms
> > hold the same values?
> >
> > I have two objects, I just want to know if they have the same
> > transforms. If they do, then do something. If not, do something
else.
> >
> >
> > Thanks
> > Bernard
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM
<mailto:Majordomo(at)Softimage.COM> with the following text in body:
> > unsubscribe xsi
> >
>
>
--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi
- References:
- [script] Comparing two transforms
- From: "Bernard Lebel" <3dbernard(at)gmail.com>
- Re: [script] Comparing two transforms
- From: "Christopher Crouzet" <christopher.crouzet(at)gmail.com>
- Re: [script] Comparing two transforms
- From: "Bernard Lebel" <3dbernard(at)gmail.com>
- Re: [script] Comparing two transforms
- From: "guillaume laforge" <guillaume.laforge.3d(at)gmail.com>
- [script] Comparing two transforms
| DATE: | << | >> | THREAD: | << | >> | INDEX: | Main | Thread |
|---|
- Previous by Date: RE: 6.0 animation Layer Troubles
- Next by Date: RE: 6.0 animation Layer Troubles
- Previous by Thread: RE: 6.0 animation Layer Troubles
- Next by Thread: RE: 6.0 animation Layer Troubles
- Index(es):
| Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available. |