inline void matrix4_assign_rotation_for_pivot(Matrix4& matrix, scene::Instance& instance) { Editable* editable = Node_getEditable(instance.path().top()); // If the instance is editable, take the localpivot point into account, otherwise just apply the rotation if (editable != 0) { matrix4_assign_rotation(matrix, matrix4_multiplied_by_matrix4(instance.localToWorld(), editable->getLocalPivot())); } else { matrix4_assign_rotation(matrix, instance.localToWorld()); } }
void visit(scene::Instance& instance) const { if(Node_getEntity(instance.path().top()) != 0 && node_is_group(instance.path().top())) { if(m_parent.top().get_pointer() != instance.path().top().get_pointer()) { parentBrushes(instance.path().top(), m_parent.top()); Path_deleteTop(instance.path()); } } }
void operator()(scene::Instance& instance) const { if(result == 0) { const char* value = Node_getEntity(instance.path().top())->getKeyValue("targetname"); if(!strcmp(value, targetname)) { result = &instance.path(); } } }
bool pre (const scene::Path& path, scene::Instance& instance) const { ++m_depth; if (m_depth == 2) { /* entity depth */ /* traverse and select children if any one is selected */ if (instance.childSelected()) Instance_setSelected(instance, true); return Node_getEntity(path.top())->isContainer() && instance.childSelected(); } else if (m_depth == 3) { /* primitive depth */ Instance_setSelected(instance, true); return false; } return true; }
void post( const scene::Path& path, scene::Instance& instance ) const { Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 && ( instance.childSelected() || Instance_getSelectable( instance )->isSelected() ) ) { entity->setKeyValue( m_key, m_value ); } }
void operator()(scene::Instance& instance) { if(instance.path().top().get().visible()) { Functor::operator()(instance); } }
void operator()(scene::Instance& instance) const { const char* classname = Node_getEntity(instance.path().top())->getKeyValue("classname"); if(!strcmp(classname, "worldspawn")) { world.LoadFromEntity(instance.path().top(), false); world.RemoveNonCheckBrushes(exclusionList, true); world.SaveToFile(pFile); } else if(strstr(classname, "info_")) { world.ClearBrushes(); world.ClearEPairs(); world.LoadEPairList(Node_getEntity(instance.path().top())); world.SaveToFile(pFile); } }
void DPatch::LoadFromPatch( scene::Instance& patch ){ QER_entity = patch.path().parent().get_pointer(); QER_brush = patch.path().top().get_pointer(); PatchControlMatrix matrix = GlobalPatchCreator().Patch_getControlPoints( patch.path().top() ); width = static_cast<int>( matrix.x() ); height = static_cast<int>( matrix.y() ); for ( int x = 0; x < width; x++ ) { for ( int y = 0; y < height; y++ ) { PatchControl& p = matrix( x, y ); points[x][y].xyz[0] = p.m_vertex[0]; points[x][y].xyz[1] = p.m_vertex[1]; points[x][y].xyz[2] = p.m_vertex[2]; points[x][y].st[0] = p.m_texcoord[0]; points[x][y].st[1] = p.m_texcoord[1]; } } SetTexture( GlobalPatchCreator().Patch_getShader( patch.path().top() ) ); #if 0 SetTexture( brush->pPatch->GetShader() ); width = brush->pPatch->getWidth(); height = brush->pPatch->getHeight(); for ( int x = 0; x < height; x++ ) { for ( int y = 0; y < width; y++ ) { float *p = brush->pPatch->ctrlAt( ROW,x,y ); p[0] = points[x][y].xyz[0]; p[1] = points[x][y].xyz[1]; p[2] = points[x][y].xyz[2]; p[3] = points[x][y].st[0]; p[4] = points[x][y].st[1]; } } #endif }
void operator()(scene::Instance& instance) const { if(!instance.isSelected()) { return; } ent.LoadFromEntity(instance.path().top()); DEPair* pEpair = ent.FindEPairByKey("origin"); if(!pEpair) { return; } vec3_t vec, out; sscanf( pEpair->value.GetBuffer(), "%f %f %f", &vec[0], &vec[1], &vec[2]); planter.FindDropPoint( vec, out ); char buffer[256]; sprintf( buffer, "%f %f %f", out[0], out[1], out[2] ); ent.AddEPair( "origin", buffer ); ent.RemoveFromRadiant(); ent.BuildInRadiant(false); }
bool pre(const scene::Path& path, scene::Instance& instance) const { if (path.top().get().visible() && Node_isBrush(path.top())) // this node is a floor { const AABB& aabb = instance.worldAABB(); float floorHeight = aabb.origin.z() + aabb.extents.z(); if (floorHeight > m_current && floorHeight < m_bestUp) { m_bestUp = floorHeight; } if (floorHeight < m_current && floorHeight > m_bestDown) { m_bestDown = floorHeight; } } return true; }
void post( const scene::Path& path, scene::Instance& instance ) const { Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 && ( instance.childSelected() || Instance_getSelectable( instance )->isSelected() ) ) { NodeSmartReference node( GlobalEntityCreator().createEntity( GlobalEntityClassManager().findOrInsert( m_classname, node_is_group( path.top() ) ) ) ); EntityCopyingVisitor visitor( *Node_getEntity( node ) ); entity->forEachKeyValue( visitor ); NodeSmartReference child( path.top().get() ); NodeSmartReference parent( path.parent().get() ); Node_getTraversable( parent )->erase( child ); if ( Node_getTraversable( child ) != 0 && Node_getTraversable( node ) != 0 && node_is_group( node ) ) { parentBrushes( child, node ); } Node_getTraversable( parent )->insert( node ); } }
void visit( scene::Instance& instance ) const { if ( Node_isPatch( instance.path().top() ) ) { m_functor( instance ); } }
void post( const scene::Path& path, scene::Instance& instance ) const { Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 && ( instance.childSelected() || Instance_getSelectable( instance )->isSelected() ) ) { if( path.top().get_pointer() == m_world ){ /* do not want to convert whole worldspawn entity */ if( instance.childSelected() && !m_2world ){ /* create an entity from world brushes instead */ EntityClass* entityClass = GlobalEntityClassManager().findOrInsert( m_classname, true ); if( entityClass->fixedsize ) return; //is important to have retexturing here; if doing in the end, undo doesn't succeed; //don't do this extra now, as it requires retexturing, working for subgraph // if ( string_compare_nocase_n( m_classname, "trigger_", 8 ) == 0 ){ // Scene_PatchSetShader_Selected( GlobalSceneGraph(), GetCommonShader( "trigger" ).c_str() ); // Scene_BrushSetShader_Selected( GlobalSceneGraph(), GetCommonShader( "trigger" ).c_str() ); // } NodeSmartReference node( GlobalEntityCreator().createEntity( entityClass ) ); Node_getTraversable( GlobalSceneGraph().root() )->insert( node ); scene::Path entitypath( makeReference( GlobalSceneGraph().root() ) ); entitypath.push( makeReference( node.get() ) ); scene::Instance& entityInstance = findInstance( entitypath ); if ( g_pGameDescription->mGameType == "doom3" ) { Node_getEntity( node )->setKeyValue( "model", Node_getEntity( node )->getKeyValue( "name" ) ); } //Scene_parentSelectedBrushesToEntity( GlobalSceneGraph(), node ); Scene_parentSubgraphSelectedBrushesToEntity( GlobalSceneGraph(), node, path ); Scene_forEachChildSelectable( SelectableSetSelected( true ), entityInstance.path() ); } return; } else if( m_2world ){ /* ungroupSelectedEntities */ //condition is skipped with world = 0, so code next to this may create multiple worldspawns; todo handle this very special case? if( node_is_group( path.top() ) ){ parentBrushes( path.top(), *m_world ); Path_deleteTop( path ); } return; } EntityClass* eclass = GlobalEntityClassManager().findOrInsert( m_classname, node_is_group( path.top() ) ); NodeSmartReference node( GlobalEntityCreator().createEntity( eclass ) ); if( entity->isContainer() && eclass->fixedsize ){ /* group entity to point one */ char value[64]; sprintf( value, "%g %g %g", instance.worldAABB().origin[0], instance.worldAABB().origin[1], instance.worldAABB().origin[2] ); entity->setKeyValue( "origin", value ); } EntityCopyingVisitor visitor( *Node_getEntity( node ) ); // entity->forEachKeyValue( visitor ); NodeSmartReference child( path.top().get() ); NodeSmartReference parent( path.parent().get() ); // Node_getTraversable( parent )->erase( child ); if ( Node_getTraversable( child ) != 0 && node_is_group( node ) ) { /* group entity to group one */ parentBrushes( child, node ); } Node_getTraversable( parent )->insert( node ); entity->forEachKeyValue( visitor ); /* must do this after inserting node, otherwise problem: targeted + having model + not loaded b4 new entities aren't selectable normally + rendered only while 0 0 0 is rendered */ if( !entity->isContainer() && !eclass->fixedsize ){ /* point entity to group one */ AABB bounds( g_vector3_identity, Vector3( 16, 16, 16 ) ); if ( !string_parse_vector3( entity->getKeyValue( "origin" ), bounds.origin ) ) { bounds.origin = g_vector3_identity; } Brush_ConstructPlacehoderCuboid( node.get(), bounds ); Node_getEntity( node )->setKeyValue( "origin", "" ); } Node_getTraversable( parent )->erase( child ); } }
void visit (scene::Instance& instance) const { if (&m_parent != &instance.path()) { Path_parent(m_parent, instance.path()); } }