本文整理汇总了C++中JObject::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ JObject::SetName方法的具体用法?C++ JObject::SetName怎么用?C++ JObject::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JObject
的用法示例。
在下文中一共展示了JObject::SetName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetEditorsGroup
JObject* JBoundsEditor::GetEditorsGroup()
{
JObject* pEditors = g_pObjectServer->FindObject( "editors", this );
if (pEditors == NULL)
{
pEditors = new JGroup();
AddChild( pEditors );
pEditors->SetName( "editors" );
}
return pEditors;
}
示例2: FnCreate
int JLuaServer::FnCreate( lua_State* pLua )
{
int nParam = lua_gettop( pLua );
if (nParam < 1 || nParam > 3)
{
rlog.err( "LUA: Incorrect command usage: <create>. "
"Must be: create( <className or fileName> | <templateObject>, [<newName>, <parentObject>] )" );
lua_settop( pLua, 0 );
lua_pushnil( pLua );
return 1;
}
// first parameter
const char* pClassName = lua_tostring( pLua, 1 );
JObject* pTemplateObj = NULL;
if (!pClassName)
{
pTemplateObj = (JObject*)lua_touserdata( pLua, 1 );
}
// second parameter
const char* pObjName = lua_tostring( pLua, 2 );
// third parameter
JObject* pParentObj = NULL;
if (nParam > 2)
{
pParentObj = (JObject*)lua_touserdata( pLua, 3 );
}
else
{
JLuaThread* pThread = reinterpret_cast<JLuaThread*>( pLua->userdata );
assert( pThread->m_pLua == pLua );
pParentObj = pThread->m_pRootObj;
}
JObject* pObj = NULL;
if (pClassName)
{
pObj = g_pObjectServer->Create( pClassName );
// try to load from script
if (pObj == NULL)
{
pObj = g_pPersistServer->LoadObject( pClassName );
}
if (pObj == NULL)
{
rlog.err( "LUA: Cannot create an object because of unknown class (or filename): %s", pClassName );
lua_settop( pLua, 0 );
lua_pushnil( pLua );
return 1;
}
if (pObjName)
{
pObj->SetName( pObjName );
}
}
else if (pTemplateObj)
{
pObj = pTemplateObj->Clone( pParentObj, pObjName );
}
if (pParentObj)
{
pParentObj->AddChild( pObj );
}
lua_settop( pLua, 0 );
lua_pushlightuserdata( pLua, pObj );
return 1;
} // JLuaServer::FnCreate
示例3: ProcessPhysicsObject
//.........这里部分代码省略.........
IParamArray* pParam = pObj->GetParamBlock();
IParamBlock* pParamBlock = NULL;
if (pParam) pParamBlock = pParam->GetParamBlock();
if (!stricmp( className, "sphere" ))
{
ColSphere* pSphere = new ColSphere();
pPhysObj = pSphere;
float radius = 0.0f;
pParamBlock->GetValue( SPHERE_RADIUS, 0, radius, FOREVER );
pSphere->SetRadius( radius );
pSphere->SetHost( hostName.c_str() );
pSphere->SetOffsetTM( objTM );
}
if (!stricmp( className, "box" ))
{
ColBox* pBox = new ColBox();
pPhysObj = pBox;
Vec3 ext;
pParamBlock->GetValue( BOXOBJ_LENGTH, 0, ext.x, FOREVER );
pParamBlock->GetValue( BOXOBJ_WIDTH, 0, ext.y, FOREVER );
pParamBlock->GetValue( BOXOBJ_HEIGHT, 0, ext.z, FOREVER );
pBox->SetExtents( ext );
pBox->SetHost( hostName.c_str() );
pBox->SetOffsetTM( objTM );
}
if (!stricmp( className, "capsule" ))
{
ColCapsule* pCapsule = new ColCapsule();
pPhysObj = pCapsule;
int bCenters = 0;
float radius = 0.0f;
float height = 0.0f;
pParamBlock->GetValue( PB_RADIUS, 0, radius, FOREVER );
pParamBlock->GetValue( PB_HEIGHT, 0, height, FOREVER );
pParamBlock->GetValue( PB_CENTERS, 0, bCenters, FOREVER );
pCapsule->SetRadius( radius );
pCapsule->SetHeight( height );
pCapsule->SetHost( hostName.c_str() );
pCapsule->SetOffsetTM( objTM );
}
if (!stricmp( className, "cylinder" ))
{
ColCylinder* pCylinder = new ColCylinder();
pPhysObj = pCylinder;
int bCenters = 0;
float radius = 0.0f;
float height = 0.0f;
pParamBlock->GetValue( PB_RADIUS, 0, radius, FOREVER );
pParamBlock->GetValue( PB_HEIGHT, 0, height, FOREVER );
pParamBlock->GetValue( PB_CENTERS, 0, bCenters, FOREVER );
pCylinder->SetRadius( radius );
pCylinder->SetHeight( height );
pCylinder->SetHost( hostName.c_str() );
pCylinder->SetOffsetTM( objTM );
}
if (!stricmp( className, "teapot" ))
{
// by teapot we represent physical body (point of mass)
PhysBody* pBody = new PhysBody();
pBody->SetHostBone( hostName.c_str() );
pPhysObj = pBody;
pBody->SetOffsetTM( objTM );
}
// if none of above, try to export as trimesh collision primitive
if (pPhysObj == NULL && scID == GEOMOBJECT_CLASS_ID)
{
ColMesh* pMesh = GetColMesh( node );
if (pMesh)
{
pPhysObj = pMesh;
pMesh->SetHost( hostName.c_str() );
pMesh->SetOffsetTM( objTM );
}
}
}
if (pPhysObj)
{
if (!m_pPhysicsGroup)
{
m_pPhysicsGroup = new JGroup();
m_pPhysicsGroup->SetName( "physics" );
}
pPhysObj->SetName( pNodeName );
m_pPhysicsGroup->AddChild( pPhysObj );
}
else
{
Warn( "Unrecognized physics object type in node %s", pNodeName );
return NULL;
}
return pPhysObj;
} // RBExport::ProcessPhysicsObject