Esempio n. 1
0
void LoadSkelman() {
	IwGetResManager()->LoadGroup("Skelman/Skelman.group");
	CIwResGroup* pGroup = IwGetResManager()->GetGroupNamed("Skelman");

	ghostStore_Model[1] = (CIwModel*)pGroup->GetResNamed("GEO_For_Export", IW_GRAPHICS_RESTYPE_MODEL);
	ghostStoreCollision[1] = (GhostCollision*)pGroup->GetResNamed("GEO_For_Export", "GhostCollision");
	ghostStore_Skin[1]  = (CIwAnimSkin*)pGroup->GetResNamed("GEO_For_Export", IW_ANIM_RESTYPE_SKIN);
	ghostStore_Skel[1]  = (CIwAnimSkel*)pGroup->GetResNamed("HIP01", IW_ANIM_RESTYPE_SKELETON);
	ghostStore_Anims[1][GHOST_ANIM_IDLE]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Idle", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[1][GHOST_ANIM_AGRO]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Idle", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[1][GHOST_ANIM_DODGE]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Miss", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[1][GHOST_ANIM_ATTACK]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Attack", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[1][GHOST_ANIM_CAPTURED]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Death", IW_ANIM_RESTYPE_ANIMATION);
}
Esempio n. 2
0
void LoadViking() {
	IwGetResManager()->LoadGroup("viking/viking.group");
	CIwResGroup* pGroup = IwGetResManager()->GetGroupNamed("viking");

	ghostStore_Model[0] = (CIwModel*)pGroup->GetResNamed("viking", IW_GRAPHICS_RESTYPE_MODEL);
	ghostStoreCollision[0] = (GhostCollision*)pGroup->GetResNamed("viking", "GhostCollision");
	ghostStore_Skin[0]  = (CIwAnimSkin*)pGroup->GetResNamed("viking", IW_ANIM_RESTYPE_SKIN);
	ghostStore_Skel[0]  = (CIwAnimSkel*)pGroup->GetResNamed("Armature", IW_ANIM_RESTYPE_SKELETON);
	ghostStore_Anims[0][GHOST_ANIM_IDLE]  = (CIwAnim*)pGroup->GetResNamed("Armature_idle", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[0][GHOST_ANIM_AGRO]  = (CIwAnim*)pGroup->GetResNamed("Armature_agro", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[0][GHOST_ANIM_DODGE]  = (CIwAnim*)pGroup->GetResNamed("Armature_dodge", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[0][GHOST_ANIM_ATTACK]  = (CIwAnim*)pGroup->GetResNamed("Armature_attack", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[0][GHOST_ANIM_CAPTURED]  = (CIwAnim*)pGroup->GetResNamed("Armature_captured", IW_ANIM_RESTYPE_ANIMATION);
}
Esempio n. 3
0
void CIwUIViewer::_ChooseStyleSheet()
{
    CIwUIStylesheet* currSheet=NULL;
    CIwResManager* pResManager = IwGetResManager();
    uint32 numGroups = pResManager->GetNumGroups();
    for (uint32 i=0; i<numGroups; ++i)
    {
        CIwResGroup* pResGroup = pResManager->GetGroup(i);
        if (CIwResList* pResList =
                pResGroup->GetListNamed(IW_UI_RESTYPE_STYLESHEET,IW_RES_PERMIT_NULL_F))
        {
            CIwManagedList& propertySets = pResList->m_Resources;
            IW_MANAGED_LIST_ITERATE(propertySets, itPS)
            currSheet=(CIwUIStylesheet*)*itPS;
        }
    }

    IwGetUIStyleManager()->SetStylesheet(currSheet);
}
Esempio n. 4
0
void ResourceManager::fireSound(const char* name) {
	if (!checkSound()) return;
    CIwResGroup* resGroup = IwGetResManager()->GetGroupNamed(SOUND_GROUP);
	CIwSoundSpec* SoundSpec = (CIwSoundSpec*)resGroup->GetResNamed(name, IW_SOUND_RESTYPE_SPEC);
	CIwSoundInst* SoundInstance = SoundSpec->Play();
}
Esempio n. 5
0
void CLevel::Initialize(btDiscreteDynamicsWorld* pDynamicsWorld)
{

	#if defined IW_DEBUG && (defined IW_BUILD_RESOURCES)
		if (IwGetResManager()->BuildResources()) 
		return; 
		// Register the model builder callbacks
		IwGetModelBuilder()->SetPostBuildFn(&BuildCollision);
	#endif 

	CIwResGroup* pGroup = 0;

	m_iCurrentSegmentX = 0;
	m_iCurrentSegmentY = 0;

	m_pCurrentCollisionModel = NULL;
	m_pCurrentCollision = NULL;

	// allocating pointers
	m_apCollisionModel = new CIwModel*[NUM_SECTORS];
	m_apCollision = new CCollision*[NUM_SECTORS];
	m_apBodyGround = new btRigidBody*[NUM_SECTORS];
	m_apGroundShape = new btBvhTriangleMeshShape*[NUM_SECTORS];
	m_apMotionState = new btDefaultMotionState*[NUM_SECTORS];
	m_apIndexVertexArrays = new btTriangleIndexVertexArray*[NUM_SECTORS];
	m_apiColIndices = new int*[NUM_SECTORS];
	m_apfColVertices = new float*[NUM_SECTORS];

	m_pDynamicsWorld = pDynamicsWorld;
	btVector3 localInertia(0,0,0);

	pGroup = IwGetResManager()->LoadGroup("col3.group");

	for (int i = 0; i < NUM_SECTORS; i++)
	{
		char strColFile[20];
		sprintf(strColFile, "Box%d%d", i / 3, i % 3);
		m_apCollisionModel[i] = (CIwModel*)pGroup->GetResNamed(strColFile, IW_GRAPHICS_RESTYPE_MODEL);
		m_apCollision[i] = (CCollision*)pGroup->GetResNamed(strColFile, "CCollision");
		// find some way to delete old unused trimeshes

		uint16 vertcount = m_apCollision[i]->GetVertCount();
		m_apiColIndices[i] = (int*)malloc(vertcount * sizeof(int));
		for (int j = 0; j < vertcount; j+=1)
		{
			m_apiColIndices[i][j] = j;
			//m_colIndices[i+1] = i+1;
			//m_colIndices[i+2] = i;
		}

		m_apfColVertices[i] = (btScalar*)malloc(vertcount*3 * sizeof(btScalar));
		for (int j = 0; j<vertcount; j++)
		{
			m_apfColVertices[i][j*3] = m_apCollision[i]->GetVert(j).x;
			m_apfColVertices[i][j*3+1] = m_apCollision[i]->GetVert(j).y;
			m_apfColVertices[i][j*3+2] = m_apCollision[i]->GetVert(j).z;
		}

		// bullet

		m_apIndexVertexArrays[i] = new btTriangleIndexVertexArray(vertcount/3,
			m_apiColIndices[i],
			3*sizeof(int),
			vertcount,(btScalar*) m_apfColVertices[i], 3*sizeof(btScalar));

		m_apGroundShape[i] = new btBvhTriangleMeshShape(m_apIndexVertexArrays[i],true);
		m_pCollisionShapes.push_back(m_apGroundShape[i]);

		btTransform groundTransform;
		groundTransform.setIdentity();
		groundTransform.setOrigin(btVector3(0,0,0));

		//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
		m_apMotionState[i] = new btDefaultMotionState(groundTransform);
		btRigidBody::btRigidBodyConstructionInfo rbInfo(0.0f,m_apMotionState[i],m_apGroundShape[i],localInertia);
		m_apBodyGround[i] = new btRigidBody(rbInfo);

		//add the body to the dynamics world
		//body->setFriction(0.0f);
		m_apBodyGround[i]->setRestitution(0.9f);			
	}

	m_pDynamicsWorld->addRigidBody(m_apBodyGround[0]);
	
}
Esempio n. 6
0
void CIwUIViewer::_LoadBaseElement(const char* pBaseName, const char* pUIFile,
                                   const char* pSelection)
{
    if (!m_ResGroup)
        IwAssertMsg(VIEWER, false, ("No resource group loaded"));

    if (!strlen(pBaseName))
    {
        // No name indicates we deleted the base element
        DestroyElement(m_BaseElement);
        return;
    }

    std::vector<std::string> selectionPath;
    SplitSeparatedStrings(pSelection, selectionPath);

    // We expect a selection starting at the base element
    if (!selectionPath.size() || selectionPath[0] != pBaseName)
    {
        IwAssertMsg(VIEWER, false, ("Unexpected selection"));

        return;
    }

    // Load .ui file
    CIwUIElement* pBase = ParseElement(pUIFile);

    // Check we have an element with the expected name
    if (!pBase || (strcmp(pBase->DebugGetName(), pBaseName) != 0))
    {
        delete pBase;
        IwAssertMsg(VIEWER, false, ("Loaded element didn't have expected name"));
        return;
    }

    if (m_BaseElement)
    {
        // Remove (hence deactivate) base element
        IwGetUIView()->RemoveElement(m_BaseElement);

        // Are we changing base element?
        if (strcmp(m_BaseElement->DebugGetName(), pBaseName) != 0)
        {
            // Replace resource with instance (hoping this will preserve changes)
            if (!_ReplaceResource(m_BaseElement))
                delete m_BaseElement;
        }
        else
            // Destroy base element
            delete m_BaseElement;

        m_BaseElement = NULL;
    }

    // Ensure we don't get a name clash
    IwGetUIView()->DestroyElements();

    // Search for existing element resource to replace
    ResourceLocation resLoc =
        FindResourceLocation(m_ResGroup, pBaseName, IW_UI_RESTYPE_ELEMENT);

    CIwResGroup* pResGroup;
    if (resLoc.first)
    {
        // Destroy old resource
        resLoc.second->m_Resources.RemoveSlow(resLoc.third);

        // Resource manager holds a reference to resources it holds
        if (!resLoc.third->IsCountZero())
            resLoc.third->DecCount();

        delete resLoc.third;

        // Load into previous location
        pResGroup = resLoc.first;
    }
    else
        pResGroup = m_ResGroup;

    pResGroup->AddRes(IW_UI_RESTYPE_ELEMENT, pBase);

    // Clone new base element and display
    pBase = pBase->Clone();
    _SetBaseElement(pBase);

    // Set selection
    {
        CIwUIElement* pSelection = FindElementByPath(selectionPath);
        _SetSelected(pSelection);
    }
}