当前位置: 首页>>代码示例>>C++>>正文


C++ TransformComponent::setScale方法代码示例

本文整理汇总了C++中TransformComponent::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ TransformComponent::setScale方法的具体用法?C++ TransformComponent::setScale怎么用?C++ TransformComponent::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TransformComponent的用法示例。


在下文中一共展示了TransformComponent::setScale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addModel

Actor* addModel(string filename, vec3 pos = vec3(0), vec3 s = vec3(1))
{

	Actor* sphere = new Actor;

	TransformComponent* trans = new TransformComponent();
	trans->setPos(pos);

	trans->setScale(s);
	sphere->addComponent(trans);
	glDebug();
	sphere->addComponent(new StaticMeshStaticPhysicsComponent(AssetManager::getBasePath() + filename));
	glDebug();
	MeshGraphicComponent* mesh = new MeshGraphicComponent(AssetManager::getBasePath() + filename);
	glDebug();
	mesh->setTextureMatrix(mat2(scale(mat4(1), vec3(10))));
	glDebug();
	Material *mat = new Material();
	glDebug();
	mat->setDiffuse(AssetManager::getBasePath() + "Data/Texture/floor1_d.png");
	mat->setNormal(AssetManager::getBasePath() + "Data/Texture/floor1_n.png");
	mat->setSpecular(AssetManager::getBasePath() + "Data/Texture/floor1_s.png");
	mat->setShininess(20);
	glDebug();
	mesh->addMaterial(mat);
	glDebug();
	sphere->addComponent(mesh);
	glDebug();
	return sphere;
}
开发者ID:ennioquaglia,项目名称:GameEngine,代码行数:30,代码来源:main.cpp

示例2: addLucy

Actor* addLucy(Scene* scene)
{
	string tex[] = {"#666666", "#666667", "#666668", "#666669"};
	for(int i = 0; i < 5; i++) {
		Actor* sphere = new Actor;

		vec3 pos(i * 3, 0, -25);
		TransformComponent* trans = new TransformComponent();
		trans->setScale(vec3(0.2));
		trans->setPos(pos);
		sphere->addComponent(trans);
		glDebug();
		sphere->addComponent(new SpherePhysicsComponent(1));
		glDebug();
		MeshGraphicComponent* mesh = new MeshGraphicComponent(AssetManager::getBasePath() + "Data/Model/lucy_low.obj");
		glDebug();
		mesh->setTextureMatrix(mat2(scale(mat4(1), vec3(10))));
		glDebug();
		Material *mat = new Material();
		glDebug();

		if(i) {
			mat->setDiffuse(tex[i - 1]);
			mat->setShininess(i * i * i * i);
		} else {
			mat->setDiffuse(AssetManager::getBasePath() + "Data/Texture/floor1_d.png");
			mat->setNormal(AssetManager::getBasePath() + "Data/Texture/floor1_n.png");
			mat->setSpecular(AssetManager::getBasePath() + "Data/Texture/floor1_s.png");
			mat->setShininess(20);
		}
		glDebug();
		mesh->addMaterial(mat);
		glDebug();
		sphere->addComponent(mesh);
		glDebug();


		scene->addActor(sphere);
	}
	return 0;
}
开发者ID:ennioquaglia,项目名称:GameEngine,代码行数:41,代码来源:main.cpp

示例3: onSceneLoad

	// Example 2D physics scene.
	void PhysicsTestScene::onSceneLoad(GameInstance *instance)
	{
		ContextData *context = instance->getContextData();

		{
			Entity *entity = rtti::dynamicCast<Entity>(rtti::RTTI::generateSerializable("Entity", instance->getContextData()));;
			entity->setName("background");

			TransformComponent *transform = rtti::dynamicCast<TransformComponent>(rtti::RTTI::generateSerializable("TransformComponent", instance->getContextData()));

			transform->setPosition(math::Vec3(0.f, 0.f, LAYER_BACKGROUND_0));
			transform->setDirection(math::Vec3(0.0f, 0.0f, 1.f));
			transform->setScale(150.f);

			renderer::SpriteComponent *sprite = rtti::dynamicCast<renderer::SpriteComponent>(rtti::RTTI::generateSerializable("SpriteComponent", instance->getContextData()));
			sprite->setTexture("grass.png");
			sprite->setDisableCullCheck(true);

			entity->addComponent(transform);
			entity->addComponent(sprite);

			instance->getScene()->addEntity(entity);
		}

		{
			Entity *entity = rtti::dynamicCast<Entity>(rtti::RTTI::generateSerializable("Entity", instance->getContextData()));;
			entity->setName("block");

			TransformComponent *transform = rtti::dynamicCast<TransformComponent>(rtti::RTTI::generateSerializable("TransformComponent", instance->getContextData()));

			transform->setPosition(math::Vec3(0.f, 50.f, LAYER_BACKGROUND_0));
			transform->setDirection(math::Vec3(-0.5f, 0.5f, 1.f));
			transform->setScale(1.f);

			renderer::SpriteComponent *sprite = rtti::dynamicCast<renderer::SpriteComponent>(rtti::RTTI::generateSerializable("SpriteComponent", instance->getContextData()));
			sprite->setTexture("biggrass.png");

			physics::Box2DRigidBodyComponent *phys = rtti::dynamicCast<physics::Box2DRigidBodyComponent>(rtti::RTTI::generateSerializable("Box2DRigidBodyComponent", instance->getContextData()));

			phys->setMass(5);
			phys->setFriction(1.f);
			phys->setDensity(1.0f);
			phys->setRestitution(0.8f);
			phys->setKinematic(true);
			phys->setGroup(physics::BOX2D_GROUP_LEVEL);

			entity->addComponent(transform);
			entity->addComponent(sprite);
			entity->addComponent(phys);

			instance->getScene()->addEntity(entity);
		}


		for (unsigned i = 0; i < 2000; ++i)
		{
			Entity *entity = rtti::dynamicCast<Entity>(rtti::RTTI::generateSerializable("Entity", instance->getContextData()));;
			entity->setName("block");

			TransformComponent *transform = rtti::dynamicCast<TransformComponent>(rtti::RTTI::generateSerializable("TransformComponent", instance->getContextData()));

			transform->setPosition(math::Vec3(150.f + i * 250.f, 50.f, LAYER_BACKGROUND_0));
			transform->setDirection(math::Vec3(-0.5f, 0.5f, 1.f));
			transform->setScale(1.f);

			renderer::SpriteComponent *sprite = rtti::dynamicCast<renderer::SpriteComponent>(rtti::RTTI::generateSerializable("SpriteComponent", instance->getContextData()));
			sprite->setTexture("biggrass.png");

			physics::Box2DRigidBodyComponent *phys = rtti::dynamicCast<physics::Box2DRigidBodyComponent>(rtti::RTTI::generateSerializable("Box2DRigidBodyComponent", instance->getContextData()));

			phys->setMass(5);
			phys->setFriction(1.f);
			phys->setDensity(1.0f);
			phys->setRestitution(0.8f);
			phys->setKinematic(true);
			phys->setGroup(physics::BOX2D_GROUP_LEVEL);

			entity->addComponent(transform);
			entity->addComponent(sprite);
			entity->addComponent(phys);

			instance->getScene()->addEntity(entity);
		}

		unsigned l = 10;
		for (unsigned i = 0; i < 10; ++i)
		{
			Entity *entity = rtti::dynamicCast<Entity>(rtti::RTTI::generateSerializable("Entity", instance->getContextData()));;
			entity->setName("Object");

			TransformComponent *transform = rtti::dynamicCast<TransformComponent>(rtti::RTTI::generateSerializable("TransformComponent", instance->getContextData()));

			transform->setPosition(math::Vec3(0.f, 750.f + 150.f * i, LAYER_OBJECT_1));

			transform->setDirection(math::Vec3(0.f, 0.f, 1.f));
			transform->setScale(1.f);

			renderer::SpriteComponent *sprite = rtti::dynamicCast<renderer::SpriteComponent>(rtti::RTTI::generateSerializable("SpriteComponent", instance->getContextData()));
			sprite->setTexture("isopropelli.png");
//.........这里部分代码省略.........
开发者ID:LauriM,项目名称:PropellerEngine,代码行数:101,代码来源:PhysicsTestScene.cpp

示例4: CreateBoard

void FieldSystem::CreateBoard()
{
	//Temporary board for building neighbourhood
	std::vector<std::vector<FieldComponent*>> fieldBoard;
	fieldBoard.resize(FIELDSIZE_Y);

	for(unsigned int y = 0; y < FIELDSIZE_Y; ++y)
	{
		fieldBoard[y].resize(FIELDSIZE_X);
		for(unsigned int x = 0; x < FIELDSIZE_X; ++x)
		{
			//Create field
			unsigned int entityId = m_dataModel->getUnusedEntityId();
			SpriteComponent* sprite = new SpriteComponent(entityId);
			sprite->setTexture(m_textureLoader->Load("resources/textures/hexagon.png"));
			int height = static_cast<int>(sprite->getTextureBounds().w);
			TransformComponent* hexagonTransform = new TransformComponent(entityId, glm::vec3(BOARD_OFFSET_X + x * FIELD_OFFSET_X, BOARD_OFFSET_Y + y  * height + (x % 2) * (height / 2), -5));
			hexagonTransform->setScale(glm::vec2(0.4f));
			FieldComponent* fieldComp = new FieldComponent(entityId);
			fieldComp->setCoordinates(glm::ivec2(x, y));
			m_eventManager->FireEvent<RegisterComponentEvent>(new RegisterComponentEvent(sprite));
			m_eventManager->FireEvent<RegisterComponentEvent>(new RegisterComponentEvent(hexagonTransform));
			m_eventManager->FireEvent<RegisterComponentEvent>(new RegisterComponentEvent(fieldComp));

			fieldBoard[y][x] = fieldComp;
			
			//Build neighbourhood
			if(y > 0)
			{
				fieldBoard[y-1][x]->getNeighbours().push_back(fieldComp);
				fieldComp->getNeighbours().push_back(fieldBoard[y-1][x]);
			}

			if(x > 0)
			{
				fieldBoard[y][x-1]->getNeighbours().push_back(fieldComp);
				fieldComp->getNeighbours().push_back(fieldBoard[y][x-1]);
			}

			if(x > 0 && y > 0 && x % 2 == 0)
			{
				fieldBoard[y-1][x-1]->getNeighbours().push_back(fieldComp);
				fieldComp->getNeighbours().push_back(fieldBoard[y-1][x-1]);
			}

			if(x < FIELDSIZE_X - 1 && y > 0 && x % 2 == 0)
			{
				fieldBoard[y-1][x+1]->getNeighbours().push_back(fieldComp);
				fieldComp->getNeighbours().push_back(fieldBoard[y-1][x+1]);
			}

		}
	}

	//Create hole/unpassable fields
	fieldBoard[7][9]->setIsPassable(false);
	fieldBoard[7][10]->setIsPassable(false);
	fieldBoard[7][11]->setIsPassable(false);
	fieldBoard[7][12]->setIsPassable(false);
	fieldBoard[7][13]->setIsPassable(false);
	RecalculateColors();
}
开发者ID:Aszura,项目名称:ARL_Ant,代码行数:62,代码来源:FieldSystem.cpp

示例5: onSceneLoad

	// instance provides access to the engine when the load is happening, all the changes should be loaded against it.
	void PhysicsTestScene::onSceneLoad(GameInstance *instance)
	{
		// Scopes are here just to make it easier to use the same name multiple times (entity, etc)
		{
			// creating a static ground with box2d physics
			Entity *entity = rtti::generate<Entity>(instance->getContextData());
			entity->setName("Ground");

			TransformComponent *transform = rtti::generate<TransformComponent>(instance->getContextData());

			// set position of the ground
			transform->setPosition(math::Vec3(50.f, 550.f, 0.f));
			transform->setDirection(math::Vec3(0.f, 0.f, 1.f));
			transform->setScale(1.f);

			// Create spritecomponent to display the image
			renderer::SpriteComponent *sprite = rtti::generate<renderer::SpriteComponent>(instance->getContextData());
			sprite->setTexture("hellknight.png"); // hellknight.png is automatically loaded and cached by the RendererSystem, etc on the background, no need to worry about it

			// Lets add 2D-physics
			physics::Box2DRigidBodyComponent *phys = rtti::generate<physics::Box2DRigidBodyComponent>(instance->getContextData());

			phys->setFriction(1.f);
			phys->setMass(5);
			phys->setDensity(1.0f);
			phys->setKinematic(true); // kinematic makes the object static. (useful for ground, etc)

			// Lets add all the components to the entity
			entity->addComponent(transform);
			entity->addComponent(sprite);
			entity->addComponent(phys);

			// aaand lets add the entity to the scene!
			instance->getScene()->addEntity(entity);
		}

		// And the lets create the player,
		{
			Entity *entity = rtti::generate<Entity>(instance->getContextData());
			entity->setName("Player"); // name can be checked  during the code, but string comparison is slow, so I would recommend to check against something else
			// for example if only the player has "PlayerInfoComponent" or something like that, you can try to find that component to 
			// detect the player.

			TransformComponent *transform = rtti::generate<TransformComponent>(instance->getContextData());

			transform->setPosition(math::Vec3(50.f, 750.f, 0.2f));
			transform->setDirection(math::Vec3(0.f, 0.f, 1.f));
			transform->setScale(1.f);

			renderer::SpriteComponent *sprite = rtti::generate<renderer::SpriteComponent>(instance->getContextData());
			sprite->setTexture("testcube.png");

			physics::Box2DRigidBodyComponent *phys = rtti::generate<physics::Box2DRigidBodyComponent>(instance->getContextData());

			phys->setMass(5);
			phys->setFriction(1.f);
			phys->setDensity(1.0f);
			phys->setKinematic(false);

			player::PlayerInputComponent *playerInput = rtti::generate<player::PlayerInputComponent>(instance->getContextData());

			// camera is used to center the camera to the player
			scene::CameraComponent *camera = rtti::generate<scene::CameraComponent>(instance->getContextData());

			renderer::LightComponent *light = rtti::generate<renderer::LightComponent>(instance->getContextData());
			light->setColor(math::Vec3(0.8f, 0.8f, 1.f));

			entity->addComponent(transform);
			entity->addComponent(sprite);
			entity->addComponent(phys);
			entity->addComponent(playerInput);
			entity->addComponent(light);
			entity->addComponent(camera);

			instance->getScene()->addEntity(entity);

			camera->setActive(true);
		}

		LOG_INFO("Physics test scene loaded!");
	}
开发者ID:LauriM,项目名称:PropellerEngine,代码行数:82,代码来源:ExampleScene.cpp


注:本文中的TransformComponent::setScale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。