コード例 #1
0
ファイル: scene.cpp プロジェクト: AdrienTD/wkbre
void DrawOOBM()
{
	uint tt = timeGetTime();
	renderer->BeginBatchDrawing();
	SetTransformMatrix(&vpmatrix);
	mshbatch->begin();
	for(int t = 0; t < strMaterials.len; t++)
	{
		int txset = 0;
		for(int a = 0; a < 2; a++)
		{
			int afset = 0;
			GrowList<GameObject*> *l = 0; // = &((oobm[a])[t]);
			for(int i = 0; i < oobm[a].len; i++)
				if(oobm[a].getpnt(i)->tid == t)
					{l = oobm[a].getpnt(i)->objs; break;}
			if(!l) continue;

			for(int i = 0; i < l->len; i++)
			{
				GameObject *o = l->get(i);

				int dif = -1;
				if((o->flags & FGO_SELECTED) || (currentSelection == o))
				{
					if((o->flags & FGO_SELECTED) && (currentSelection == o))
						dif = 0xFFFF00FF;
					else
						dif = (currentSelection==o)?0xFFFF0000:0xFF0000FF;
				}

				//Model *md = o->objdef->subtypes[o->subtype].appear[o->appearance].def;
				Model *md = GetObjectModel(o);
				if(showrepresentations && o->objdef->representation) md = o->objdef->representation;
				md->prepare(); md->mesh->prepare();
				Mesh *msh = md->mesh;
				// If md != md->mesh, this means that md is an Anim!
				SetMatrices(o->scale, -o->orientation, o->position);
				Matrix mWorldCopy = mWorld;

				uint tm = (int)(current_time*1000.0f) - o->animtimeref;
				// If the current task has SYNCH_ANIMATION_TO_FRACTION, use it.
				if(md != md->mesh) if(o->ordercfg.order.len)
				{
					STask *st = &o->ordercfg.order.first->value.task.first->value;
					if(st->type->satf)
					{
						SequenceEnv env; env.self = o;
						tm = st->type->satf->get(&env) * ((Anim*)md)->dur;
						tm = st->lastsatf + (tm - st->lastsatf) * elapsed_time * 0.5f;
						if(tm >= ((Anim*)md)->dur) tm = ((Anim*)md)->dur - 1;
						st->lastsatf = tm;
					}
				}
				if(o->animlooping) if(md != md->mesh)
					tm %= ((Anim*)md)->dur;

				for(int g = 0; g < msh->ngrp; g++)
					if((msh->lstmatflags[g] == a) && (msh->lstmattid[g] == t))
					{
						if(!txset) {txset = 1; SetTexture(0, msh->lstmattex[g]);}
						if(!afset) {afset = 1; if(a) renderer->EnableAlphaTest(); else renderer->DisableAlphaTest();}

						(animsEnabled?md:md->mesh)->drawInBatch(mshbatch, g, o->color, dif, tm);
					}

				for(int j = 0; j < msh->nAttachPnts; j++)
					if(msh->attachPnts[j].model)
					if(md->isAttachPointOn(j, tm))
					{
						Model *apmd = msh->attachPnts[j].model;
						Mesh *apms = apmd->mesh;
						for(int g = 0; g < apms->ngrp; g++)
							if((apms->lstmatflags[g] == a) && (apms->lstmattid[g] == t))
							{
								if(!txset) {txset = 1; SetTexture(0, apms->lstmattex[g]);}
								if(!afset) {afset = 1; if(a) renderer->EnableAlphaTest(); else renderer->DisableAlphaTest();}

								uint aptm = current_time * 1000;
								if(apmd != apmd->mesh)
									aptm %= ((Anim*)apmd)->dur;

								Vector3 p, s;
								md->getAttachPointPos(&s, j, tm);
								TransformVector3(&p, &s, &mWorldCopy);
								SetMatrices(Vector3(1,1,1), Vector3(0,0,0), p);

								(animsEnabled?apmd:apms)->drawInBatch(mshbatch, g, o->color, dif, aptm);
							}
					}
			}

			l->clear();
			mshbatch->flush();
		}
		mshbatch->flush();
	}
	mshbatch->end();
}
コード例 #2
0
ファイル: rQuaternion.cpp プロジェクト: Kaneta1011/fbx-anim
rVector3 rQuaternion::GetTransformedVector3(const rVector3& v) const{
	rVector3 returnVec = v;
	TransformVector3(returnVec);
	return returnVec;
}
コード例 #3
0
ファイル: rMatrix4.cpp プロジェクト: aedotcom/recondite
rVector3 rMatrix4::GetTransformedVector3(const rVector3& v) const{
	rVector3 r = v;
	TransformVector3(r);
	return r;
}