//显示选中物体的包围盒
void ObjectPositionEditor::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
{
	EditorRoot* pEditorRoot = EditorRoot::Instance();
	DebugRenderer* debug = pEditorRoot->scene_->GetComponent<DebugRenderer>();
	if(debug == NULL)
		return;

	vector<Node*> nodes = pEditorRoot->GetUnionSelections();
	for(int i = 0;i < nodes.size();i ++)
	{
		Node* node = nodes[i];
		if(node->GetComponent<Skybox>() != NULL)
			continue;

		debug->AddNode(node,1.0f,false);

		const Vector<SharedPtr<Component> >& components = node->GetComponents();
		for(int j = 0;j < node->GetNumComponents();j ++)
		{
			Drawable* drawable = dynamic_cast<Drawable*>(components[j].Get());
			if(drawable != NULL)
			{
				debug->AddBoundingBox(drawable->GetWorldBoundingBox(),Color::WHITE,true);
			}
		}
	}

	//计算总的
	if(nodes.size() > 1)
	{
		BoundingBox allBox;
		for(int i = 0;i < nodes.size();i ++)
		{
			Node* node = nodes[i];
			if(node->GetComponent<Skybox>() != NULL)
				continue;

			const Vector<SharedPtr<Component> >& components = node->GetComponents();
			for(int j = 0;j < node->GetNumComponents();j ++)
			{
				Drawable* drawable = dynamic_cast<Drawable*>(components[j].Get());
				if(drawable != NULL)
				{
					allBox.Merge(drawable->GetWorldBoundingBox());
				}
			}
		}

		debug->AddBoundingBox(allBox,Color::BLUE,true);
	}

	if(CurrentHoverObject != NULL)
	{
		CurrentHoverObject->DrawDebugGeometry(debug,false);
	}
}
Esempio n. 2
0
void Navigation::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
{
    // If draw debug mode is enabled, draw navigation mesh debug geometry
    if (drawDebug_)
        scene_->GetComponent<NavigationMesh>()->DrawDebugGeometry(true);
    
    // Visualize the start and end points and the last calculated path
    DebugRenderer* debug = scene_->GetComponent<DebugRenderer>();
    if (startPosDefined_)
        debug->AddBoundingBox(BoundingBox(startPos_ - 0.1f * Vector3::ONE, startPos_ + 0.1f * Vector3::ONE), Color::WHITE);
    if (endPosDefined_)
        debug->AddBoundingBox(BoundingBox(endPos_ - 0.1f * Vector3::ONE, endPos_ + 0.1f * Vector3::ONE), Color::WHITE);
    if (currentPath_.Size() > 1)
    {
        // Draw the path with a small upward bias so that it does not clip into the surfaces
        Vector3 bias = 0.05f * Vector3::UP;
        for (unsigned i = 0; i < currentPath_.Size() - 1; ++i)
            debug->AddLine(currentPath_[i] + bias, currentPath_[i + 1] + bias, Color::WHITE);
    }
}
Esempio n. 3
0
void Navigation::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
{
    // If draw debug mode is enabled, draw navigation mesh debug geometry
    if (drawDebug_)
        scene_->GetComponent<NavigationMesh>()->DrawDebugGeometry(true);

    if (currentPath_.Size())
    {
        // Visualize the current calculated path
        DebugRenderer* debug = scene_->GetComponent<DebugRenderer>();
        debug->AddBoundingBox(BoundingBox(endPos_ - Vector3(0.1f, 0.1f, 0.1f), endPos_ + Vector3(0.1f, 0.1f, 0.1f)),
            Color(1.0f, 1.0f, 1.0f));

        // Draw the path with a small upward bias so that it does not clip into the surfaces
        Vector3 bias(0.0f, 0.05f, 0.0f);
        debug->AddLine(jackNode_->GetPosition() + bias, currentPath_[0] + bias, Color(1.0f, 1.0f, 1.0f));

        if (currentPath_.Size() > 1)
        {
            for (unsigned i = 0; i < currentPath_.Size() - 1; ++i)
                debug->AddLine(currentPath_[i] + bias, currentPath_[i + 1] + bias, Color(1.0f, 1.0f, 1.0f));
        }
    }
}