Game Development Community

Manual node transform doesn't update RESOLVED

by Robert Pinter · in Torque 3D Professional · 07/15/2012 (12:23 am) · 1 replies

Hi All,

I would like to achieve my own C++ class which controls the transforms of the Shape nodes by manual script and not by animation, and I have a serious problem to do that so I need a help.

So I have loaded some StaticShapes and I put them into SimSet.

Script parts

//Datablock  
    datablock StaticShapeData(AnimatedKnight)    
    {    
       category = "Knights"; // Your object will show up in the mission editor under "shapes/Misc"    
       className = "AnimatedShapes"; // Give this a discriptive name     
       //shapeFile = "art/shapes/Knight/Knight2.DAE"; //Path to your object    
       shapeFile = "art/shapes/actors/Soldier/soldier_rigged.DAE";  
       isPlaying = 0;  // Well....you want it to play don't you?? "0" = false    
    };    
      
      
    //Load Models  
      
    function LoadModels($numShape)  
    {  
      
    if ($numShape == 0)   
    {  
    echo ("You have to specify at least 1 number of model");  
    }  
    else  
    {  
        $MySet = new SimSet(MyShapes);  
          
        for (%objIndex = 0; %objIndex < $numShape; %objIndex++)  
            {  
                  
                %object = new StaticShape(Knight@%objIndex)    
                    {    
                    dataBlock = AnimatedKnight;  
                    position = ""@%objIndex + (%objIndex + 0.5) @ " 0.0 0.0";  
                    rotation = "0 0 1 180";  
                    };      
                      
                MissionCleanup.add(%object);  
                $MySet.add(%object);  
            }  
              
            %client = LocalClientConnection;  
            if ($numShape == 1)  
            {  
            %client.camera.setOrbitObject((Knight@($numShape-1)).getID(),""@mDegToRad(30) @" 0 0 ", 1, 5, 1.5);   
            }  
            else  
            {  
            %client.camera.setOrbitObject((Knight@(mCeil($numShape/2)-1)).getID(),""@mDegToRad(30) @" 0 0 ", 1, 5, 1.5);      
            }  
              
              
              
    }  
         
        
    }  
      
 
      
    /Here I have call a function and pass to the my C++ function.  
      
    function HandleModels()  
    {  
    Handle_Models(MyShapes);  
    }

C++ part

DefineEngineFunction(Handle_Models,void,(SimSet* ShapeArray),,"")  
    {  
          
              
        if ( ShapeArray->size() == 0 )  
     {  
         Con::warnf("No shape can be found in the SimSet");    
     }  
     else  
     {  
              
        for(SimSetIterator itr(ShapeArray); *itr; itr++)  
        {  
              
            ShapeBase *ShapeObj = dynamic_cast<ShapeBase*>(*itr);  
      
            S32 Bone_Count = ShapeObj->getShape()->nodes.size();  
      
                Con::printf("--------------------------------");  
                Con::printf("Shape Name: " "%s",ShapeObj->getName());  
                Con::printf("Joint count: %i",Bone_Count);  
                Con::printf("--------------------------------");  
                  
      
             //Write each Joint name to the console  
            for (int j = 0; j < Bone_Count; j++)  
            {  
              if ( ShapeObj->getShape()->nodes[j].parentIndex != -1)  
              {  
              const char *bname =ShapeObj->getShape()->getNodeName(j);  
              Con::printf("Bone Index: " "%i " "Bone Name: " "%s",j,bname);  
              //Set the nodes anumation state to hands off  
              ShapeObj->getShapeInstance()->setNodeAnimationState(j,TSShapeInstance::MaskNodeHandsOff);  
                  
                //do some change on the nodes  
              MatrixF mat;  
      
              mat.set(EulerF(0.2*j*10,0.1*j*20,0));  
                  
              ShapeObj->getShapeInstance()->mNodeTransforms[j].mul(mat);  
      
                ShapeObj->getShapeInstance()->setDirty(TSShapeInstance::TransformDirty);  
                ShapeObj->getShapeInstance()->animate();  
                  
                  
             }  
            }  
                              
            Idx++;  
          }   
      }

So the everything works fine until this point except after I change the nodetransforms and set the them to dirty and animate them, nothing happened.

I have dumped the transform matrixs and it seems to change all the time, but the shape doesn't move.

I have a feeling I'm animating the sub instance of the shape or I'm animating on server side and this is the reason why I don't see any update.

I have read all the post in regards animaton and node transform, but it didn't help.

Also I have dumped the player class and shape editor class, but I have no idea why doesn't work mine.

Do you have any idea what can be the problem and the solution?

#1
07/15/2012 (12:25 am)
I have found the solution,

When I pass the SimSet, it contains the server SimObject and not the client SimObject.

So actually I just have to store the SimObject what I can get by the.

objectname.getClientObject()

So everything works fine now.