コード例 #1
0
ファイル: charapp.cpp プロジェクト: garinh/planeshift
void psCharAppearance::ProcessAttach(csRef<iMeshWrapper> meshWrap, csRef<iSpriteCal3DSocket> socket)
{
    if(!socket.IsValid())
        return;
    CS_ASSERT(socket.IsValid());
    
    meshWrap->GetFlags().Set(CS_ENTITY_NODECAL);
    const char* socketName = socket->GetName();

    // Given a socket name of "righthand", we're looking for a key in the form of "socket_righthand"
    csString keyName = "socket_";
    keyName += socketName;

    // Variables for transform to be specified
    float trans_x = 0, trans_y = 0.0, trans_z = 0, rot_x = -PI/2, rot_y = 0, rot_z = 0;
    csRef<iObjectIterator> it = meshWrap->GetFactory()->QueryObject()->GetIterator();

    while ( it->HasNext() )
    {
        csRef<iKeyValuePair> key ( scfQueryInterface<iKeyValuePair> (it->Next()));
        if (key && keyName == key->GetKey())
        {
            sscanf(key->GetValue(),"%f,%f,%f,%f,%f,%f",&trans_x,&trans_y,&trans_z,&rot_x,&rot_y,&rot_z);
        }
    }

    meshWrap->QuerySceneNode()->SetParent( baseMesh->QuerySceneNode ());
    socket->SetMeshWrapper( meshWrap );
    socket->SetTransform( csTransform(csZRotMatrix3(rot_z)*csYRotMatrix3(rot_y)*csXRotMatrix3(rot_x), csVector3(trans_x,trans_y,trans_z)) );

    usedSlots.PushSmart(socketName);
}
コード例 #2
0
ファイル: pseffectlight.cpp プロジェクト: garinh/planeshift
unsigned int psLight::AttachLight(const char* name, const csVector3& pos,
  	float radius, const csColor& colour, csRef<iMeshWrapper> mw)
{
    baseColour = colour;
    csString lightName = name;
    lightName.Append("_%u", genUniqueID);
    light = engine->CreateLight(lightName, pos, radius, colour, CS_LIGHT_DYNAMICTYPE_DYNAMIC);
    light->SetAttenuationMode(CS_ATTN_INVERSE);

    // Attach to mesh.
    light->QuerySceneNode()->SetParent(mw->QuerySceneNode());

    csString sname(mw->GetMovable()->GetSectors()->Get(0)->QueryObject()->GetName());
    if(sname.Find("room") == 0)
    {
        // Add to the podium sector.
        podium = engine->GetSectors()->FindByName("room");
        if(podium.IsValid()) podium->GetLights()->Add(light);
    }

    lastTime = vclock->GetCurrentTicks();

    return ++genUniqueID;
}
コード例 #3
0
ファイル: charapp.cpp プロジェクト: garinh/planeshift
void psCharAppearance::ApplyRider(csRef<iMeshWrapper> mesh)
{
    csRef<iSpriteCal3DState> mountstate = scfQueryInterface<iSpriteCal3DState> (mesh->GetMeshObject());
    
    csRef<iSpriteCal3DSocket> socket = mountstate->FindSocket( "back" );
    
    if ( !socket )
    {
        Error1("Socket back not found.");
        return;
    }
    
    baseMesh->GetFlags().Set(CS_ENTITY_NODECAL);
    const char* socketName = socket->GetName();

    // Given a socket name of "righthand", we're looking for a key in the form of "socket_righthand"
    csString keyName = "socket_";
    keyName += socketName;

    // Variables for transform to be specified
    float trans_x = 0, trans_y = 0.0, trans_z = 0, rot_x = -PI/2, rot_y = 0, rot_z = 0;
    csRef<iObjectIterator> it = baseMesh->GetFactory()->QueryObject()->GetIterator();

    while ( it->HasNext() )
    {
        csRef<iKeyValuePair> key ( scfQueryInterface<iKeyValuePair> (it->Next()));
        if (key && keyName == key->GetKey())
        {
            sscanf(key->GetValue(),"%f,%f,%f,%f,%f,%f",&trans_x,&trans_y,&trans_z,&rot_x,&rot_y,&rot_z);
        }
    }

    baseMesh->QuerySceneNode()->SetParent( mesh->QuerySceneNode ());
    socket->SetMeshWrapper( baseMesh );
    socket->SetTransform( csTransform(csZRotMatrix3(rot_z)*csYRotMatrix3(rot_y)*csXRotMatrix3(rot_x), csVector3(trans_x,trans_y,trans_z)) );
}