Re: objects not connecting to right groups in custom operator

Date : Mon, 6 Nov 2006 08:26:12 +1100
To : XSI(at)Softimage.COM
From : "Aloys Baillet" <aloys.baillet(at)gmail.com>
Subject : Re: objects not connecting to right groups in custom operator
Yes indeed, you need one port by portgroup.
But I think I'm missing something in your set-up, I don't see why it wouldn't work!
You can send me your current code offline if you want.

Cheers,

Aloys

On 11/4/06, Mathieu Leclaire <mleclair(at)hybride.com> wrote:
OK, let me see if I understand correctly. Instead of creating 3 groups I should create 6 and connect the primitive and kinematics to different groups? I've tried that but it logs me this now:
 

//INFO : nb groups in Operator = 6

//INFO : nb ports in Group 0 = 2

//INFO : nb Instances in Group 0 = 1

//INFO : port 0 instance 0 is sphere.polymsh

//INFO : port 0 instance 1 is

//INFO : port 1 instance 0 is sphere.kine.global

//INFO : port 1 instance 1 is

//INFO : nb ports in Group 1 = 1

//INFO : nb Instances in Group 1 = 1

//INFO : port 0 instance 0 is

//INFO : nb ports in Group 2 = 1

//INFO : nb Instances in Group 2 = 1

//INFO : port 0 instance 0 is

//INFO : nb ports in Group 3 = 1

//INFO : nb Instances in Group 3 = 1

//INFO : port 0 instance 0 is

//INFO : nb ports in Group 4 = 1

//INFO : nb Instances in Group 4 = 1

//INFO : port 0 instance 0 is

//INFO : nb ports in Group 5 = 1

//INFO : nb Instances in Group 5 = 1

//INFO : port 0 instance 0 is

 

Am I still misunderstanding something? I don't understand why it still connects the primitive and kinamatic on the first group and doesn't connect the other groups. Something weird is happening and I can't figure out why.

-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM]On Behalf Of Aloys Baillet
Sent: Thursday, November 02, 2006 4:48 PM
To: XSI(at)Softimage.COM
Subject: Re: objects not connecting to right groups in custom operator

Hi Mathieu,

Bad news, SICO don't allow multiple ports on dynamic port groups.
I logged a bug to Softimage for this one (UDEV00226149).
It's actually a "documented" problem of the ConnectToGroup method:

Note: This method only works for Self-Installed Custom Operators if there is a single port inside the port group. This limitation exists because you can only pass a single object in the Object argument.

As a workaround, you can try using the UpdateConnectOnOp command, or split your portgroups so that you only have one dynamic port per port group.

I know, it's a pain! You can log it to the support as well so that someone takes care of it...

Cheers,

Aloys

On 11/3/06, Mathieu Leclaire <mleclair(at)hybride.com> wrote:
OK... here I am again a bit confused about Self-Installed Custom Operators.
Sorry for all the code but I need to show it to explain what I'm doing.
First I'll explain what I'm after. I need my operator to have access to the
geometry of at least 3 objects:

1 - The deforming object that will be deformed by the operator.
2 - The target object that is used to drive the deformed object.
3 - A list of obstacles.

So I'm trying to set-up 3 groups for each one of those components and pass
the primitive and global kinematics to the operator. Here is part of the
code when I try to assign the operator :


        CustomOperator newOp =
Application().GetFactory().CreateObject(L"test_SICO");
        assert( newOp.IsValid() ) ;
        newOp.PutDebug(0);

        // Create group 0 for the deformed mesh
        newOp.AddPortGroup( L"Group_0", 1, 1 );
        newOp.AddIOPortByClassID ( siPrimitiveID, L"IO_Geom", 0  ) ;
        newOp.AddInputPortByClassID( siKinematicStateID, L"In_Kine", 0  ) ;

        // Create group 1 for the target mesh
        newOp.AddPortGroup( L"Group_1", 1, 1 );
        newOp.AddInputPortByClassID( siPrimitiveID, L"In_Geom", 1  ) ;
        newOp.AddInputPortByClassID( siKinematicStateID, L"In_Kine", 1  ) ;

        // Obstable group will allow between 1 and 1000 objects
        newOp.AddPortGroup( L"Group_2", 1, 1000 );
        newOp.AddInputPortByClassID( siPrimitiveID, L"In_Geom", 2  ) ;
        newOp.AddInputPortByClassID( siKinematicStateID, L"In_Kine", 2  ) ;

        // Connection time
        long instance = 0;
        CStatus st;
        //primitive of deformed object to Group_0... deformedMeshX3D is an
X3DObject
        st = newOp.ConnectToGroup( 0 , (CRef)deformedMeshX3D.GetActivePrimitive(),
instance ) ;
        if ( st != CStatus::OK )
        {
                Application().LogMessage(L"error connecting primitive of deformed
object");
                return st;
        }
        //kinematics of deformed object to Group_0... deformedMeshX3D is an
X3DObject
        st = newOp.ConnectToGroup( 0 ,
(CRef)(deformedMeshX3D.GetKinematics().GetGlobal()), instance ) ;
        if ( st != CStatus::OK )
        {
                Application().LogMessage(L"error connecting kinematics of deformed
object");
                return st;
        }
        //primitive of target object to Group_1... targetMeshX3D is an X3DObject
        st = newOp.ConnectToGroup( 1 , (CRef)targetMeshX3D.GetActivePrimitive(),
instance ) ;
        if ( st != CStatus::OK )
        {
                Application().LogMessage(L"error connecting primitive of target object");
                return st;
        }
        //kinematics of target object to Group_1... targetMeshX3D is an X3DObject
        st = newOp.ConnectToGroup( 1 ,
(CRef)(targetMeshX3D.GetKinematics().GetGlobal()), instance ) ;
        if ( st != CStatus::OK )
        {
                Application().LogMessage(L"error connecting kinematics of target object");
                return st;
        }

        // Connect all the obstacles to Group_2
        for (long i=0; i<obstaclesCount; i++)
        {
                CRef tempRef(inObstacles[i]);
                if (!tempRef.IsValid() )
                {
                        // This wasn't a valid XSI object
                        newOp.Disconnect(false) ;       //Cleanup
                        return CStatus::InvalidArgument ;
                }
                X3DObject inObstacle(inObstacles[i]);
                Primitive obstaclePrim = inObstacle.GetActivePrimitive();

                CRef l_ref(obstaclePrim.GetRef());
                CStatus st( newOp.ConnectToGroup(  2, l_ref, instance ) );
                assert( st.Succeeded() ) ;
                //assert( instance == i ) ;

                KinematicState obstacleKine = inObstacle.GetKinematics().GetGlobal();

                CRef l_ref2(obstacleKine.GetRef());
                CStatus st2( newOp.ConnectToGroup(  2, l_ref2, instance ) );
                assert( st2.Succeeded() ) ;
                //assert( instance == i ) ;
        }


So this is how I'm connecting them but it gives me weird results... If I log
what's in the different groups and port inside the operators update callback
function:


XSIPLUGINCALLBACK CStatus test_SICO_Update( CRef& in_ctxt )
{
        OperatorContext ctxt( in_ctxt );
        Operator op(ctxt.GetSource());

        long nbPorts, nbInst, numGroup = op.GetNumPortGroups();

        Application().LogMessage(L"nb groups in Operator = "+CString(numGroup ));

        for (long ii=0; ii<numGroup; ii++){
                nbPorts = op.GetNumPortsInGroup(ii);
                nbInst = op.GetNumInstancesInGroup(ii);
                Application().LogMessage(L"nb ports in Group "+CString(ii)+L" =
"+CString(nbPorts));
                Application().LogMessage(L"nb Instances in Group "+CString(ii)+L" =
"+CString(nbInst));
                for (long jj=0; jj<nbPorts; jj++)
                        for (long kk=0; kk<nbPorts; kk++) {
                                SIObject objet = ctxt.GetInputValue( ii, jj, kk );
                                Application().LogMessage(L"port "+CString(jj)+L" instance
"+CString(kk)+L" is "+objet.GetFullName());
                        }
        }
        CRef output = ctxt.GetOutputTarget();
        return CStatus::OK;
}


here's what's being logged if the 3 objects attached are sphere (deformed
object), sphere1 (target object) and sphere2 (obstacles) :


//INFO : nb groups in Operator = 3
//INFO : nb ports in Group 0 = 3
//INFO : nb Instances in Group 0 = 2
//INFO : port 0 instance 0 is sphere.polymsh
//INFO : port 0 instance 1 is sphere.kine.global
//INFO : port 0 instance 2 is
//INFO : port 1 instance 0 is sphere1.polymsh
//INFO : port 1 instance 1 is sphere1.kine.global
//INFO : port 1 instance 2 is
//INFO : port 2 instance 0 is sphere2.polymsh
//INFO : port 2 instance 1 is sphere2.kine.global
//INFO : port 2 instance 2 is
//INFO : nb ports in Group 1 = 2
//INFO : nb Instances in Group 1 = 2
//INFO : port 0 instance 0 is sphere.polymsh
//INFO : port 0 instance 1 is sphere.kine.global
//INFO : port 1 instance 0 is sphere1.polymsh
//INFO : port 1 instance 1 is sphere1.kine.global
//INFO : nb ports in Group 2 = 2
//INFO : nb Instances in Group 2 = 2
//INFO : port 0 instance 0 is
//INFO : port 0 instance 1 is
//INFO : port 1 instance 0 is
//INFO : port 1 instance 1 is


...not only is the objects not connected to the right groups, but it
actually logs 3 times those parameters which shows that the operator is
called 3 times on each change of frame where only sphere's position is
animated. What am I doing wrong? Why are the connections not at the desired
group and ports?



Mathieu Leclaire
R&D Programmer
Hybride Technologies


====================================
"There's only one way you can fail, and that's to quit."

-- Brian Hays
====================================
Want to live a happy life and help make the world a better place? Come and
Play The Critical Mass Game:
http://www.criticalmassgame.com/?taf=cc875f0b




---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi



--
Aloys Baillet - XSI Technical Director
Character Dpt - Animal Logic
--



--
Aloys Baillet - XSI Technical Director
Character Dpt - Animal Logic
--

Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.