void JBoundsEditor::CreateEditor( JObject* pEdited ) { JObject* pTemplates = g_pObjectServer->FindObject( "templates", this ); JObject* pEditors = GetEditorsGroup(); if (pTemplates == NULL || pEditors == NULL) { return; } int nTemplates = pTemplates->GetNChildren(); JString editorName; for (int i = 0; i < nTemplates; i++) { JWidget* pTemplate = obj_cast<JWidget>( pTemplates->GetChild( i ) ); if (pTemplate && is_a( pEdited, pTemplate->GetName() )) { // this object can be edited with this editor template editorName = pEdited->GetName(); editorName += "_"; editorName += pTemplate->GetName(); editorName += "_editor"; JObject* pEditor = pTemplate->Clone( pEditors, editorName.c_str(), true ); pEditors->AddChild( pEditor ); JBoundsEditContext ctx; ctx.m_pEdited = pEdited; ctx.m_pEditor = pEditor; pEdited->GetPath( ctx.m_Path ); m_Edited.push_back( ctx ); // parse property connections from text field JString propcfg( pTemplate->GetText() ); char* propConfig = (char*)propcfg.c_str(); while (propConfig && *propConfig != 0) { char* editedVal = propConfig; char* editorVal = propConfig + strcspn( propConfig, "<|" ); char& ch = *editorVal; if (ch == '|') { ch = 0; editorVal = "value"; } else if (ch == '<') { *editorVal = 0; editorVal++; propConfig = editorVal + strcspn( editorVal, "|" ); if (*propConfig == '|') { *propConfig = 0; propConfig++; } } else if (ch == 0) { propConfig = 0; editorVal = "value"; } g_pSignalServer->Connect( pEditor, editorVal, pEdited, editedVal ); g_pSignalServer->Connect( pEdited, editedVal, pEditor, editorVal ); pEdited->SendSignal( editedVal ); g_pSignalServer->Connect( pEdited, "visible", pEditor, "visible" ); pEdited->SendSignal( "visible" ); } } } }
void JListBox::AddString(JString str) { CListBox::AddString(str.c_str()); }
JObject* RBExport::ProcessPhysicsObject( INode* node ) { ObjectState os = node->EvalWorldState( m_CurTime ); Object* pObj = os.obj; const char* pNodeName = node->GetName(); if (!pObj) { Warn( "Physics node %s is invalid.", pNodeName ); } JObject* pPhysObj = NULL; Mat4 objTM = Convert( GetLocalTM( node, m_CurTime ) ); JString hostName = ""; ExpNode* pExportedParent = GetExportedNode( node->GetParentNode() ); if (pExportedParent && pExportedParent->m_pObject) { JObject* pParentObj = pExportedParent->m_pObject; if (obj_cast<PhysBody>( pParentObj )) { hostName = pParentObj->GetName(); } else if (obj_cast<JBone>( pParentObj )) { hostName = pParentObj->GetName(); } } // check for joint type DWORD scID = pObj->SuperClassID(); if (scID == HELPER_CLASS_ID) { PhysJoint* pJoint = new PhysJoint(); pJoint->SetHostBone( hostName.c_str() ); pPhysObj = pJoint; } else { CStr className; pObj->GetClassName( className ); 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
bool RBoot::Init( const CommandLine& cmd ) { import( rb_core ); JCore* m_pCore = new JCore(); m_pCore->SetName( "core" ); if (m_pCore != JCore::s_pInstance) { return false; } uint32_t hwnd = 0; const char* pHandle = cmd.GetValue( "window" ); if (pHandle) { sscanf( pHandle, "%d", &hwnd ); } import( rb_draw ); //import( rb_extui ); import( rb_particle ); ImportRenderLib(); import( rb_scene ); import( rb_script_lua ); //import( rb_sound ); //import( rb_texture ); import( rb_ui ); //import( rb_video ); //import( rb_physics ); link_class( ModelViewer ); link_class( TestDriver ); m_pCore->Init(); AddCommonMediaPath(); const char* scriptFile = cmd.GetValue( "script" ); JObject* pRoot = NULL; if (scriptFile) { // find script's media directory and add it AddScriptMediaPath( scriptFile ); // load script pRoot = g_pPersistServer->LoadObject( scriptFile ); } else { AddModuleMediaPath(); } const char* mediaDir = cmd.GetValue( "media" ); g_pFileServer->AddMediaPath( mediaDir ); m_pCore->AddServer( "animserver" ); m_pCore->AddServer( "stringserver" ); m_pCore->AddServer( "windowserver" ); m_pCore->AddServer( c_RenderServerName ); m_pCore->AddServer( "drawserver" ); m_pCore->AddServer( "modelserver" ); m_pCore->AddServer( "particleserver" ); m_pCore->AddServer( "luaserver" ); m_pCore->AddServer( "soundserver" ); m_pCore->AddServer( "physicsserver" ); m_pCore->AddServer( "videoserver" ); g_pWindowServer->SetRootHandle( reinterpret_cast<void*>( hwnd ) ); m_pCore->InitTree(); if (!pRoot) { pRoot = g_pPersistServer->LoadObject( "rboot" ); } if (!pRoot) { return false; } JString objPath; pRoot->GetPath( objPath ); m_pCore->SetRootObject( objPath.c_str() ); g_pWindowServer->AddWindow( pRoot ); pRoot->InitTree(); ModelViewer* pModelViewer = obj_cast<ModelViewer>( pRoot ); Path animPath, modelPath; if (pModelViewer) { pModelViewer->SetAnim( cmd.GetValue( "anim" ) ); pModelViewer->SetModel( cmd.GetValue( "model" ) ); } JDialog* pRootDlg = obj_cast<JDialog>( pRoot ); if (pRootDlg) { pRootDlg->Show(); } return true; }