Пример #1
0
LIST_OF_ENTITIES *
STEPWrapper::getListOfEntities(SDAI_Application_instance *sse, const char *name)
{
    LIST_OF_ENTITIES *l = new LIST_OF_ENTITIES;

    sse->ResetAttributes();

    STEPattribute *attr;
    while ((attr = sse->NextAttribute()) != NULL) {
	std::string attrval;
	std::string attrname = attr->Name();

	if (attrname.compare(name) == 0) {
	    STEPaggregate *sa = (STEPaggregate *)attr->ptr.a;

	    EntityNode *sn = (EntityNode *)sa->GetHead();
	    SDAI_Application_instance *se;
	    while (sn != NULL) {
		se = (SDAI_Application_instance *)sn->node;

		l->push_back(se);
		sn = (EntityNode *)sn->NextNode();
	    }
	    break;
	}
    }

    return l;
}
Пример #2
0
LIST_OF_PATCHES *
STEPWrapper::parseListOfPatchEntities(const char *in)
{
    LIST_OF_PATCHES *l = new LIST_OF_PATCHES;
    ErrorDescriptor errdesc;
    EntityAggregate *ag = new EntityAggregate();

    ag->StrToVal(in, &errdesc, SCHEMA_NAMESPACE::e_cartesian_point, instance_list, 0);
    EntityNode *sn = (EntityNode *)ag->GetHead();

    SDAI_Application_instance *sse;
    while (sn != NULL) {
	sse = (SDAI_Application_instance *)sn->node;
	SurfacePatch *aCP = dynamic_cast<SurfacePatch *>(Factory::CreateObject(this,sse));
	if (aCP != NULL) {
	    l->push_back(aCP);
	} else {
	    std::cout << "Error loading SurfacePatch." << std::endl;
	}
	sn = (EntityNode *)sn->NextNode();
    }
    delete ag;

    return l;
}
Пример #3
0
void
STEPWrapper::printEntityAggregate(STEPaggregate *sa, int level)
{
    std::string strVal;

    for (int i = 0; i < level; i++) {
	std::cout << "    ";
    }
    std::cout << "Aggregate:" << sa->asStr(strVal) << std::endl;

    EntityNode *sn = (EntityNode *)sa->GetHead();
    SDAI_Application_instance *sse;
    while (sn != NULL) {
	sse = (SDAI_Application_instance *)sn->node;

	if (((sse->eDesc->Type() == SET_TYPE) || (sse->eDesc->Type() == LIST_TYPE)) && (sse->eDesc->BaseType() == ENTITY_TYPE)) {
	    printEntityAggregate((STEPaggregate *)sse, level + 2);
	} else if (sse->eDesc->Type() == ENTITY_TYPE) {
	    printEntity(sse, level + 2);
	} else {
	    std::cout << "Instance Type not handled:" << std::endl;
	}
	//std::cout << "sn - " << sn->asStr(attrval) << std::endl;

	sn = (EntityNode *)sn->NextNode();
    }
    //std::cout << std::endl << std::endl;
}
Пример #4
0
void EntityNode::NodeRemovedCallback( MObject& node, void* clientData )
{
    MAYA_START_EXCEPTION_HANDLING();

    if( !s_DoRemoveNodeCallback )
    {
        return;
    }

    s_DoRemoveNodeCallback = false;
    {
        MFnDependencyNode nodeFn( node );

        EntityNode* artClass = (EntityNode*)(nodeFn.userNode());
        artClass->UnloadArt();

        M_EntityNode::iterator itor = artClass->m_Instances.begin();
        M_EntityNode::iterator end  = artClass->m_Instances.end();
        for( ; itor != end; ++itor)
        {
            MGlobal::deleteNode( itor->second->thisMObject() );
        }
        artClass->m_Instances.clear();

        s_ClassTransformsMap.erase( artClass->m_AssetPath.Hash() );
    }
    s_DoRemoveNodeCallback = true;

    MAYA_FINISH_EXCEPTION_HANDLING();
}
Пример #5
0
/**
 * clips a trace against entities
 * trace is represented by line-segment and AABB
 */
void EntityManager::ClipTrace(STrace& tr)
{
	PROFILE_FUNCTION();

	EntityNode* pHeadNode = m_paEntityTree; /* pointer to the first entity-node */
	
	pHeadNode->ClipTrace_r( tr, pHeadNode );
}
Пример #6
0
//---------------------------------------------------------------------------------------------------------
// State Code
//---------------------------------------------------------------------------------------------------------
void EntityRockMouth::State_Attack(s32 messageType_, EntityNode* entityNode_, s32 dataSize_)
{

//---------------------------------------------------------------------------------------------------------
// STATE_MESSAGE_ENTER
//---------------------------------------------------------------------------------------------------------
	if( messageType_ == eCommonMessageTypes::STATE_MESSAGE_ENTER )
	{
		entityNode_->GetSpriteComponent()->GetAnimPlayer()->SetAnimationByTag("OpeningMouth", 1);
		entityNode_->SetIntParamOffset("attackNb", 10);
	}
	else
//---------------------------------------------------------------------------------------------------------
// STATE_MESSAGE_EXIT
//---------------------------------------------------------------------------------------------------------
	if( messageType_ == eCommonMessageTypes::STATE_MESSAGE_EXIT )
	{
		;
	}
	else
//---------------------------------------------------------------------------------------------------------
// STATE_MESSAGE_UPDATE
//---------------------------------------------------------------------------------------------------------
	if( messageType_ == eCommonMessageTypes::STATE_MESSAGE_UPDATE )
	{
		PhyObject* phyObj = entityNode_->GetPhysicObject();

		if( entityNode_->GetSpriteComponent()->GetAnimPlayer()->IsAnimOver() )
		{
			if( !entityNode_->GetSpriteComponent()->GetAnimPlayer()->CurrentAnimation()->Tag.compare("OpeningMouth") )
			{
				entityNode_->GetSpriteComponent()->GetAnimPlayer()->SetAnimationByTag("ClosingMouth", 1);

				core::vector2di iShootPos = entityNode_->GetSpriteComponent()->GetSprite()->GetMkPointDataByTag("Shoot");
				core::vector2df shootPos = phyObj->Position + core::vector2df( iShootPos.X, iShootPos.Y );
				core::vector2df shootVeloc = core::vector2df( 75, -10 );

				EntityNode* rock = entityNode_->GetGameManager()->GetEntityFactory()->CreateEntityFromTemplate("rock", entityNode_->getParent()->getName(), "", 0);
				rock->GetPhysicObject()->Position = shootPos;
				rock->GetPhysicObject()->Velocity = shootVeloc;
				rock->SetIntParam("HP", 50);
			}
			else
			{
				entityNode_->SetIntParamOffset("attackNb", -1);

				if( entityNode_->GetIntParam("attackNb") > 0 )
				{
					entityNode_->GetSpriteComponent()->GetAnimPlayer()->SetAnimationByTag("OpeningMouth", 1);
				}
				else
				{
					entityNode_->GetStateMachine()->SwitchState("Idle");
				}
			}
		}
	}
}
Пример #7
0
EntityNode* EntityFactory::CreateDropItem( 
	EntityNode* entityParent, 
	eItemType itemType,
	int itemSubtype
)
{
	EntityNode* entity = CreateEntity( entityParent->getParent()->getName(), "" );
	entity->SetIntParam("ItemType", itemType);
	entity->SetIntParam("ItemSubtype", itemSubtype);
	BuildEntityFromTemplate( entity, "dropItem", 0);
	return entity;
}
Пример #8
0
EntityNode* EntityFactory::CreateProjectile( 
	EntityNode* entityParent, 
	const std::string& sSprite, 
	const std::string& sFlyingAnim,
	const std::string& sCollBody,
	const core::vector2df& position, 
	const core::vector2df& velocity, 
	bool isGravityOn 
)
{
		EntityNode* projectile = CreateEntity( entityParent->getParent()->getName(), "" );

		projectile->CreatePhysicObject();

		projectile->GetPhysicObject()->Position = position;
		projectile->GetPhysicObject()->Velocity = velocity;
		projectile->GetPhysicObject()->IsApplyGravity = isGravityOn;

		projectile->SetSpriteComponent( sSprite );
		projectile->GetPhysicObject()->BoundingBox = projectile->GetSpriteComponent()->GetSprite()->GetMkRectDataByTag( sCollBody );
		projectile->GetSpriteComponent()->GetAnimPlayer()->SetAnimationByTag(sFlyingAnim, -1);

		BuildEntityFromTemplate( projectile, "projectile", 0);

		return projectile;
}
Пример #9
0
EntityNode& EntityNode::Get( const Helium::Path& path, bool createIfNotExisting )
{
    MFnDagNode dagFn;

    try
    {
        M_IdClassTransform::iterator findItor = s_ClassTransformsMap.find( path.Hash() );
        if( findItor != s_ClassTransformsMap.end() )
        {
            return *findItor->second;
        }
        else if ( createIfNotExisting )
        {
            // we couldn't find it, so create it and return the loaded art class
            Asset::AssetClassPtr assetClass = Asset::AssetClass::LoadAssetClass( path );

            if ( assetClass.ReferencesObject() )
            {
                tstring artFilePath = assetClass->GetPath().Get();

                MObject classTransform = dagFn.create( EntityNode::s_TypeID, assetClass->GetShortName().c_str() );
                dagFn.setDoNotWrite( true );

                EntityNode* artClass = static_cast<EntityNode*>( dagFn.userNode() );

                artClass->m_AssetPath = path;
                artClass->SetArtFilePath( artFilePath.c_str() );

                s_ClassTransformsMap[ path.Hash() ] = artClass;
                artClass->LoadArt();

                return *artClass;
            }
        }
    }
    catch (Helium::Exception& )
    {
        if ( createIfNotExisting )
        {
            MGlobal::displayError( MString("Unable to create EntityNode!") );
        }
    }

    return EntityNode::Null;
}
Пример #10
0
void EntityInstanceNode::Show( const EntityNode& instanceClassNode )
{
    if( instanceClassNode == EntityNode::Null )
        return;

    MFnDagNode instanceFn( thisMObject() );
    MDagPath path;
    instanceFn.getPath( path );

    MFnDagNode nodeFn( instanceClassNode.thisMObject() );
    u32 len = nodeFn.childCount();

    for( u32 i = 0; i < len; ++i )
    {
        MFnDagNode nodeFn( nodeFn.child( i ) );

        MDagPath child;
        nodeFn.getPath( child );
        MDagPath result;
        Maya::duplicate( child, path, result, true, true );
    }
}
Пример #11
0
EntityNode* SceneLoader::LoadEntityNode(QDomElement element)
{
  if (element.nodeName() != QString ("node") ||
      QString::compare(element.attribute("type"), "entity", Qt::CaseInsensitive) != 0)
    {
      printf ("ceXMLDataLoader::LoadEntityNode: Illegal data format: '%s' != 'entitynode'\n", element.nodeName().toStdString().c_str()); fflush (stdout);
      return 0;
    }

  EntityNode* entity = new EntityNode();
  QString  name = element.attribute("name");
  if (!name.isNull())
    {
      entity->SetName(name.toStdString());
    }


  QDomElement geometryElement = element.firstChildElement("geometry");
  if (!geometryElement.isNull())
    {
      Geometry* geom = LoadGeometry(geometryElement);
      if (geom)
        {
          _geometryIdx++;
        }
      entity->SetGeometry(geom);
    }

  QDomElement shadowElement = element.firstChildElement("shadow");
  if (!shadowElement.isNull())
    {
      LoadShadow (entity, shadowElement);
    }
  entity->SetCastShadow(true);

  QDomElement transformElement = element.firstChildElement("transformation");
  if (!transformElement.isNull())
    {
      QDomElement matrixElement = transformElement.firstChildElement("matrix");
      entity->SetMatrix(LoadMatrix4f(matrixElement));
      entity->FinishTransformation(false);
    }

  return entity;
}
Пример #12
0
void EntityManager::GetVisibleEntities(ViewFrustumTest& vf_test)
{
	EntityNode* pHeadNode = m_paEntityTree; /* pointer to the first entity-node */
	
	pHeadNode->GetVisibleEntities_r( vf_test, pHeadNode );
}
Пример #13
0
void EntityManager::CheckPosition(CTrace& tr)
{
	EntityNode* pHeadNode = m_paEntityTree; /* pointer to the first entity-node */
	
	pHeadNode->CheckPosition_r( tr, pHeadNode );
}
Пример #14
0
//-----------------------------------------------------------------------------
// EntityInstanceNodeCmd::doIt
// execution of the command
//-----------------------------------------------------------------------------
MStatus EntityInstanceNodeCmd::doIt( const MArgList & args )
{
  MStatus stat;

  // parse the command line arguments using the declared syntax
  MArgDatabase argParser( syntax(), args, &stat );

  if( argParser.isFlagSet( ReloadAllArtFlagLong ) )
  {
    EntityNode::UnloadAllArt();
    EntityNode::LoadAllArt();
    return MS::kSuccess;
  }
  else if( argParser.isFlagSet( UnloadAllArtFlagLong ) )
  {
    EntityNode::UnloadAllArt();
    return MS::kSuccess;
  }
  else if( argParser.isFlagSet( UnselectFlag ) )
  {
    MGlobal::executeCommand( "select -all" );

    MSelectionList list;
    MGlobal::getActiveSelectionList( list );
    EntityNode::UnselectAll( list );
    MGlobal::setActiveSelectionList( list );

    return MS::kSuccess;
  }
  else if( argParser.isFlagSet( CreateInstanceFlag ) )
  {
      HELIUM_BREAK();
#pragma TODO( "Reimplement to use the Vault" )
    //File::FileBrowser browserDlg( NULL, -1, "Create Instance" );
    //browserDlg.AddFilter( FinderSpecs::Asset::ENTITY_DECORATION );
    //browserDlg.SetFilterIndex( FinderSpecs::Asset::ENTITY_DECORATION );

    //if ( browserDlg.ShowModal() == wxID_OK )
    //{
    //  tstring fullPath = browserDlg.GetPath();
    //  if ( FileSystem::Exists( fullPath ) )
    //  {
    //    if ( FileSystem::HasExtension( fullPath, FinderSpecs::Asset::ENTITY_DECORATION.GetDecoration() ) )
    //    {
    //      Asset::EntityPtr instance = new Asset::Entity( fullPath );
    //      std::pair< EntityNode*, EntityInstanceNode* >result = EntityNode::CreateInstance( instance );
    //      MFnDependencyNode nodeFn( result.second->thisMObject() );
    //    }
    //  }
    //}

    return MS::kSuccess;
  }
  else if( argParser.isFlagSet( FlattenLong ) )
  {
    EntityNode::FlattenInstances();    
    return MS::kSuccess;
  }

  //
  // the following flags need an EntityNode object to proceed
  //

  MSelectionList selection;
  argParser.getObjects( selection );

  MObject selectedNode;
  selection.getDependNode( 0, selectedNode );

  MFnDependencyNode nodeFn;
  nodeFn.setObject( selectedNode );

  EntityNode* classTransform = NULL;
  if( nodeFn.typeId() == EntityInstanceNode::s_TypeID )
  {
    EntityInstanceNode* node = static_cast< EntityInstanceNode* >( nodeFn.userNode( &stat ) );
    if( !node )
    {
      return MS::kFailure;
    }

    classTransform = &EntityNode::Get( node->GetBackingEntity()->GetEntity()->GetPath() );
    if( *classTransform == EntityNode::Null )
    {
      return MS::kFailure;
    }
  }
  else if ( nodeFn.typeId() == EntityNode::s_TypeID )
  {
    classTransform = static_cast< EntityNode* >( nodeFn.userNode( &stat ) );
    if( !classTransform )
    {
      return MS::kFailure;
    }
  }

  if (argParser.isFlagSet( ReloadArtLong ) )
  {
    classTransform->LoadArt();
  }
  else if( argParser.isFlagSet( SelectEntityAssetFlagLong ) )
  {
    MFnDagNode nodeFn( classTransform->thisMObject() );
    MGlobal::executeCommand( "select -r \"" + nodeFn.fullPathName() + "\"" );
  }

  return MS::kSuccess;
}