Esempio n. 1
0
void SetMatrices(Vector3 is, Vector3 ir, Vector3 it)
{
	Matrix mscale, mrot, mtrans;
	CreateScaleMatrix(&mscale, is.x, is.y, is.z);
	CreateRotationYXZMatrix(&mrot, ir.y, ir.x, ir.z);
	CreateTranslationMatrix(&mtrans, it.x, it.y, it.z);

	mWorld = mscale*mrot*mtrans;
	//MultiplyMatrices(&mReal, &mWorld, &vpmatrix);
	//TransposeMatrix(&matrix, &mReal);
	MultiplyMatrices(&matrix, &mWorld, &vpmatrix);
	//ddev->SetTransform( D3DTS_WORLD, &matrix );

	//mWorldMulView = mWorld * matView;
}
Esempio n. 2
0
OrientedBoundingBox::OrientedBoundingBox(glm::vec3 pos, glm::vec3 rot, glm::vec3 scale, glm::vec3 extents) {
	min_x = -extents.x;
	max_x = extents.x;

	if (min_x > max_x)
	{
		float t = min_x;
		min_x = max_x;
		max_x = t;
	}

	min_y = -extents.y;
	max_y = extents.y;
	if (min_y > max_y)
	{
		float t = min_y;
		min_y = max_y;
		max_y = t;
	}

	min_z = -extents.z;
	max_z = extents.z;
	if (min_z > max_z)
	{
		float t = min_z;
		min_z = max_z;
		max_z = t;
	}

	//rotate
	transformation = CreateRotateMatrix(rot.x * 3.14159f / 180.0f, rot.y * 3.14159f / 180.0f, rot.z * 3.14159f / 180.0f);
	
	//scale
	transformation = CreateScaleMatrix(scale.x, scale.y, scale.z) * transformation;

	//translate
	transformation = CreateTranslateMatrix(pos.x, pos.y, pos.z) * transformation;
	inverted_transformation = glm::inverse(transformation);
}
Esempio n. 3
0
void Test24()
{
	LoadBCP("data.bcp");
	InitWindow();
	Anim tm("Warrior Kings Game Set\\Characters\\Abaddon\\GRAB1.ANIM3");
	//Anim tm("Warrior Kings Game Set\\Characters\\Michael\\SPECIALMOVE.ANIM3");
	RBatch *batch = renderer->CreateBatch(16384, 16384);

	Matrix m1, m2;
	CreateScaleMatrix(&m1, 1.5, 1.5, 1.5);
	CreateTranslationMatrix(&m2, 0, -4, 0);
	mWorld = m1 * m2;

	while(!appexit)
	{
		BeginDrawing();
		BeginMeshDrawing();
		renderer->BeginBatchDrawing();
		batch->begin();
		SetModelMatrices();
		//CreateIdentityMatrix(&mWorld);


		//tm.mesh->draw(1);
		//tn.draw(2);

		//tm.drawInBatch(batch, 0, 1, -1, 0);
		//batch->flush();

		DrawAnim(&tm, batch, 1, timeGetTime());
		batch->end();

		EndDrawing();
		HandleWindow();
	}
}
Esempio n. 4
0
void SetModelMatrices()
{
	Matrix matWorld, rotMatrix, transMatrix, scaleMatrix;
	CreateRotationYMatrix(&rotMatrix, (timeGetTime()%2000)*(2.0f*M_PI)/2000.0f);
	CreateTranslationMatrix(&transMatrix, 0.0f, ytranslation, 0.0f);
	CreateScaleMatrix(&scaleMatrix, scaling, scaling, scaling);
	MultiplyMatrices(&matWorld, &rotMatrix, &transMatrix);
	//MultiplyMatrices(&matWorld, &matWorld, &scaleMatrix);
	matWorld *= scaleMatrix;
	Matrix finalmatrix = matWorld;

	Vector3 vEyePt( 0.0f, 18.0f,-20.0f );
	Vector3 vLookatPt( 0.0f, 0.0f, 0.0f );
	Vector3 vUpVec( 0.0f, 1.0f, 0.0f );
	Matrix matView;
	CreateLookAtLHViewMatrix( &matView, &vEyePt, &vLookatPt, &vUpVec );
	finalmatrix *= matView;

	Matrix matProj;
	CreatePerspectiveMatrix( &matProj, M_PI / 4, 1.0f, 1.0f, 100.0f );
	finalmatrix *= matProj;

	SetTransformMatrix(&finalmatrix);
}