mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 12:39:55 +00:00
OpenCS: Add selection outline effect to CSVRender::Object
This commit is contained in:
parent
dac3b33efb
commit
41ea76fd83
@ -10,6 +10,8 @@
|
|||||||
#include <osg/Shape>
|
#include <osg/Shape>
|
||||||
#include <osg/Geode>
|
#include <osg/Geode>
|
||||||
|
|
||||||
|
#include <osgFX/Scribe>
|
||||||
|
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
#include "../../model/world/ref.hpp"
|
#include "../../model/world/ref.hpp"
|
||||||
#include "../../model/world/refidcollection.hpp"
|
#include "../../model/world/refidcollection.hpp"
|
||||||
@ -116,9 +118,14 @@ const CSMWorld::CellRef& CSVRender::Object::getReference() const
|
|||||||
|
|
||||||
CSVRender::Object::Object (CSMWorld::Data& data, osg::Group* parentNode,
|
CSVRender::Object::Object (CSMWorld::Data& data, osg::Group* parentNode,
|
||||||
const std::string& id, bool referenceable, bool forceBaseToZero)
|
const std::string& id, bool referenceable, bool forceBaseToZero)
|
||||||
: mData (data), mBaseNode(0), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero)
|
: mData (data), mBaseNode(0), mSelected(false), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero)
|
||||||
{
|
{
|
||||||
mBaseNode = new osg::PositionAttitudeTransform;
|
mBaseNode = new osg::PositionAttitudeTransform;
|
||||||
|
mOutline = new osgFX::Scribe;
|
||||||
|
mOutline->addChild(mBaseNode);
|
||||||
|
|
||||||
|
mBaseNode->setUserData(new ObjectHolder(this));
|
||||||
|
|
||||||
parentNode->addChild(mBaseNode);
|
parentNode->addChild(mBaseNode);
|
||||||
|
|
||||||
// 0x1 reserved for separating cull and update visitors
|
// 0x1 reserved for separating cull and update visitors
|
||||||
@ -145,6 +152,23 @@ CSVRender::Object::~Object()
|
|||||||
mParentNode->removeChild(mBaseNode);
|
mParentNode->removeChild(mBaseNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::Object::setSelected(bool selected)
|
||||||
|
{
|
||||||
|
mSelected = selected;
|
||||||
|
|
||||||
|
mParentNode->removeChild(mOutline);
|
||||||
|
mParentNode->removeChild(mBaseNode);
|
||||||
|
if (selected)
|
||||||
|
mParentNode->addChild(mOutline);
|
||||||
|
else
|
||||||
|
mParentNode->addChild(mBaseNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSVRender::Object::getSelected() const
|
||||||
|
{
|
||||||
|
return mSelected;
|
||||||
|
}
|
||||||
|
|
||||||
bool CSVRender::Object::referenceableDataChanged (const QModelIndex& topLeft,
|
bool CSVRender::Object::referenceableDataChanged (const QModelIndex& topLeft,
|
||||||
const QModelIndex& bottomRight)
|
const QModelIndex& bottomRight)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
|
#include <osg/Referenced>
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
@ -16,6 +17,11 @@ namespace osg
|
|||||||
class Group;
|
class Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace osgFX
|
||||||
|
{
|
||||||
|
class Scribe;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
{
|
{
|
||||||
class ResourceSystem;
|
class ResourceSystem;
|
||||||
@ -29,12 +35,29 @@ namespace CSMWorld
|
|||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Object;
|
||||||
|
|
||||||
|
// An object to attach as user data to the osg::Node, allows us to get an Object back from a Node when we are doing a ray query
|
||||||
|
class ObjectHolder : public osg::Referenced
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObjectHolder(Object* obj)
|
||||||
|
: mObject(obj)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Object* mObject;
|
||||||
|
};
|
||||||
|
|
||||||
class Object
|
class Object
|
||||||
{
|
{
|
||||||
const CSMWorld::Data& mData;
|
const CSMWorld::Data& mData;
|
||||||
std::string mReferenceId;
|
std::string mReferenceId;
|
||||||
std::string mReferenceableId;
|
std::string mReferenceableId;
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
|
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
|
||||||
|
osg::ref_ptr<osgFX::Scribe> mOutline;
|
||||||
|
bool mSelected;
|
||||||
osg::Group* mParentNode;
|
osg::Group* mParentNode;
|
||||||
Resource::ResourceSystem* mResourceSystem;
|
Resource::ResourceSystem* mResourceSystem;
|
||||||
bool mForceBaseToZero;
|
bool mForceBaseToZero;
|
||||||
@ -68,6 +91,11 @@ namespace CSVRender
|
|||||||
|
|
||||||
~Object();
|
~Object();
|
||||||
|
|
||||||
|
/// Mark the object as selected, selected objects show an outline effect
|
||||||
|
void setSelected(bool selected);
|
||||||
|
|
||||||
|
bool getSelected() const;
|
||||||
|
|
||||||
/// \return Did this call result in a modification of the visual representation of
|
/// \return Did this call result in a modification of the visual representation of
|
||||||
/// this object?
|
/// this object?
|
||||||
bool referenceableDataChanged (const QModelIndex& topLeft,
|
bool referenceableDataChanged (const QModelIndex& topLeft,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user