コード例 #1
0
void CSlingshotEngine::buildSlingshot()
{
	Matrix44 transformation;
	setTranslation(transformation, Vector3(0.0f, -8.0f, -15.0f));

	SceneFactory::CreateBox(NULL, transformation, Vector3(1.0f, 2.0f, 1.0f), EntityCategories::SLINGSHOT, false);
	m_pSlingshotBaseNode = GazEngine::getWorldRepresentations()[0]->getChildren().back();

	transformation.setIdentity();
	setTranslation(transformation, Vector3(-1.6f, 3.3f, 0.0f));
	rotate(transformation, Math::PI * 0.2f, Vector4(0.0f, 0.0f, 1.0f, 1.0f));
	SceneFactory::CreateBox(m_pSlingshotBaseNode, transformation, Vector3(0.5f, 2.0f, 0.5f),
		EntityCategories::SLINGSHOT, false);
	SimpleTree* pArmNode = m_pSlingshotBaseNode->getChildren().back();

	transformation.setIdentity();
	setTranslation(transformation, Vector3(0.0f, 2.0f, 0.0f));
	m_pArm0Body = SceneFactory::CreateSphere(pArmNode, transformation, EntityCategories::SLINGSHOT, 1.0f);

	transformation.setIdentity();
	setTranslation(transformation, Vector3(1.6f, 3.3f, 0.0f));
	rotate(transformation, Math::PI * -0.2f, Vector4(0.0f, 0.0f, 1.0f, 1.0f));
	SceneFactory::CreateBox(m_pSlingshotBaseNode, transformation, Vector3(0.5f, 2.0f, 0.5f),
		EntityCategories::SLINGSHOT, false);
	pArmNode = m_pSlingshotBaseNode->getChildren().back();

	transformation.setIdentity();
	setTranslation(transformation, Vector3(0.0f, 2.0f, 0.0f));
	m_pArm1Body = SceneFactory::CreateSphere(pArmNode, transformation, EntityCategories::SLINGSHOT, 1.0f);
}
コード例 #2
0
ファイル: Matrix.cpp プロジェクト: DaniBarca/3DEnvironment
void Matrix44::setRotation(double radians, Vector axis){
    assert(axis.size() == 3);
    Matrix44 r   = Matrix44();
    Matrix44 aux = Matrix44();;
    aux.setIdentity();
    aux.setPosition(m[3],m[7],m[11]);
    r.setRotationMatrix(radians, axis);
    operator=(r*aux);
}
コード例 #3
0
	Matrix44 SimpleSceneGraph::getAbsoluteTransform() const
	{
		Matrix44 absoluteMatrix;
		absoluteMatrix.setIdentity();
		const SceneGraph* currentGraph = this;
		while (currentGraph != nullptr)
		{
			absoluteMatrix *= currentGraph->getTransform();
			currentGraph = currentGraph->getParent();
		}

		return absoluteMatrix;
	}
コード例 #4
0
ファイル: SimpleTree.cpp プロジェクト: simplegsb/gazengine
Matrix44 SimpleTree::getAbsoluteTransformation() const
{
	Matrix44 absoluteMatrix;
	absoluteMatrix.setIdentity();
	const SimpleTree* currentNode = this;
	while (currentNode != NULL)
	{
		absoluteMatrix *= currentNode->getTransformation();
		currentNode = currentNode->getParent();
	}

	return absoluteMatrix;
}
コード例 #5
0
void runModelMathTests(const Vector3& position)
{

	unique_ptr<Entity> test(new Entity);
	setPosition(test->getTransform(), position);

	ModelFactory::Recipe cubeRecipe;
	cubeRecipe.shape = ModelFactory::Recipe::Shape::BOX;
	cubeRecipe.color = Vector4(1.0f, 0.0f, 0.0f, 1.0f);
	cubeRecipe.dimensions = Vector3(2.0f, 2.0f, 2.0f);
	unique_ptr<Mesh> cube = ModelFactory::cookMesh(cubeRecipe);

	Matrix44 relativeTransform;
	relativeTransform.setIdentity();
	setPosition(relativeTransform, Vector3(1.0f, 1.0f, 1.0f));
	unique_ptr<Mesh> cubeMinusCube = ModelFunctions::subtract(*cube, *cube, relativeTransform);

	ModelFactory::Recipe cylinderRecipe;
	cylinderRecipe.shape = ModelFactory::Recipe::Shape::CYLINDER;
	cylinderRecipe.color = Vector4(1.0f, 0.0f, 0.0f, 1.0f);
	cylinderRecipe.dimensions = Vector3(0.6f, 10.0f, 0.0f);
	cylinderRecipe.divisions = 5;
	unique_ptr<Mesh> cylinder = ModelFactory::cookMesh(cylinderRecipe);

	ModelFactory::Recipe hemisphereRecipe;
	hemisphereRecipe.shape = ModelFactory::Recipe::Shape::HEMISPHERE;
	hemisphereRecipe.color = Vector4(1.0f, 0.0f, 0.0f, 1.0f);
	hemisphereRecipe.dimensions = Vector3(2.0f, 0.0f, 0.0f);
	unique_ptr<Mesh> hemisphere = ModelFactory::cookMesh(hemisphereRecipe);

	ModelFactory::Recipe prismRecipe;
	prismRecipe.shape = ModelFactory::Recipe::Shape::PRISM;
	prismRecipe.color = Vector4(1.0f, 0.0f, 0.0f, 1.0f);
	prismRecipe.dimensions = Vector3(1.0f, 1.0f, 1.0f);
	unique_ptr<Mesh> prism = ModelFactory::cookMesh(prismRecipe);

	ModelFactory::Recipe sphereRecipe;
	sphereRecipe.shape = ModelFactory::Recipe::Shape::SPHERE;
	sphereRecipe.color = Vector4(1.0f, 0.0f, 0.0f, 1.0f);
	sphereRecipe.dimensions = Vector3(2.0f, 0.0f, 0.0f);
	unique_ptr<Mesh> sphere = ModelFactory::cookMesh(sphereRecipe);

	unique_ptr<Mesh> triangle = ModelFactory::createTriangleMesh(Vector3(0.0f, 1.0f, 0.0f),
																 Vector3(-1.0f, -2.0f, 0.0f),
																 Vector3(1.0f, -2.0f, 0.0f),
																 shared_ptr<MeshBuffer>(),
																 Vector4(1.0f, 0.0f, 0.0f, 1.0f));

	setPosition(relativeTransform, Vector3(0.0f, 0.0f, 5.0f));
	unique_ptr<Mesh> triangleMinusCylinder = ModelFunctions::subtract(*triangle, *cylinder, relativeTransform);
	unique_ptr<Mesh> prismMinusCylinder = ModelFunctions::subtract(*prism, *cylinder, relativeTransform);

	unique_ptr<Model> model(new Model);
	//model->setMesh(move(cube));
	model->setMesh(move(cubeMinusCube));
	//model->setMesh(move(cylinder));
	//model->setMesh(move(hemisphere));
	//model->setMesh(move(prism));
	//model->setMesh(move(sphere));
	//model->setMesh(move(triangle));
	//model->setMesh(move(triangleMinusCylinder));
	//model->setMesh(move(prismMinusCylinder));

	unique_ptr<Shape> bounds(new Square(1.0f));
	model->setBounds(move(bounds));

	test->addComponent(move(model));
	Simplicity::getScene()->addEntity(move(test));
}