Exemplo n.º 1
0
	virtual void ApplyGroup(Group &group) {
		Group *old = root;
		root = 0;

		// only play in the cache if the group is shared
		const bool doCache = group.GetRefCount() > 1;

		if (doCache) {
			std::map<Group*,Group*>::iterator i = cache.find(&group);
			if (i != cache.end())
				root = (*i).second;
		}

		if (!root) {
			// can't use the copy constructor or Clone
			// they will do too much work
			root = new Group(group.GetRenderer());
			root->SetName(group.GetName());
			root->SetNodeMask(group.GetNodeMask());

			if (doCache)
				cache.insert(std::make_pair(&group, root));
		}

		group.Traverse(*this);

		if (old) {
			old->AddChild(root);
			root = old;
		}
	}
Exemplo n.º 2
0
void CompanyBuilder::addNode(string team_name, string supervisor)
{
    Node* grp = constructGrp(team_name);
    Group* super = getTeam(supervisor);
    if (super != nullptr) {
        super->AddChild(grp);
        print();
    }else {printErrorMessage("find", supervisor);}
}
Exemplo n.º 3
0
void CompanyBuilder::addNode(string first, string last, string title, string team_name)
{
    Node* emp = constructEmp(first, last, title);
    Group* team = getTeam(team_name);
    if (team != nullptr) {
        team->AddChild(emp);
        print();
    } else {printErrorMessage("find", team_name);}
}
Exemplo n.º 4
0
Group* Group::Clone()
{
	Group* temp = new Group(this->Name()); 
	for(int i=0; i < this->_members.size(); i++){
		Node* temporary = _members[i]->Clone(); 
		temp->AddChild(temporary);
	}

	return temp;
}
Exemplo n.º 5
0
void CompanyBuilder::disbandNode(string team_name , string supervisor) 
{
    if (supervisor == "None") { printErrorMessage("disband", team_name); return;}
    Node* team = getNode(team_name);
    Group* teamGrp = getTeam(team_name);
    Group* super = getTeam(supervisor);
    super->RemoveChild(team); //remove team's pointer from super's vector
    for (int i=0; i < teamGrp->get_children_size(); i++)
    {
        super->AddChild(teamGrp->get_child(i));
    }
    teamGrp->ClearNodeVec(); //prevent team from deleting its children when destructor called
    delete teamGrp;
    print();
}
Exemplo n.º 6
0
Node* BuildAppleCo()
{
	Group* root = new Group("Apple");
	Employee* CEO = new Employee("Tim", "Cook", "CEO");
        Group* VPs = new Group("VP");
        Employee* VPEng = new Employee("Craig", "Federighi", "VP of Engineering");
        Employee* VPDesign = new Employee("Jonathan", "Ive", "VP of Design");
        Employee* VPMarketing = new Employee("Phillip","Schiller", "VP of Marketing");

        root->AddChild(CEO);
        root->AddChild(VPs);
        VPs->AddChild(VPEng);
        VPs->AddChild(VPDesign);
        VPs->AddChild(VPMarketing);
        Group* iPadGroup = new Group("iPad");
        Group* iWatchGroup = new Group("Smartwatch");
        Group* iPhoneGroup = new Group("iPhone");
        Employee* iPadDesigner = new Employee ("Phillip","Smith", "Designer");
        VPs->AddChild(iPadGroup);
        VPs->AddChild(iWatchGroup);
        VPs->AddChild(iPhoneGroup);
        iPhoneGroup->AddChild(iPadDesigner);
	return root;
}
Exemplo n.º 7
0
void Shields::ReparentShieldNodes(SceneGraph::Model* model)
{
	assert(s_initialised);

	Graphics::Renderer *renderer = model->GetRenderer();

	using SceneGraph::Node;
	using SceneGraph::Group;
	using SceneGraph::MatrixTransform;
	using SceneGraph::StaticGeometry;

	//This will find all matrix transforms meant for navlights.
	SceneGraph::FindNodeVisitor shieldFinder(SceneGraph::FindNodeVisitor::MATCH_NAME_ENDSWITH, "_shield");
	model->GetRoot()->Accept(shieldFinder);
	const std::vector<Node*> &results = shieldFinder.GetResults();

	//Move shield geometry to same level as the LODs
	for (unsigned int i = 0; i < results.size(); i++) {
		MatrixTransform *mt = dynamic_cast<MatrixTransform*>(results.at(i));
		assert(mt);

		const Uint32 NumChildren = mt->GetNumChildren();
		if (NumChildren>0)
		{
			// Group to contain all of the shields we might find
			Group *shieldGroup = new Group(renderer);
			shieldGroup->SetName(s_shieldGroupName);

			// go through all of this MatrixTransforms children to extract all of the shield meshes
			for (Uint32 iChild = 0; iChild < NumChildren; ++iChild) {
				Node* node = mt->GetChildAt(iChild);
				assert(node);
				if (node)
				{
					RefCountedPtr<StaticGeometry> sg(dynamic_cast<StaticGeometry*>(node));
					assert(sg.Valid());
					sg->SetNodeMask(SceneGraph::NODE_TRANSPARENT);

					// We can early-out if we've already processed this models scenegraph.
					if (Graphics::BLEND_ALPHA == sg->m_blendMode) {
						assert(false);
					}

					// force the blend mode
					sg->m_blendMode = Graphics::BLEND_ALPHA;

					Graphics::RenderStateDesc rsd;
					rsd.blendMode = Graphics::BLEND_ALPHA;
					rsd.depthWrite = false;
					sg->SetRenderState(renderer->CreateRenderState(rsd));

					for (Uint32 iMesh = 0; iMesh < sg->GetNumMeshes(); ++iMesh) {
						StaticGeometry::Mesh &rMesh = sg->GetMeshAt(iMesh);
						rMesh.material = GetGlobalShieldMaterial();
					}

					// find the accumulated transform from the root to our node
					MatrixAccumVisitor mav(mt->GetName());
					model->GetRoot()->Accept(mav);

					// set our nodes transformation to be the accumulated transform
					MatrixTransform *sg_transform_parent = new MatrixTransform(renderer, mav.outMat);
					std::stringstream nodeStream;
					nodeStream << iChild << s_matrixTransformName;
					sg_transform_parent->SetName(nodeStream.str());
					sg_transform_parent->AddChild(sg.Get());

					// dettach node from current location in the scenegraph...
					mt->RemoveChild(node);

					// attach new transform node which parents the our shields mesh to the shield group.
					shieldGroup->AddChild(sg_transform_parent);
				}
			}

			model->GetRoot()->AddChild(shieldGroup);
		}
	}
}