コード例 #1
0
ファイル: test.c プロジェクト: ahua/java
/*
 * Parse the java heap and set all the pointers to hold
 * physical addresses instead of relative values. Return
 * a pointer to the next available object location.
 */
static void convertPointers() {
    Ref next = core;
    while (next[OBJECT_ID].i != HEADER_END) {
        convertObject(next);
        next += next[OBJECT_SIZE].i;
    }
    core[CORE_NEXT].i = next - core;
}
コード例 #2
0
// this have to be called after all scenes created their groups
void gkBlenderSceneConverter::convertGroupInstances()
{
	m_gscene = static_cast<gkScene*>(gkSceneManager::getSingleton().getByName(gkResourceName(GKB_IDNAME(m_bscene), m_groupName)));

	if (m_gscene)
	{
		gkGroupManager* mgr = gkGroupManager::getSingletonPtr();

                utArray<Blender::Object*> groups;
		for (Blender::Base* base = (Blender::Base*)m_bscene->base.first; base; base = base->next)
		{
			if (!base->object)
				continue;

			Blender::Object* bobj = base->object;

			// non - conversion object
			if (!validObject(bobj))
				continue;

			// only concentrate on the group-instances
			if ( (bobj->transflag & OB_DUPLIGROUP) && bobj->dup_group != 0)
				groups.push_back(bobj);
		}


		// Process user created groups.
		utArray<Blender::Object*>::Iterator it = groups.iterator();
		while (it.hasMoreElements())
		{
			Blender::Object* bobj = it.getNext();

			// Should not fail
			GK_ASSERT((bobj->transflag& OB_DUPLIGROUP && bobj->dup_group != 0));


			// Owning group
			Blender::Group* bgobj = bobj->dup_group;
			const gkResourceName groupName(GKB_IDNAME(bgobj), m_groupName);


			if (mgr->exists(groupName))
			{
				gkGameObjectGroup* ggobj = (gkGameObjectGroup*)mgr->getByName(groupName);


				gkGameObjectInstance* inst = ggobj->createGroupInstance(m_gscene, gkResourceName(GKB_IDNAME(bobj), m_groupName),0,bobj->lay);
				inst->getRoot()->_makeGroup(ggobj);
				inst->getRoot()->_makeGroupInstance(inst);
				if (inst)
					convertObject(bobj, inst->getRoot());
			}
		}
	} else
	{
		gkLogger::write("CAUTION:Calling gkBlenderSceneConverter::convertGroupInstance() without calling convert(false) before doesn't work! No group-instances created!",true);
	}
}
コード例 #3
0
ファイル: functions_600.cpp プロジェクト: Glyth/xoreos
void ScriptFunctions::speakStringByStrRef(Aurora::NWScript::FunctionContext &ctx) {
	Object *object = convertObject(ctx.getCaller());
	if (!object)
		return;

	// TODO: ScriptFunctions::speakStringByStrRef(): Volume
	uint32 strRef = (uint32) ctx.getParams()[0].getInt();
	uint32 volume = (uint32) ctx.getParams()[1].getInt();

	object->speakString(TalkMan.getString(strRef).c_str(), volume);
}
コード例 #4
0
ファイル: functions_600.cpp プロジェクト: Glyth/xoreos
void ScriptFunctions::storeCampaignObject(Aurora::NWScript::FunctionContext &ctx) {
	ctx.getReturn() = 0;

	const Common::UString &dbName  = ctx.getParams()[0].getString();
	const Common::UString &varName = ctx.getParams()[1].getString();

	Object *object = convertObject(ctx.getParams()[3].getObject());
	if (!object)
		return;

	warning("TODO: StoreCampaignObject: \"%s\":\"%s\" to \"%s\"",
			dbName.c_str(), varName.c_str(), object->getTag().c_str());
}
コード例 #5
0
ファイル: functions.cpp プロジェクト: DeejStar/xoreos
void ScriptFunctions::jumpTo(Object *object, Area *area, float x, float y, float z) {
	// Sanity check
	if (!object->getArea() || !area) {
		warning("ScriptFunctions::jumpTo(): No area?!? (%d, %d)",
		        object->getArea() != 0, area != 0);
		return;
	}

	GfxMan.lockFrame();

	// Are we moving between areas?
	if (object->getArea() != area) {
		const Common::UString &areaFrom = object->getArea()->getResRef();
		const Common::UString &areaTo   = area->getResRef();

		warning("TODO: ScriptFunctions::jumpTo(): Moving from \"%s\" to \"%s\"",
		        areaFrom.c_str(), areaTo.c_str());

		Object *pc = convertObject(getPC());
		if (pc) {
			const Common::UString &pcArea = pc->getArea()->getResRef();

			if (areaFrom == pcArea) {
				// Moving away from the currently visible area.

				object->hide();
				object->unloadModel();

			} else if (areaTo == pcArea) {
				// Moving into the currently visible area.

				object->loadModel();
				object->show();
			}

		}

		object->setArea(area);
	}

	// Update position
	object->setPosition(x, y, z);

	GfxMan.unlockFrame();

	if (object == getPC() && _module)
		_module->movedPC();
}
コード例 #6
0
void gkBlenderSceneConverter::convert(bool createGroupInstances)
{
	if (m_gscene)
		return;

	m_gscene = (gkScene*)gkSceneManager::getSingleton().create(gkResourceName(GKB_IDNAME(m_bscene), m_groupName));
	if (!m_gscene)
	{
		gkPrintf("SceneConverter: duplicate scene '%s'\n", (m_bscene->id.name + 2));
		return;
	}

	m_gscene->setLoadBlendFile(m_file);


	if (m_bscene->world)
		convertWorld();


	convertSoundScene();


	m_gscene->setLayer((UTuint32)m_bscene->lay);


	utArray<Blender::Object*> groups, armatureLinker;
	for (Blender::Base* base = (Blender::Base*)m_bscene->base.first; base; base = base->next)
	{
		if (!base->object)
			continue;

		Blender::Object* bobj = base->object;

		// non - conversion object
		if (!validObject(bobj))
			continue;

		if ((bobj->transflag& OB_DUPLIGROUP) && bobj->dup_group != 0)
			groups.push_back(bobj);
		else
			convertObject(bobj);

		if (bobj->type == OB_MESH && bobj->parent != 0 && bobj->parent->type == OB_ARMATURE)
			armatureLinker.push_back(bobj);
#if 0
		if (bobj->parent) {
			short parentType = bobj->parent->type;
			short parentParType = bobj->parent->partype;
		}
		short parType = bobj->partype;

		int i=0;
#endif
	}

	// build group instances
	convertGroups();
	if (createGroupInstances)
		convertGroupInstances();

	if (!armatureLinker.empty())
	{
		gkMeshManager& memgr = gkMeshManager::getSingleton();
		gkSkeletonManager& skmgr = gkSkeletonManager::getSingleton();
		gkGameObjectManager& gomgr = gkGameObjectManager::getSingleton();


		UTsize i;
		for (i = 0; i < armatureLinker.size(); ++i)
		{
			Blender::Object* obMe = armatureLinker[i];
			Blender::Object* obAr = obMe->parent;


			gkEntity* gobjEn = gomgr.getEntity(GKB_IDNAME(obMe));
			gkSkeleton* gobjSk = gomgr.getSkeleton(GKB_IDNAME(obAr));

			if (gobjEn && gobjSk && !gobjEn->getProperties().hasBoneParent())
			{
				gobjEn->setSkeleton(gobjSk);


				// Link data
				Blender::Mesh* me = static_cast<Blender::Mesh*>(obMe->data);
				Blender::bArmature* ar = static_cast<Blender::bArmature*>(obAr->data);

				if (memgr.exists(GKB_IDNAME(me)) && skmgr.exists(GKB_IDNAME(obAr)))
				{
					gkSkeletonResource* skel = skmgr.getByName<gkSkeletonResource>(GKB_IDNAME(obAr));

					memgr.getByName<gkMesh>(GKB_IDNAME(me))->_setSkeleton(skel);

					gkBone::BoneList::Iterator roots = skel->getRootBoneList().iterator();

					while (roots.hasMoreElements())
					{
						gkBone* bone = roots.getNext();
						gkMatrix4 eobmat = gkMathUtils::getFromFloat(obMe->obmat);
						gkMatrix4 sobmat = gkMathUtils::getFromFloat(obAr->obmat);

						gkTransformState trans(eobmat.inverse() * sobmat);
						if (!trans.isNaN())
							bone->applyRootTransform(trans);
						else
							gkPrintf("Warning: Invalid bone transform.");
					}

				}
			}
		}
	}

	m_logic->resolveLinks();
}
コード例 #7
0
void gkBlenderSceneConverter::convertGroups()
{
	gkGroupManager* mgr = gkGroupManager::getSingletonPtr();

	// This is a complete list of groups & containing objects.
	// The gkGameObjectGroup is a containter, the gkGameObjectGroupInstance
	// is where the object should be added / removed from the scene.
	
	//	for (Blender::Group* bgrp = (Blender::Group*)m_file->_getInternalFile()->m_group.first; bgrp != 0; 
	//	bgrp = (Blender::Group*)bgrp->id.next)

	gkBlendListIterator iter = m_file->_getInternalFile()->getGroupList();
	while (iter.hasMoreElements())
	{
		Blender::Group* bgrp = (Blender::Group*)iter.getNext();


		const gkResourceName groupName(GKB_IDNAME(bgrp), m_groupName);

		if (mgr->exists(groupName))
		{
			// Can most likely assert here
			continue;
		}

		gkGameObjectGroup* group = (gkGameObjectGroup*)mgr->create(groupName);


		for (Blender::GroupObject* bgobj = (Blender::GroupObject*)bgrp->gobject.first; bgobj; bgobj = bgobj->next)
		{
			if (bgobj->ob)
			{
				Blender::Object* bobj = bgobj->ob;

				if (!validObject(bobj))
					continue;

				// is object a group-instance?
				if ( (bobj->transflag& OB_DUPLIGROUP) && bobj->dup_group != 0)
				{
					gkGameObject* gobj = m_gscene->createObject(gkString(GKB_IDNAME(bobj))+"_grproot");
					convertObject(bobj,gobj);

					// Owning group
					Blender::Group* bgobj = bobj->dup_group;
					const gkString instGroupName(GKB_IDNAME(bgobj));
					if (gobj)
						group->addGroup(instGroupName,gobj);
				}
				else
				{
					gkGameObject* gobj = m_gscene->getObject(GKB_IDNAME(bobj));

					// add it to the list
					if (gobj)
						group->addObject(gobj);
				}
			}
		}

		// Destroy if empty
		if (group->isEmpty())
			mgr->destroy(group);
		else
			mgr->attachGroupToScene(m_gscene, group);

	}
}
コード例 #8
0
void gkBlenderSceneConverter::convertGroups(utArray<Blender::Object*> &groups)
{
	gkGroupManager* mgr = gkGroupManager::getSingletonPtr();

	// This is a complete list of groups & containing objects.
	// The gkGameObjectGroup is a containter, the gkGameObjectGroupInstance
	// is where the object should be added / removed from the scene.
	
	//	for (Blender::Group* bgrp = (Blender::Group*)m_file->_getInternalFile()->m_group.first; bgrp != 0; 
	//	bgrp = (Blender::Group*)bgrp->id.next)

	gkBlendListIterator iter = m_file->_getInternalFile()->getGroupList();
	while (iter.hasMoreElements())
	{
		Blender::Group* bgrp = (Blender::Group*)iter.getNext();


		const gkResourceName groupName(GKB_IDNAME(bgrp), m_groupName);

		if (mgr->exists(groupName))
		{
			// Can most likely assert here
			continue;
		}

		gkGameObjectGroup* group = (gkGameObjectGroup*)mgr->create(groupName);


		for (Blender::GroupObject* bgobj = (Blender::GroupObject*)bgrp->gobject.first; bgobj; bgobj = bgobj->next)
		{
			if (bgobj->ob)
			{
				Blender::Object* bobj = bgobj->ob;

				if (!validObject(bobj))
					continue;

				gkGameObject* gobj = m_gscene->getObject(GKB_IDNAME(bobj));

				// add it to the list
				if (gobj)
					group->addObject(gobj);
			}
		}

		// Destroy if empty
		if (group->isEmpty())
			mgr->destroy(group);
		else
			mgr->attachGroupToScene(m_gscene, group);

	}

	// Process user created groups.
	utArray<Blender::Object*>::Iterator it = groups.iterator();
	while (it.hasMoreElements())
	{
		Blender::Object* bobj = it.getNext();


		// Should not fail
		GK_ASSERT((bobj->transflag& OB_DUPLIGROUP && bobj->dup_group != 0));


		// Owning group
		Blender::Group* bgobj = bobj->dup_group;
		const gkResourceName groupName(GKB_IDNAME(bgobj), m_groupName);


		if (mgr->exists(groupName))
		{
			gkGameObjectGroup* ggobj = (gkGameObjectGroup*)mgr->getByName(groupName);


			gkGameObjectInstance* inst = ggobj->createGroupInstance(m_gscene, gkResourceName(GKB_IDNAME(bobj), m_groupName));
			if (inst)
				convertObject(bobj, inst->getRoot());
		}
	}
}