Esempio n. 1
0
void gkJoystickController::updateInputState(void)
{
	m_camRot.m_absolute   = gkVector2(m_joystick->getAxisValue(0), m_joystick->getAxisValue(1));
	m_camRot.normalize();

	m_movement.m_absolute = gkVector2(m_joystick->getAxisValue(2), m_joystick->getAxisValue(3));
	m_movement.normalize();

	m_isBtn1 = isButtonDownCache(GK_JOY_BUTTON_1, m_btn1Cache);
	m_isBtn2 = isButtonDownCache(GK_JOY_BUTTON_2, m_btn2Cache);
	m_isBtn3 = isButtonDownCache(GK_JOY_BUTTON_3, m_btn3Cache);
}
Esempio n. 2
0
gkVertex::gkVertex()
{
	co = no = (0, 0, 0);
	vcol = 0xFFFFFFFF;
	vba  = -1;
	for (int _i = 0; _i < GK_UV_MAX; _i++)
		uv[_i] = gkVector2(0, 0);
}
Esempio n. 3
0
void gkGamePlayer::loadConstraints()
{
	gkScene* dest = m_levelData->getLevel();

	gkPhysicsProperties& props = m_physics->getProperties().m_physics;
	props.m_mode |= GK_CONTACT;

	// add constraint clamping
	if (m_xRot)
	{
		gkLimitRotConstraint* lr = new gkLimitRotConstraint();
		lr->setLimitX(gkVector2(-90, 5));
		dest->addConstraint(m_xRot, lr);
	}

	if (m_physics)
	{
		gkLimitLocConstraint* ll = new gkLimitLocConstraint();
		ll->setMinX(-30.f);
		ll->setMaxX(30.f);
		ll->setMinY(-30.f);
		ll->setMaxY(30.f);
		ll->setMinZ(0.f);
		ll->setMaxZ(30.f);
		dest->addConstraint(m_physics, ll);
	}

	if (m_camera)
	{
		gkCollisionCameraConstraint* col = new gkCollisionCameraConstraint();
		col->setTarget(m_physics);
		col->setLength(.95f);
		col->setForwardOffs(.125f);
		col->setDownOffs(.125f);	
		dest->addConstraint(m_camera, col);
		m_camera->setMainCamera(true);
	}
}
Esempio n. 4
0
void gkBlenderMeshConverter::convert_legacy(void)
{
	Blender::MFace*  mface = m_bmesh->mface;
	Blender::MVert*  mvert = m_bmesh->mvert;
	Blender::MCol*   mcol =  0;
	Blender::MTFace* mtface[8] = {0, 0, 0, 0, 0, 0, 0, 0};

	Blender::MVert          vpak[4];
	unsigned int            cpak[4];
	unsigned int            ipak[4];
	int                     totlayer;


	gkSubMesh* curSubMesh = 0;
	m_meshtable.clear();

	gkLoaderUtils_getLayers_legacy(m_bmesh, mtface, &mcol, totlayer);

	bool sortByMat          = gkEngine::getSingleton().getUserDefs().blendermat;
	bool openglVertexColor  = gkEngine::getSingleton().getUserDefs().rendersystem == OGRE_RS_GL;


	for (int fi = 0; fi < m_bmesh->totface; fi++)
	{
		const Blender::MFace& curface = mface[fi];

		// skip if face is not a triangle || quad
		if (!curface.v3)
			continue;

		const bool isQuad = curface.v4 != 0;

		TempFace t[2];
		PackedFace f;
		f.totlay = totlayer;

		if (isQuad)
		{
			vpak[0] = mvert[curface.v1];
			vpak[1] = mvert[curface.v2];
			vpak[2] = mvert[curface.v3];
			vpak[3] = mvert[curface.v4];

			ipak[0] = curface.v1;
			ipak[1] = curface.v2;
			ipak[2] = curface.v3;
			ipak[3] = curface.v4;

			if (mcol != 0)
			{
				cpak[0] = packColourABGR(mcol[0]);
				cpak[1] = packColourABGR(mcol[1]);
				cpak[2] = packColourABGR(mcol[2]);
				cpak[3] = packColourABGR(mcol[3]);
			}
			else
				cpak[0] = cpak[1] = cpak[2] = cpak[3] = 0xFFFFFFFF;


			for (int i = 0; i < totlayer; i++)
			{
				if (mtface[i] != 0)
				{
					f.uvLayers[i][0] = gkVector2((float*)mtface[i][fi].uv[0]);
					f.uvLayers[i][1] = gkVector2((float*)mtface[i][fi].uv[1]);
					f.uvLayers[i][2] = gkVector2((float*)mtface[i][fi].uv[2]);
					f.uvLayers[i][3] = gkVector2((float*)mtface[i][fi].uv[3]);
				}
			}
			f.verts     = vpak;
			f.index     = ipak;
			f.colors    = cpak;

			gkVector3 e0, e1;

			e0 = (gkVector3(mvert[curface.v1].co) - gkVector3(mvert[curface.v2].co));
			e1 = (gkVector3(mvert[curface.v3].co) - gkVector3(mvert[curface.v4].co));

			if (e0.squaredLength() < e1.squaredLength())
			{
				convertIndexedTriangle(&t[0], 0, 1, 2, f);
				convertIndexedTriangle(&t[1], 2, 3, 0, f);
			}
			else
			{
				convertIndexedTriangle(&t[0], 0, 1, 3, f);
				convertIndexedTriangle(&t[1], 3, 1, 2, f);
			}
		}
		else
		{
			for (int i = 0; i < totlayer; i++)
			{
				if (mtface[i] != 0)
				{
					f.uvLayers[i][0] = gkVector2((float*)mtface[i][fi].uv[0]);
					f.uvLayers[i][1] = gkVector2((float*)mtface[i][fi].uv[1]);
					f.uvLayers[i][2] = gkVector2((float*)mtface[i][fi].uv[2]);
				}
			}

			vpak[0] = mvert[curface.v1];
			vpak[1] = mvert[curface.v2];
			vpak[2] = mvert[curface.v3];

			ipak[0] = curface.v1;
			ipak[1] = curface.v2;
			ipak[2] = curface.v3;

			if (mcol != 0)
			{
				cpak[0] = packColourABGR(mcol[0]);
				cpak[1] = packColourABGR(mcol[1]);
				cpak[2] = packColourABGR(mcol[2]);
			}
			else
				cpak[0] = cpak[1] = cpak[2] = cpak[3] = 0xFFFFFFFF;

			f.verts     = vpak;
			f.index     = ipak;
			f.colors    = cpak;

			convertIndexedTriangle(&t[0], 0, 1, 2, f);
		}

		gkMeshPair tester(curSubMesh);
		if (sortByMat)
		{
			int mode = 0;
			if (mtface[0])
				mode = mtface[0][fi].mode;

			tester.test = gkMeshHashKey(curface.mat_nr, mode);
		}
		else
		{
			Blender::Image* ima[8] = {0, 0, 0, 0, 0, 0, 0, 0};
			for (int i = 0; i < totlayer; i++)
			{
				if (mtface[i] != 0)
					ima[i] = mtface[i][fi].tpage;
			}

			int mode = 0, alpha = 0;
			if (mtface[0])
			{
				mode    = mtface[0][fi].mode;
				alpha   = mtface[0][fi].transp;
			}

			tester.test = gkMeshHashKey(mode, alpha, ima);
		}

		// find submesh
		UTsize arpos = 0;
		if ((arpos = m_meshtable.find(tester)) == UT_NPOS)
		{
			curSubMesh = new gkSubMesh();

			curSubMesh->setTotalLayers(totlayer);
			curSubMesh->setVertexColors(mcol != 0);

			m_gmesh->addSubMesh(curSubMesh);
			tester.item = curSubMesh;
			m_meshtable.push_back(tester);
		}
		else
			curSubMesh = m_meshtable.at(arpos).item;

		if (curSubMesh == 0) continue;


		if (!(curface.flag & ME_SMOOTH))
		{
			// face normal
			calcNormal(&t[0]);
			if (isQuad)
				t[1].v0.no = t[1].v1.no = t[1].v2.no = t[0].v0.no;
		}

		int triflag = 0;
		if (mtface[0])
		{
			if (mtface[0][fi].mode & TF_DYNAMIC)
				triflag |= gkTriangle::TRI_COLLIDER;
			if (mtface[0][fi].mode & TF_INVISIBLE)
				triflag |= gkTriangle::TRI_INVISIBLE;
		}
		else
			triflag = gkTriangle::TRI_COLLIDER;



		curSubMesh->addTriangle(t[0].v0, t[0].i0,
		                        t[0].v1, t[0].i1,
		                        t[0].v2, t[0].i2, triflag);

		if (isQuad)
		{
			curSubMesh->addTriangle(t[1].v0, t[1].i0,
			                        t[1].v1, t[1].i1,
			                        t[1].v2, t[1].i2, triflag);

		}

		if (mcol)
			mcol += 4;

	}
}
Esempio n. 5
0
void gkBlenderMeshConverter::convert_bmesh(void)
{
	Blender::MVert*  mvert = m_bmesh->mvert;
	Blender::MPoly*  mpoly = m_bmesh->mpoly;
	Blender::MLoop*   mloop = m_bmesh->mloop;
	Blender::MTexPoly* mtexpoly = m_bmesh->mtpoly;
	Blender::MLoopUV* muvloop = m_bmesh->mloopuv;
	Blender::MLoopCol* mloopCol =  m_bmesh->mloopcol;
	// UV-Layer-Data
	Blender::MTexPoly* mtpoly[8] = {0, 0, 0, 0, 0, 0, 0, 0};
	Blender::MLoopUV* muvs[8] = {0, 0, 0, 0, 0, 0, 0, 0};

	bool hasUV = muvloop != 0;


	Blender::MVert          vpak[4];
	unsigned int            cpak[4];
	unsigned int            ipak[4];
	int                     totlayer;


	gkSubMesh* curSubMesh = 0;
	m_meshtable.clear();

	gkLoaderUtils_getLayers_bmesh(m_bmesh, mtpoly,muvs, &mloopCol, totlayer);

	bool sortByMat          = gkEngine::getSingleton().getUserDefs().blendermat;
	bool openglVertexColor  = gkEngine::getSingleton().getUserDefs().rendersystem == OGRE_RS_GL;


	bool hasTexPoly = mtexpoly != 0;

	for (int fi = 0; fi < m_bmesh->totpoly; fi++)
	{
		const Blender::MPoly& curpoly = mpoly[fi];
		const Blender::MTexPoly& curTexPol = mtexpoly[fi];

		// skip if face is not a triangle || quad
		if (curpoly.totloop<3)
			continue;

		if (curpoly.totloop>4){
			gkLogger::write("Using poly with more than 4 verts is not supported by gkMeshConverter!");
			continue;
		}


		const bool isQuad = curpoly.totloop==4;

		TempFace t[2];
		PackedFace f;
		f.totlay = totlayer;

		const Blender::MLoop& v1 = mloop[curpoly.loopstart];
		const Blender::MLoop& v2 = mloop[curpoly.loopstart+1];
		const Blender::MLoop& v3 = mloop[curpoly.loopstart+2];

		if (isQuad)
		{

			const Blender::MLoop& v4 = mloop[curpoly.loopstart+3];

			const Blender::MLoopUV& uv1 = muvloop[curpoly.loopstart];
			const Blender::MLoopUV& uv2 = muvloop[curpoly.loopstart+1];
			const Blender::MLoopUV& uv3 = muvloop[curpoly.loopstart+2];
			const Blender::MLoopUV& uv4 = muvloop[curpoly.loopstart+3];

			vpak[0] = mvert[v1.v];
			vpak[1] = mvert[v2.v];
			vpak[2] = mvert[v3.v];
			vpak[3] = mvert[v4.v];

			ipak[0] = v1.v;
			ipak[1] = v2.v;
			ipak[2] = v3.v;
			ipak[3] = v4.v;

			if (mloopCol != 0)
			{
				cpak[0] = *(unsigned int*)(mloopCol + curpoly.loopstart);
				cpak[1] = *(unsigned int*)(mloopCol + curpoly.loopstart+1);
				cpak[2] = *(unsigned int*)(mloopCol + curpoly.loopstart+2);
				cpak[3] = *(unsigned int*)(mloopCol + curpoly.loopstart+3);
			}
			else
				cpak[0] = cpak[1] = cpak[2] = cpak[3] = 0xFFFFFFFF;


//TODO: Multitexture!?

			for (int i = 0; i < totlayer; i++)
			{
				if (mtpoly[i] != 0)
				{
					f.uvLayers[i][0] = gkVector2((float*)&muvs[i][curpoly.loopstart].uv[0]);
					f.uvLayers[i][1] = gkVector2((float*)&muvs[i][curpoly.loopstart+1].uv[0]);
					f.uvLayers[i][2] = gkVector2((float*)&muvs[i][curpoly.loopstart+2].uv[0]);
					f.uvLayers[i][3] = gkVector2((float*)&muvs[i][curpoly.loopstart+3].uv[0]);
				}
			}

			f.verts     = vpak;
			f.index     = ipak;
			f.colors    = cpak;

			// what is this?
			gkVector3 e0, e1;

			e0 = (gkVector3(mvert[v1.v].co) - gkVector3(mvert[v2.v].co));
			e1 = (gkVector3(mvert[v3.v].co) - gkVector3(mvert[v4.v].co));

			if (e0.squaredLength() < e1.squaredLength())
			{
				convertIndexedTriangle(&t[0], 0, 1, 2, f);
				convertIndexedTriangle(&t[1], 2, 3, 0, f);
			}
			else
			{
				convertIndexedTriangle(&t[0], 0, 1, 3, f);
				convertIndexedTriangle(&t[1], 3, 1, 2, f);
			}
		}
		else
		{
			for (int i = 0; i < totlayer; i++)
			{
				if (mtpoly[i] != 0)
				{
					f.uvLayers[i][0] = gkVector2((float*)&muvs[i][curpoly.loopstart].uv[0]);
					f.uvLayers[i][1] = gkVector2((float*)&muvs[i][curpoly.loopstart+1].uv[0]);
					f.uvLayers[i][2] = gkVector2((float*)&muvs[i][curpoly.loopstart+2].uv[0]);
				}
			}

			vpak[0] = mvert[v1.v];
			vpak[1] = mvert[v2.v];
			vpak[2] = mvert[v3.v];

			ipak[0] = v1.v;
			ipak[1] = v2.v;
			ipak[2] = v3.v;

			if (mloopCol != 0)
			{
				cpak[0] = *(unsigned int*)(mloopCol + curpoly.loopstart);
				cpak[1] = *(unsigned int*)(mloopCol + curpoly.loopstart+1);
				cpak[2] = *(unsigned int*)(mloopCol + curpoly.loopstart+2);
			}
			else
				cpak[0] = cpak[1] = cpak[2] = 0xFFFFFFFF;

			f.verts     = vpak;
			f.index     = ipak;
			f.colors    = cpak;

			convertIndexedTriangle(&t[0], 0, 1, 2, f);
		}


		gkMeshPair tester(curSubMesh);

		if (sortByMat)
		{
			int mode = 0;
			if (mtpoly[0])
				mode = mtpoly[0][fi].mode;


			tester.test = gkMeshHashKey(curpoly.mat_nr, mode);
		}
		else
		{
			Blender::Image* ima[8] = {0, 0, 0, 0, 0, 0, 0, 0};
			for (int i = 0; i < totlayer; i++)
			{
				if (mtpoly[i] != 0)
					ima[i] = mtpoly[i][fi].tpage;
			}


			int mode = 0, alpha = 0;
			if (mtpoly[0])
			{
				mode    = mtpoly[0][fi].mode;
				alpha   = mtpoly[0][fi].transp;
			}


			tester.test = gkMeshHashKey(mode, alpha, ima);
		}

		// find submesh
		UTsize arpos = 0;
		if ((arpos = m_meshtable.find(tester)) == UT_NPOS)
		{
			curSubMesh = new gkSubMesh();

			curSubMesh->setTotalLayers(totlayer);
			curSubMesh->setVertexColors(mloopCol != 0);

			m_gmesh->addSubMesh(curSubMesh);
			tester.item = curSubMesh;
			m_meshtable.push_back(tester);
		}
		else
			curSubMesh = m_meshtable.at(arpos).item;

		if (curSubMesh == 0) continue;


		if (!(curpoly.flag & ME_SMOOTH))
		{
			// face normal
			calcNormal(&t[0]);
			if (isQuad)
				t[1].v0.no = t[1].v1.no = t[1].v2.no = t[0].v0.no;
		}


// ---- warning -----
// mtpoly[0][fi].mode is always 0 which makes the mesh invisible
// For now setting the standardvalue to collider (which means visible)
// This is afaik the only data I couldn't get in import

		int triflag = gkTriangle::TRI_COLLIDER;


		if (mtpoly[0])
		{
			if (mtpoly[0][fi].mode & TF_DYNAMIC)
				triflag |= gkTriangle::TRI_COLLIDER;
			if (mtpoly[0][fi].mode & TF_INVISIBLE)
				triflag |= gkTriangle::TRI_INVISIBLE;
		}
		else
			triflag = gkTriangle::TRI_COLLIDER;

// ---- end warning ------

		curSubMesh->addTriangle(t[0].v0, t[0].i0,
		                        t[0].v1, t[0].i1,
		                        t[0].v2, t[0].i2, triflag);

		if (isQuad)
		{
			curSubMesh->addTriangle(t[1].v0, t[1].i0,
			                        t[1].v1, t[1].i1,
			                        t[1].v2, t[1].i2, triflag);

		}


	}
}
Esempio n. 6
0
void gkBlenderSceneConverter::convertObjectPhysics(gkGameObject* gobj, Blender::Object* bobj)
{
	gkGameObjectProperties&  props  = gobj->getProperties();
	gkPhysicsProperties&     phy    = props.m_physics;
	int boundtype;
	int version = m_file->_getInternalFile()->getVersion();

	if ((bobj->gameflag & OB_COLLISION) && bobj->body_type==GK_NO_COLLISION)
		phy.m_type = GK_STATIC;
	else
	{
		phy.m_type = GK_STATIC;
		switch (bobj->body_type)
		{
		case OB_BODY_TYPE_CHARACTER:	phy.m_type = GK_CHARACTER;      break;
		case OB_BODY_TYPE_RIGID:        phy.m_type = GK_RIGID;          break;
		case OB_BODY_TYPE_DYNAMIC:      phy.m_type = GK_DYNAMIC;        break;
		case OB_BODY_TYPE_NO_COLLISION: phy.m_type = GK_NO_COLLISION;   break;
		case OB_BODY_TYPE_SENSOR :		phy.m_type = GK_SENSOR;         break;
		case OB_BODY_TYPE_NAVMESH :     phy.m_type = GK_NAVMESH;        break;
		}
	}



	if (bobj->type != OB_MESH)
	{
		if (!(bobj->gameflag & OB_ACTOR))
			phy.m_type = GK_NO_COLLISION;
	}


	Blender::Object* parent = bobj->parent;
	while (parent && parent->parent) 
		parent = parent->parent;
	
	if (parent && (bobj->gameflag & OB_CHILD) == 0)
		phy.m_type = GK_NO_COLLISION;


	if (!props.isPhysicsObject())
		return;

	if (bobj->gameflag & OB_ACTOR)
	{
		props.m_mode    |= GK_ACTOR;
		phy.m_mode      |= GK_CONTACT;
	}
	if (bobj->gameflag & OB_GHOST)
		props.m_mode |= GK_GHOST;
	if (bobj->gameflag & OB_OCCLUDER)
		props.m_mode |= GK_OCCLUDER;

	if (bobj->gameflag  & OB_CHILD)							phy.m_mode |= parent ? GK_COMPOUND_CHILD : GK_COMPOUND;
	if (bobj->gameflag  & OB_COLLISION_RESPONSE)            phy.m_mode |= GK_NO_SLEEP;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_X_AXIS)        phy.m_mode |= GK_LOCK_LINV_X;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_Y_AXIS)        phy.m_mode |= GK_LOCK_LINV_Y;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_Z_AXIS)        phy.m_mode |= GK_LOCK_LINV_Z;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_X_ROT_AXIS)    phy.m_mode |= GK_LOCK_ANGV_X;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_Y_ROT_AXIS)    phy.m_mode |= GK_LOCK_ANGV_Y;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_Z_ROT_AXIS)    phy.m_mode |= GK_LOCK_ANGV_Z;

	phy.m_minVel        = bobj->min_vel;
	phy.m_maxVel        = bobj->max_vel;
	phy.m_cpt           = bobj->m_contactProcessingThreshold;
	phy.m_linearDamp    = bobj->damping;
	phy.m_angularDamp   = bobj->rdamping;
	phy.m_mass          = bobj->mass;
	phy.m_radius        = bobj->inertia;
	phy.m_formFactor    = bobj->formfactor;
	phy.m_margin        = bobj->margin;

	if (bobj->col_group>0 && bobj->col_mask>0) {
		phy.m_colGroupMask = bobj->col_group;
		phy.m_colMask = bobj->col_mask;
		phy.m_charStepHeight = bobj->step_height;
		phy.m_charJumpSpeed = bobj->jump_speed;
		phy.m_charFallSpeed = bobj->fall_speed;
	}

	if (gobj->hasVariable("gk_collisionmask")){
		phy.m_colMask = gobj->getVariable("gk_collisionmask")->getValueInt();
	}
	if (gobj->hasVariable("gk_collisiongroup")){
		phy.m_colGroupMask = gobj->getVariable("gk_collisiongroup")->getValueInt();
	}

	if (bobj->type == OB_MESH)
	{
		Blender::Mesh* me = (Blender::Mesh*)bobj->data;

		if (me)
		{
			Blender::Material* ma = BlenderMaterial(bobj, 0);
			if (ma)
			{
				phy.m_restitution   = ma->reflect;
				phy.m_friction      = ma->friction;
			}

		}
	}
	
	if (version<=260)
		boundtype = bobj->boundtype;
	else
		boundtype = bobj->collision_boundtype;
	
	if (!(bobj->gameflag & OB_BOUNDS))
		if (bobj->body_type == OB_BODY_TYPE_STATIC)
			boundtype = OB_BOUND_TRIANGLE_MESH;
		else
			boundtype = OB_BOUND_BOX;

	switch (boundtype)
	{
	case OB_BOUND_BOX:
		phy.m_shape = SH_BOX;
		break;
	case OB_BOUND_SPHERE:
		phy.m_shape = SH_SPHERE;
		break;
	case OB_BOUND_CONE:
		phy.m_shape = SH_CONE;
		break;
	case OB_BOUND_CYLINDER:
		phy.m_shape = SH_CYLINDER;
		break;
	case OB_BOUND_CONVEX_HULL:
		phy.m_shape = SH_CONVEX_TRIMESH;
		break;
	case OB_BOUND_TRIANGLE_MESH:
		if (bobj->type == OB_MESH)
		{
		if (phy.isRigidOrDynamic())
			phy.m_shape = SH_GIMPACT_MESH;
		else
			phy.m_shape = SH_BVH_MESH;
		}
		else
			phy.m_shape = SH_SPHERE;
		break;
	case OB_BOUND_CAPSULE:
		phy.m_shape = SH_CAPSULE;
		break;
	}
		
		
	// setup velocity constraints
	if (phy.isRigidOrDynamic())
	{
		if (phy.m_minVel > 0.f || phy.m_maxVel > 0.f)
		{
			gkLimitVelocityConstraint* vc = new gkLimitVelocityConstraint();
			vc->setLimit(gkVector2(phy.m_minVel, phy.m_maxVel));

			m_gscene->getConstraintManager()->addConstraint(gobj, vc);
		}
	}
}
Esempio n. 7
0
void gkBlenderSceneConverter::convertObjectConstraints(gkGameObject* gobj, Blender::Object* bobj)
{
	// TODO: add more constraints
	gkConstraintManager* mgr = m_gscene->getConstraintManager();

	for (Blender::bConstraint* bc = (Blender::bConstraint*)bobj->constraints.first; bc; bc = bc->next)
	{

		if (bc->type == CONSTRAINT_TYPE_RIGIDBODYJOINT)
		{

			Blender::bRigidBodyJointConstraint* jc = (Blender::bRigidBodyJointConstraint*)bc->data;

			gkPhysicsConstraintProperties p;
			p.m_target = GKB_IDNAME(jc->tar);
			p.m_axis  = gkVector3(jc->axX, jc->axY, jc->axZ);
			p.m_pivot = gkVector3(jc->pivX, jc->pivY, jc->pivZ);
			for (int i = 0; i < 6; i++)
			{
				p.m_minLimit[i] = jc->minLimit[i];
				p.m_maxLimit[i] = jc->maxLimit[i];
			}
			p.m_flag = jc->flag;
			p.m_disableLinkedCollision = (jc->flag & CONSTRAINT_DISABLE_LINKED_COLLISION) != 0;

			
			if (jc->type == CONSTRAINT_RB_BALL)
				p.m_type = GK_BALL_CONSTRAINT;
			else if (jc->type == CONSTRAINT_RB_HINGE)
				p.m_type = GK_HINGE_CONSTRAINT;			
			else if (jc->type == CONSTRAINT_RB_CONETWIST)			
				p.m_type = GK_CONETWIST_CONSTRAINT;			
			else if (jc->type == CONSTRAINT_RB_VEHICLE)			
				p.m_type = GK_VEHICLE_CONSTRAINT;			
			else if (jc->type == CONSTRAINT_RB_GENERIC6DOF)			
				p.m_type = GK_D6_CONSTRAINT;

			gobj->getProperties().m_physics.m_constraints.push_back(p);

		}
		else
		{
			if (bc->enforce == 0.0)
				continue;

			gkConstraint* co = 0;

			if (bc->type == CONSTRAINT_TYPE_ROTLIMIT)
			{
				// rotation is in radians.
				Blender::bRotLimitConstraint* lr = (Blender::bRotLimitConstraint*)bc->data;
				if (!lr->flag)
					continue;

				gkLimitRotConstraint* c = new gkLimitRotConstraint();
				co = c;

				if (lr->flag & LIMIT_XROT)
					c->setLimitX(gkVector2(lr->xmin * gkDPR, lr->xmax * gkDPR));
				if (lr->flag & LIMIT_YROT)
					c->setLimitY(gkVector2(lr->ymin * gkDPR, lr->ymax * gkDPR));
				if (lr->flag & LIMIT_ZROT)
					c->setLimitZ(gkVector2(lr->zmin * gkDPR, lr->zmax * gkDPR));
			}
			else if (bc->type == CONSTRAINT_TYPE_LOCLIMIT)
			{
				Blender::bLocLimitConstraint* ll = (Blender::bLocLimitConstraint*)bc->data;
				if (!ll->flag)
					continue;

				gkLimitLocConstraint* c = new gkLimitLocConstraint();
				co = c;


				if (ll->flag & LIMIT_XMIN) c->setMinX(ll->xmin);
				if (ll->flag & LIMIT_XMAX) c->setMaxX(ll->xmax);
				if (ll->flag & LIMIT_YMIN) c->setMinY(ll->ymin);
				if (ll->flag & LIMIT_YMAX) c->setMaxY(ll->ymax);
				if (ll->flag & LIMIT_ZMIN) c->setMinZ(ll->zmin);
				if (ll->flag & LIMIT_ZMAX) c->setMaxZ(ll->zmax);
			}

			if (co)
			{
				co->setSpace(bc->ownspace == CONSTRAINT_SPACE_LOCAL ? TRANSFORM_LOCAL : TRANSFORM_WORLD);
				co->setInfluence(bc->enforce);		
	
				mgr->addConstraint(gobj, co);
			}
		}
	}
}
Esempio n. 8
0
int OgreKit::setup(int argc, char** argv)
{
	int winsize_x		= 800;
	int winsize_y		= 600;
	m_prefs.wintitle	= gkString("OgreKit Demo (Press Escape to exit)[") + m_blend + gkString("]");


	gkString cfgfname;

	// Parse command line
	try
	{
		TCLAP::CmdLine cmdl("Ogrekit", ' ', "n/a");
		cmdl.setExceptionHandling(false);

		//cfg arguments

		TCLAP::ValueArg<std::string>	rendersystem_arg		("r", "rendersystem",			"Set rendering system. (gl, d3d9, d3d10, d3d11)", false, "", "string"); //default GL
		TCLAP::ValueArg<std::string>	viewportOrientation_arg	("",  "viewportorientation",	"Set viewport orientation.", false, m_prefs.viewportOrientation, "string"); 
		TCLAP::ValueArg<std::string>	log_arg					("",  "log",					"Set log file name.", false, m_prefs.log, "string"); 
		TCLAP::ValueArg<bool>			verbose_arg				("v", "verbose",				"Enable verbose log.", false, m_prefs.verbose, "bool");
		TCLAP::ValueArg<int>			winsize_x_arg			("",  "width",					"Set window width.", false, winsize_x, "int");
		TCLAP::ValueArg<int>			winsize_y_arg			("",  "height",					"Set window height.", false, winsize_y, "int");
		TCLAP::ValueArg<std::string>	wintitle_arg			("",  "wintitle",				"Set window title.", false, m_prefs.wintitle, "string"); 
		TCLAP::ValueArg<bool>			fullscreen_arg			("f", "fullscreen",				"Enable fullscreen mode.", false, m_prefs.fullscreen, "bool");
		TCLAP::ValueArg<std::string>	framingType_arg			("",  "framingtype",			"Set viewport framing type. (extend, crop, letterbox)", false, "", "string");
		TCLAP::ValueArg<std::string>	resources_arg			("",  "resources",				"Set resouces.", false, m_prefs.resources, "string");
		TCLAP::ValueArg<bool>			blendermat_arg			("",  "blendmat",				"Convert meshes using blender materials.", false, m_prefs.blendermat, "bool");
		TCLAP::ValueArg<bool>			matblending_arg			("",  "matblending",			"Enable material pass blending mode.", false, m_prefs.matblending, "bool");		
		TCLAP::ValueArg<bool>			grapInput_arg			("g", "grabinput",				"Grap mouse input.", false, m_prefs.grabInput, "bool");
		TCLAP::ValueArg<bool>			debugFps_arg			("d", "debugfps",				"Display debug fps.", false, m_prefs.debugFps, "bool");
		TCLAP::ValueArg<bool>			vsync_arg				("", "vsync",					"enable vertical-sync.", false, m_prefs.vsync, "bool");
		TCLAP::ValueArg<int>			vsyncrate_arg			("",  "vsync-rate",				"Set vsync-rate ", 0, m_prefs.vsyncRate, "int");

		TCLAP::ValueArg<bool>			debugPhysics_arg		("p", "debugphysics",			"Display debug physics.", false, m_prefs.debugPhysics, "bool");
		TCLAP::ValueArg<bool>			debugPhysicsAabb_arg	("a", "debugphysicsaabb",		"Display debug physics aabb.", false, m_prefs.debugPhysicsAabb, "bool");
		TCLAP::ValueArg<bool>			buildStaticGeometry_arg	("",  "buildinstances",			"Build Static Geometry.", false, m_prefs.buildStaticGeometry, "bool");
		TCLAP::ValueArg<bool>			useBulletDbvt_arg		("",  "frustumculling",			"Enable view frustum culling by dbvt.", false, m_prefs.useBulletDbvt, "bool");
		TCLAP::ValueArg<bool>			showDebugProps_arg		("t", "showdebugprops",			"Show debug props.", false, m_prefs.showDebugProps, "bool");
		TCLAP::ValueArg<bool>			debugSounds_arg			("",  "debugsounds",			"Debug sounds.", false, m_prefs.debugSounds, "bool");
		TCLAP::ValueArg<bool>			disableSound_arg		("s", "disablesound",			"Disable sounds.", false, m_prefs.disableSound, "bool");
		TCLAP::ValueArg<bool>			fsaa_arg				("",  "fsaa",					"Enable fsaa.", false, m_prefs.fsaa, "bool");
		TCLAP::ValueArg<int>			fsaaSamples_arg			("",  "fsaasSamples",			"Set fsaa samples.", false, m_prefs.fsaaSamples, "int");
		TCLAP::ValueArg<bool>			enableshadows_arg		("",  "enableshadows",			"Enable Shadows.", false, m_prefs.enableshadows, "bool");
		TCLAP::ValueArg<int>			defaultMipMap_arg		("",  "defaultmipmap",			"Set default mipMap.", false, m_prefs.defaultMipMap, "int");
		TCLAP::ValueArg<std::string>	shadowtechnique_arg		("",  "shadowtechnique",		"Set shadow technique.", false, m_prefs.shadowtechnique, "string"); 
		TCLAP::ValueArg<std::string>	colourshadow_arg		("",  "colourshadow",			"Set shadow colour.", false, "", "string"); 
		TCLAP::ValueArg<float>			fardistanceshadow_arg	("",  "fardistanceshadow",		"Set far distance shadow.", false, m_prefs.fardistanceshadow, "float"); 
		TCLAP::ValueArg<std::string>	shaderCachePath_arg		("",  "shadercachepath",		"RTShaderSystem cache file path.", false, m_prefs.shaderCachePath, "string"); 
		

		cmdl.add(rendersystem_arg);
		cmdl.add(viewportOrientation_arg);
		cmdl.add(log_arg);
		cmdl.add(verbose_arg);
		cmdl.add(winsize_x_arg);
		cmdl.add(winsize_y_arg);
		cmdl.add(wintitle_arg);
		cmdl.add(fullscreen_arg);
		cmdl.add(framingType_arg);
		cmdl.add(resources_arg);
		cmdl.add(blendermat_arg);
		cmdl.add(matblending_arg);
		cmdl.add(grapInput_arg);
		cmdl.add(debugFps_arg);
		cmdl.add(debugPhysics_arg);	
		cmdl.add(vsync_arg);
		cmdl.add(vsyncrate_arg);
		cmdl.add(debugPhysicsAabb_arg);	
		cmdl.add(buildStaticGeometry_arg);
		cmdl.add(useBulletDbvt_arg);
		cmdl.add(showDebugProps_arg);
		cmdl.add(debugSounds_arg);
		cmdl.add(disableSound_arg);
		cmdl.add(fsaa_arg);
		cmdl.add(fsaaSamples_arg);
		cmdl.add(enableshadows_arg);
		cmdl.add(defaultMipMap_arg);
		cmdl.add(shadowtechnique_arg);
		cmdl.add(colourshadow_arg);
		cmdl.add(fardistanceshadow_arg);
		cmdl.add(shaderCachePath_arg);

		//input file arguments
		
		TCLAP::ValueArg<std::string>			cfgfname_arg("c", "config-file", "Startup configuration file (.cfg) to use.", false, gkDefaultConfig, "string");
		TCLAP::UnlabeledValueArg<std::string>	bfname_arg("blender-file", "Blender file to launch as game.", false, gkDefaultBlend, "string");

		cmdl.add(cfgfname_arg);
		cmdl.add(bfname_arg);

		cmdl.parse( argc, argv );

		cfgfname						= cfgfname_arg.getValue();
		m_blend							= bfname_arg.getValue();

		m_prefs.rendersystem			= gkUserDefs::getOgreRenderSystem(rendersystem_arg.getValue());
		m_prefs.viewportOrientation		= viewportOrientation_arg.getValue();
		//m_prefs.sceneManager			= sceneManager_arg.getValue();
		m_prefs.log						= log_arg.getValue();
		m_prefs.verbose					= verbose_arg.getValue();

		m_prefs.winsize					= gkVector2(winsize_x_arg.getValue(), winsize_y_arg.getValue());
		m_prefs.wintitle				= wintitle_arg.getValue();

		m_prefs.fullscreen				= fullscreen_arg.getValue();
		m_prefs.framingType				= gkUserDefs::getViewportFramingType(framingType_arg.getValue());
		m_prefs.resources				= resources_arg.getValue();
		m_prefs.blendermat				= blendermat_arg.getValue();
		m_prefs.matblending				= matblending_arg.getValue();
		m_prefs.grabInput				= grapInput_arg.getValue();
		m_prefs.debugFps				= debugFps_arg.getValue();
		m_prefs.debugPhysics			= debugPhysics_arg.getValue();
		m_prefs.debugPhysicsAabb		= debugPhysicsAabb_arg.getValue();
		m_prefs.buildStaticGeometry		= buildStaticGeometry_arg.getValue();
		m_prefs.useBulletDbvt			= useBulletDbvt_arg.getValue();
		m_prefs.showDebugProps			= showDebugProps_arg.getValue();
		m_prefs.debugSounds				= debugSounds_arg.getValue();
		m_prefs.disableSound			= disableSound_arg.getValue();

		m_prefs.vsync					= vsync_arg.getValue();
		m_prefs.vsyncRate				= vsyncrate_arg.getValue();

		m_prefs.fsaa					= fsaa_arg.getValue();
		m_prefs.fsaaSamples				= fsaaSamples_arg.getValue();
		m_prefs.enableshadows			= enableshadows_arg.getValue();
		m_prefs.defaultMipMap			= defaultMipMap_arg.getValue();
		m_prefs.shadowtechnique			= shadowtechnique_arg.getValue();
		m_prefs.fardistanceshadow		= fardistanceshadow_arg.getValue();	
		m_prefs.shaderCachePath			= shaderCachePath_arg.getValue();

		if (colourshadow_arg.isSet())
			m_prefs.colourshadow		= Ogre::StringConverter::parseColourValue(colourshadow_arg.getValue());

#ifdef __APPLE__
		if (m_blend.find("-psn") != gkString::npos)
			m_blend = gkDefaultBlend;
#endif

	}
	catch (TCLAP::ArgException& e)
	{
		std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
		return -1;
	}
	catch (TCLAP::ExitException&)
	{
		// just return and exit app
		return -1;
	}
	catch (...)
	{
		std::cerr << "Unknown exception." << std::endl;
		return -1;
	}



	gkPath path = cfgfname;

	// overide settings if found
	if (path.isFile())
		m_prefs.load(path.getPath());

	return 0;
}
Esempio n. 9
0
void gkBlenderSceneConverter::convertObjectPhysics(gkGameObject* gobj, Blender::Object* bobj)
{
	gkGameObjectProperties&  props  = gobj->getProperties();
	gkPhysicsProperties&     phy    = props.m_physics;

	phy.m_type = GK_STATIC;
	switch (bobj->body_type)
	{
	case OB_BODY_TYPE_RIGID:        phy.m_type = GK_RIGID;          break;
	case OB_BODY_TYPE_DYNAMIC:      phy.m_type = GK_DYNAMIC;        break;
	case OB_BODY_TYPE_NO_COLLISION: phy.m_type = GK_NO_COLLISION;   break;
	}

	if (bobj->type != OB_MESH)
	{
		if (!(bobj->gameflag & OB_ACTOR))
			phy.m_type = GK_NO_COLLISION;
	}


	Blender::Object* parent = bobj->parent;
	while (parent && parent->parent) 
		parent = parent->parent;
	
	if (parent && (bobj->gameflag  & OB_CHILD) == 0)
		phy.m_type = GK_NO_COLLISION;


	if (!props.isPhysicsObject())
		return;

	if (bobj->gameflag & OB_ACTOR)
	{
		props.m_mode    |= GK_ACTOR;
		phy.m_mode      |= GK_CONTACT;
	}
	if (bobj->gameflag & OB_GHOST)
		props.m_mode |= GK_GHOST;
	if (bobj->gameflag & OB_OCCLUDER)
		props.m_mode |= GK_OCCLUDER;

	if (bobj->gameflag  & OB_CHILD)							phy.m_mode |= parent ? GK_COMPOUND_CHILD : GK_COMPOUND;
	if (bobj->gameflag  & OB_COLLISION_RESPONSE)            phy.m_mode |= GK_NO_SLEEP;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_X_AXIS)        phy.m_mode |= GK_LOCK_LINV_X;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_Y_AXIS)        phy.m_mode |= GK_LOCK_LINV_Y;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_Z_AXIS)        phy.m_mode |= GK_LOCK_LINV_Z;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_X_ROT_AXIS)    phy.m_mode |= GK_LOCK_ANGV_X;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_Y_ROT_AXIS)    phy.m_mode |= GK_LOCK_ANGV_Y;
	if (bobj->gameflag2 & OB_LOCK_RIGID_BODY_Z_ROT_AXIS)    phy.m_mode |= GK_LOCK_ANGV_Z;

	phy.m_minVel        = bobj->min_vel;
	phy.m_maxVel        = bobj->max_vel;
	phy.m_cpt           = bobj->m_contactProcessingThreshold;
	phy.m_linearDamp    = bobj->damping;
	phy.m_angularDamp   = bobj->rdamping;
	phy.m_mass          = bobj->mass;
	phy.m_radius        = bobj->inertia;
	phy.m_formFactor    = bobj->formfactor;
	phy.m_margin        = bobj->margin;

	if (bobj->type == OB_MESH)
	{
		Blender::Mesh* me = (Blender::Mesh*)bobj->data;

		if (me)
		{
			Blender::Material* ma = BlenderMaterial(bobj, 0);
			if (ma)
			{
				phy.m_restitution   = ma->reflect;
				phy.m_friction      = ma->friction;
			}

		}
	}

	if (phy.isRigidOrDynamic())
	{
		switch (bobj->boundtype)
		{
		case OB_BOUND_BOX:
			phy.m_shape = SH_BOX;
			break;
		case OB_BOUND_SPHERE:
			phy.m_shape = SH_SPHERE;
			break;
		case OB_BOUND_CONE:
			phy.m_shape = SH_CONE;
			break;
		case OB_BOUND_CYLINDER:
			phy.m_shape = SH_CYLINDER;
			break;
		case OB_BOUND_POLYT:
			phy.m_shape = SH_CONVEX_TRIMESH;
			break;
		case OB_BOUND_POLYH:
		case OB_BOUND_DYN_MESH:
			phy.m_shape = SH_GIMPACT_MESH;
			break;
		}
	}
	else
	{
		if (bobj->type == OB_MESH)
			phy.m_shape = SH_BVH_MESH;
		else
			phy.m_shape = SH_SPHERE;
	}

	// setup velocity constraints
	if (phy.isRigidOrDynamic())
	{
		if (phy.m_minVel > 0.f || phy.m_maxVel > 0.f)
		{
			gkLimitVelocityConstraint* vc = new gkLimitVelocityConstraint();
			vc->setLimit(gkVector2(phy.m_minVel, phy.m_maxVel));

			m_gscene->getConstraintManager()->addConstraint(gobj, vc);
		}
	}
}
Esempio n. 10
0
void gkBlenderMeshConverter::convert(void)
{
	Blender::MFace*  mface = m_bmesh->mface;
	Blender::MVert*  mvert = m_bmesh->mvert;
	Blender::MCol*   mcol =  0;
	Blender::MTFace* mtface[8] = {0, 0, 0, 0, 0, 0, 0, 0};


	if (!mface || !mvert)
		return;

	Blender::MVert          vpak[4];
	unsigned int            cpak[4];
	unsigned int            ipak[4];
	int                     totlayer;


	gkSubMesh* curSubMesh = 0;
	utArray<gkMeshPair> meshtable;

	gkLoaderUtils_getLayers(m_bmesh, mtface, &mcol, totlayer);

	bool sortByMat          = gkEngine::getSingleton().getUserDefs().blendermat;
	bool openglVertexColor  = gkEngine::getSingleton().getUserDefs().rendersystem == OGRE_RS_GL;


	AssignmentListMap assignMap;
	bool canAssign = m_bmesh->dvert && m_bobj->parent && m_bobj->parent->type == OB_ARMATURE;
	if (canAssign)
	{
		int dgi = 0;
		for (Blender::bDeformGroup* dg = (Blender::bDeformGroup*)m_bobj->defbase.first; dg; dg = dg->next, ++dgi)
		{
			m_gmesh->createVertexGroup(dg->name);
			convertBoneAssignments(dgi, assignMap);
		}
	}



	for (int fi = 0; fi < m_bmesh->totface; fi++)
	{
		const Blender::MFace& curface = mface[fi];

		// skip if face is not a triangle || quad
		if (!curface.v3)
			continue;

		const bool isQuad = curface.v4 != 0;

		TempFace t[2];
		PackedFace f;
		f.totlay = totlayer;

		if (isQuad)
		{
			vpak[0] = mvert[curface.v1];
			vpak[1] = mvert[curface.v2];
			vpak[2] = mvert[curface.v3];
			vpak[3] = mvert[curface.v4];

			ipak[0] = curface.v1;
			ipak[1] = curface.v2;
			ipak[2] = curface.v3;
			ipak[3] = curface.v4;

			if (mcol != 0)
			{
				cpak[0] = packColour(mcol[0], openglVertexColor);
				cpak[1] = packColour(mcol[1], openglVertexColor);
				cpak[2] = packColour(mcol[2], openglVertexColor);
				cpak[3] = packColour(mcol[3], openglVertexColor);
			}
			else
				cpak[0] = cpak[1] = cpak[2] = cpak[3] = 0xFFFFFFFF;


			for (int i = 0; i < totlayer; i++)
			{
				if (mtface[i] != 0)
				{
					f.uvLayers[i][0] = gkVector2((float*)mtface[i][fi].uv[0]);
					f.uvLayers[i][1] = gkVector2((float*)mtface[i][fi].uv[1]);
					f.uvLayers[i][2] = gkVector2((float*)mtface[i][fi].uv[2]);
					f.uvLayers[i][3] = gkVector2((float*)mtface[i][fi].uv[3]);
				}
			}
			f.verts     = vpak;
			f.index     = ipak;
			f.colors    = cpak;

			gkVector3 e0, e1;

			e0 = (gkVector3(mvert[curface.v1].co) - gkVector3(mvert[curface.v2].co));
			e1 = (gkVector3(mvert[curface.v3].co) - gkVector3(mvert[curface.v4].co));

			if (e0.squaredLength() < e1.squaredLength())
			{
				convertIndexedTriangle(&t[0], 0, 1, 2, f);
				convertIndexedTriangle(&t[1], 2, 3, 0, f);
			}
			else
			{
				convertIndexedTriangle(&t[0], 0, 1, 3, f);
				convertIndexedTriangle(&t[1], 3, 1, 2, f);
			}
		}
		else
		{
			for (int i = 0; i < totlayer; i++)
			{
				if (mtface[i] != 0)
				{
					f.uvLayers[i][0] = gkVector2((float*)mtface[i][fi].uv[0]);
					f.uvLayers[i][1] = gkVector2((float*)mtface[i][fi].uv[1]);
					f.uvLayers[i][2] = gkVector2((float*)mtface[i][fi].uv[2]);
				}
			}

			vpak[0] = mvert[curface.v1];
			vpak[1] = mvert[curface.v2];
			vpak[2] = mvert[curface.v3];

			ipak[0] = curface.v1;
			ipak[1] = curface.v2;
			ipak[2] = curface.v3;

			if (mcol != 0)
			{
				cpak[0] = packColour(mcol[0], openglVertexColor);
				cpak[1] = packColour(mcol[1], openglVertexColor);
				cpak[2] = packColour(mcol[2], openglVertexColor);
			}
			else
				cpak[0] = cpak[1] = cpak[2] = cpak[3] = 0xFFFFFFFF;

			f.verts     = vpak;
			f.index     = ipak;
			f.colors    = cpak;

			convertIndexedTriangle(&t[0], 0, 1, 2, f);
		}

		gkMeshPair tester(curSubMesh);
		if (sortByMat)
		{
			int mode = 0;
			if (mtface[0])
				mode = mtface[0][fi].mode;

			tester.test = gkMeshHashKey(curface.mat_nr, mode);
		}
		else
		{
			Blender::Image* ima[8] = {0, 0, 0, 0, 0, 0, 0, 0};
			for (int i = 0; i < totlayer; i++)
			{
				if (mtface[i] != 0)
					ima[i] = mtface[i][fi].tpage;
			}

			int mode = 0, alpha = 0;
			if (mtface[0])
			{
				mode    = mtface[0][fi].mode;
				alpha   = mtface[0][fi].transp;
			}

			tester.test = gkMeshHashKey(mode, alpha, ima);
		}

		// find submesh
		UTsize arpos = 0;
		if ((arpos = meshtable.find(tester)) == UT_NPOS)
		{
			curSubMesh = new gkSubMesh();

			curSubMesh->setTotalLayers(totlayer);
			curSubMesh->setVertexColors(mcol != 0);

			m_gmesh->addSubMesh(curSubMesh);
			tester.item = curSubMesh;
			meshtable.push_back(tester);
		}
		else
			curSubMesh = meshtable.at(arpos).item;

		if (curSubMesh == 0) continue;


		if (!(curface.flag & ME_SMOOTH))
		{
			// face normal
			calcNormal(&t[0]);
			if (isQuad)
				t[1].v0.no = t[1].v1.no = t[1].v2.no = t[0].v0.no;
		}

		int triflag = 0;
		if (mtface[0])
		{
			if (mtface[0][fi].mode & TF_DYNAMIC)
				triflag |= gkTriangle::TRI_COLLIDER;
			if (mtface[0][fi].mode & TF_INVISIBLE)
				triflag |= gkTriangle::TRI_INVISIBLE;
		}
		else
			triflag = gkTriangle::TRI_COLLIDER;



		curSubMesh->addTriangle(t[0].v0, t[0].i0,
		                        t[0].v1, t[0].i1,
		                        t[0].v2, t[0].i2, triflag);

		if (isQuad)
		{
			curSubMesh->addTriangle(t[1].v0, t[1].i0,
			                        t[1].v1, t[1].i1,
			                        t[1].v2, t[1].i2, triflag);

		}

		if (mcol)
			mcol += 4;

	}

	// build materials
	utArrayIterator<utArray<gkMeshPair> > iter(meshtable);

	while (iter.hasMoreElements())
	{
		gkMeshHashKey& key  = iter.peekNext().test;
		gkSubMesh* val      = iter.peekNext().item;



		Blender::Material* bmat = BlenderMaterial(m_bobj, key.m_matnr);
		if (key.m_blenderMat)
		{
			if (bmat)
				convertMaterial(bmat, val->getMaterial(), key);
		}
		else
			convertTextureFace(val->getMaterial(), key, (Blender::Image**)key.m_images);

		if (canAssign)
		{
			// build def groups
			assignBoneAssignments(val, assignMap);

		}

		iter.getNext();
	}
}