Exemple #1
0
int main(int args[])
{
	//auto window = Window::CreateSDLWindow();
	auto application = new FWApplication();
	if (!application->GetWindow())
	{
		LOG("Couldn't create window...");
		return EXIT_FAILURE;
	}
	
	application->SetTargetFPS(60);
	application->SetColor(Color(255, 10, 40, 255));
	
	Cow * moe = new Cow();
	Graph * graph = new Graph();
	while (application->IsRunning())
	{
		application->StartTick();

		SDL_Event event;
		while (SDL_PollEvent(&event))
		{
			switch (event.type)
			{
			case SDL_QUIT:
				application->Quit();
				break;
			case SDL_KEYDOWN:
				switch (event.key.keysym.sym){
				case false:
					break;

				default:
					break;
				}
			}
		}
		
		application->SetColor(Color(0, 0, 0, 255));
		for (int i = 0; i < graph->getGraphSize(); i++){
			application->AddRenderable(graph->getNode(i));
		}
		for (int i = 0; i < graph->getEdgesSize(); i++){
			Edge * E = graph->getEdge(i);
			application->DrawLine(E->mXA, E->mYA, E->mXB, E->mYB);
		}

		application->AddRenderable(moe);		
		// For the background
		application->SetColor(Color(255, 255, 255, 255));

		application->UpdateGameObjects();
		application->RenderGameObjects();
		application->EndTick();
	}
		
	return EXIT_SUCCESS;
}
Exemple #2
0
Treenity::Treenity(QWidget *parent)
	: QMainWindow(parent), m_running(true)
{
	//Set some utility init things
	Utils::GetInstance()->setParent(this);
	Utils::GetInstance()->setFloating(true);

	// Setup component names in the editor.
	m_componentNames[RootForce::ComponentType::RENDERABLE]			= "Renderable";
	m_componentNames[RootForce::ComponentType::TRANSFORM]			= "Transform";
	m_componentNames[RootForce::ComponentType::POINTLIGHT]			= "Point Light";
	m_componentNames[RootForce::ComponentType::CAMERA]				= "Camera";
	m_componentNames[RootForce::ComponentType::HEALTH]				= "Health";
	m_componentNames[RootForce::ComponentType::PLAYERCONTROL]		= "Player Control";
	m_componentNames[RootForce::ComponentType::PHYSICS]				= "Physics";
	m_componentNames[RootForce::ComponentType::NETWORK]				= "Network";
	m_componentNames[RootForce::ComponentType::LOOKATBEHAVIOR]		= "Look-At Behaviour";
	m_componentNames[RootForce::ComponentType::THIRDPERSONBEHAVIOR] = "Third Person Behaviour";
	m_componentNames[RootForce::ComponentType::SCRIPT]				= "Script";
	m_componentNames[RootForce::ComponentType::COLLISION]			= "Physics";	// Required since the component list searches on name.
	m_componentNames[RootForce::ComponentType::COLLISIONRESPONDER]	= "Collision Responder";
	m_componentNames[RootForce::ComponentType::PLAYER]				= "Player";
	m_componentNames[RootForce::ComponentType::ANIMATION]			= "Animation";
	m_componentNames[RootForce::ComponentType::PARTICLE]			= "Particle";
	m_componentNames[RootForce::ComponentType::TDMRULES]			= "Team-Deathmatch Rules";
	m_componentNames[RootForce::ComponentType::PLAYERACTION]		= "Player Action";
	m_componentNames[RootForce::ComponentType::PLAYERPHYSICS]		= "Player Physics";
	m_componentNames[RootForce::ComponentType::ENTITYSTATE]			= "Entity State";
	m_componentNames[RootForce::ComponentType::SHADOWCASTER]		= "Shadowcaster";
	m_componentNames[RootForce::ComponentType::DIRECTIONALLIGHT]	= "Directional Light";
	m_componentNames[RootForce::ComponentType::SERVERINFORMATION]	= "Server Information";
	m_componentNames[RootForce::ComponentType::CLIENT]				= "Client";
	m_componentNames[RootForce::ComponentType::RAGDOLL]				= "Ragdoll";
	m_componentNames[RootForce::ComponentType::WATERCOLLIDER]		= "Water Collider";
	m_componentNames[RootForce::ComponentType::ABILITYSPAWN]		= "Ability Spawn";
	m_componentNames[RootForce::ComponentType::TRYPICKUPCOMPONENT]	= "Try Pickup";
	m_componentNames[RootForce::ComponentType::SOUND]				= "Sound";
	m_componentNames[RootForce::ComponentType::TIMER]				= "Timer";
	m_componentNames[RootForce::ComponentType::FOLLOW]				= "Follow";
	m_componentNames[RootForce::ComponentType::HOMING]				= "Homing";
	m_componentNames[RootForce::ComponentType::RAY]					= "Ray";
	m_componentNames[RootForce::ComponentType::DAMAGEANDKNOCKBACK]	= "Damage and Knockback";
	m_componentNames[RootForce::ComponentType::SCALABLE]			= "Scalable";
	m_componentNames[RootForce::ComponentType::STATCHANGE]			= "Stat Change";
	m_componentNames[RootForce::ComponentType::KILLANNOUNCEMENT]	= "Kill Announcement";
	m_componentNames[RootForce::ComponentType::CONTROLLERACTIONS]	= "Controller Action";

	// Setup the main UI.
	ui.setupUi(this);

	setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
	setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );

	m_compView = new ComponentView();
	m_scrollArea = new VerticalScrollArea();
	m_scrollArea->setWidget(m_compView);
	m_scrollArea->setFrameStyle(QFrame::Plain);
	// Setup the component view and its items.
	
	ui.verticalLayout->addWidget(m_scrollArea);
	m_componentViews[RootForce::ComponentType::TRANSFORM]			= new TransformView();
	m_componentViews[RootForce::ComponentType::RENDERABLE]			= new RenderableView();	
	m_componentViews[RootForce::ComponentType::COLLISION]			= new PhysicsView();
	m_componentViews[RootForce::ComponentType::WATERCOLLIDER]		= new WaterColliderView();
	m_componentViews[RootForce::ComponentType::SCRIPT]				= new ScriptView();
	m_componentViews[RootForce::ComponentType::COLLISIONRESPONDER]	= new CollisionResponderView();
	m_componentViews[RootForce::ComponentType::PARTICLE]			= new ParticleView();

	// Block component views from updates while in game mode.
	m_componentViews[RootForce::ComponentType::RENDERABLE]->SetReceiveUpdates(false);

	for (auto it : m_componentViews)
	{
		it.second->SetEditorInterface(this);
	}
	
	ui.treeView_entityOutliner->SetEditorInterface(this);

	//Set up water tool
	m_waterToolDockable = new WaterTool(this);

	// Match signals with slots.
	connect(ui.actionNew,							SIGNAL(triggered()),		this,					SLOT(New()));
	connect(ui.actionOpen_Project,					SIGNAL(triggered()),		this,					SLOT(OpenProject()));
	connect(ui.action_saveAs,						SIGNAL(triggered()),		this,					SLOT(SaveAs()));
	connect(ui.action_save,							SIGNAL(triggered()),		this,					SLOT(Save()));
	connect(ui.actionExit,							SIGNAL(triggered()),		this,					SLOT(close()));
	connect(ui.actionLog,							SIGNAL(triggered()),		Utils::GetInstance(),	SLOT(Show()));
	connect(ui.action_addEntity,					SIGNAL(triggered()),		this,					SLOT(CreateEntity()));
	connect(ui.action_removeEntity,					SIGNAL(triggered()),		this,					SLOT(DestroyEntity()));
	connect(ui.lineEdit_entityName,					SIGNAL(editingFinished()),	this,					SLOT(RenameEntity()));
	connect(ui.action_addRenderable,				SIGNAL(triggered()),		this,					SLOT(AddRenderable()));
	connect(ui.action_addPhysics,					SIGNAL(triggered()),		this,					SLOT(AddPhysics()));
	connect(ui.action_addWaterCollider,				SIGNAL(triggered()),		this,					SLOT(AddWaterCollider()));
	connect(ui.action_addScript,					SIGNAL(triggered()),		this,					SLOT(AddScriptComponent()));
	connect(ui.action_collisionResponder,			SIGNAL(triggered()),		this,					SLOT(AddCollisionResponder()));
	connect(ui.action_addParticle,					SIGNAL(triggered()),		this,					SLOT(AddParticleComponent()));
	connect(ui.actionPlay,							SIGNAL(triggered()),		this,					SLOT(Play()));
	connect(ui.pushButton_translateMode,			SIGNAL(clicked()),			this,					SLOT(SetTranslateTool()));
	connect(ui.pushButton_rotateMode,				SIGNAL(clicked()),			this,					SLOT(SetRotateTool()));
	connect(ui.pushButton_scaleMode,				SIGNAL(clicked()),			this,					SLOT(SetResizeTool()));
	connect(ui.comboBox_mode,						SIGNAL(currentIndexChanged(int)), this,				SLOT(ChangeToolMode(int)));
	connect(ui.actionWaterSetting,					SIGNAL(triggered()),		m_waterToolDockable,	SLOT(Show()));

	connect(m_componentViews[RootForce::ComponentType::RENDERABLE],			SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemoveRenderable(ECS::Entity*)));
	connect(m_componentViews[RootForce::ComponentType::COLLISION],			SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemovePhysics(ECS::Entity*))); 
	connect(m_componentViews[RootForce::ComponentType::WATERCOLLIDER],		SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemoveWaterCollider(ECS::Entity*))); 
	connect(m_componentViews[RootForce::ComponentType::SCRIPT],				SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemoveScriptComponent(ECS::Entity*))); 
	connect(m_componentViews[RootForce::ComponentType::COLLISIONRESPONDER], SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemoveCollisionResponder(ECS::Entity*))); 

	// Setup Qt-to-SDL keymatching.
	InitialiseKeymap();

	ui.widget_canvas3D->SetEditorInterface(this);
	// Set tool mode.
	m_toolMode = ToolMode::LOCAL;
}
Exemple #3
0
void EngineActions::DuplicateEntity( ECS::Entity* p_entity )
{
	//Create new entity
	ECS::Entity* newEntity = CreateEntity();
	//Set position, scale and rotation of new entity to same as old entity + a little offset in X (to avoid clipping and confusion)
	SetPosition(newEntity, GetPosition(p_entity) + glm::vec3(10, 0, 0));
	SetOrientation(newEntity, GetOrientation(p_entity));
	SetScale(newEntity, GetScale(p_entity));

	//Get all components
	RootForce::Renderable*		renderable		= m_world->GetEntityManager()->GetComponent<RootForce::Renderable>(p_entity);
	RootForce::Physics*			physics			= m_world->GetEntityManager()->GetComponent<RootForce::Physics>(p_entity);
	RootForce::Collision*		collision		= m_world->GetEntityManager()->GetComponent<RootForce::Collision>(p_entity);
	RootForce::Script*			script			= m_world->GetEntityManager()->GetComponent<RootForce::Script>(p_entity);
	RootForce::WaterCollider*	watercollider	= m_world->GetEntityManager()->GetComponent<RootForce::WaterCollider>(p_entity);
	RootForce::ParticleEmitter* particleEmitter = m_world->GetEntityManager()->GetComponent<RootForce::ParticleEmitter>(p_entity);

	//Check if there's a renderable and copy data
	if(renderable != nullptr)
	{
		AddRenderable(newEntity);
		SetRenderableModelName(newEntity, GetRenderableModelName(p_entity));
		SetRenderableMaterialName(newEntity, GetRenderableMaterialName(p_entity));
	}

	//Check if there's a renderable and copy data
	if(collision != nullptr)
	{
		if(physics != nullptr)
		{
			AddPhysics(newEntity, true);
			SetMass(newEntity, GetMass(p_entity));
		}
		else
			AddPhysics(newEntity, false);

		SetPhysicsType(newEntity, GetPhysicsType(p_entity));
		SetPhysicsShape(newEntity, GetPhysicsShape(p_entity));
		SetShapeHeight(newEntity, GetShapeHeight(p_entity));
		SetShapeRadius(newEntity, GetShapeRadius(p_entity));
		SetPhysicsMesh(newEntity, GetPhysicsMesh(p_entity));
		SetCollideWithStatic(newEntity, GetCollideWithStatic(p_entity));
		SetCollideWithWorld(newEntity, GetCollideWithWorld(p_entity));
		SetGravity(newEntity, GetGravity(p_entity));	
	}

	//Check if there's a script and copy data
	if(script != nullptr)
	{
		AddScript(newEntity);
		SetScript(newEntity, GetScript(p_entity));
	}

	//Check if there's a water collider and copy data
	if(watercollider != nullptr)
	{
		AddWaterCollider(newEntity);
		SetWaterColliderInterval(newEntity, GetWaterColliderInterval(p_entity));
		SetWaterColliderPower(newEntity, GetWaterColliderPower(p_entity));
		SetWaterColliderRadius(newEntity, GetWaterColliderRadius(p_entity));
	}

	if(particleEmitter != nullptr)
	{
		AddParticle(newEntity);
		SetParticleEmitter(newEntity, GetParticleEmitter(p_entity));
	}
}