|
|
@ -3,10 +3,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <osg/Group>
|
|
|
|
#include <osg/Group>
|
|
|
|
#include <osg/PositionAttitudeTransform>
|
|
|
|
#include <osg/PositionAttitudeTransform>
|
|
|
|
|
|
|
|
|
|
|
|
#include <osg/ShapeDrawable>
|
|
|
|
|
|
|
|
#include <osg/Shape>
|
|
|
|
|
|
|
|
#include <osg/Geode>
|
|
|
|
#include <osg/Geode>
|
|
|
|
|
|
|
|
#include <osg/Geometry>
|
|
|
|
|
|
|
|
#include <osg/PrimitiveSet>
|
|
|
|
|
|
|
|
|
|
|
|
#include "elements.hpp"
|
|
|
|
#include "elements.hpp"
|
|
|
|
|
|
|
|
|
|
|
@ -24,37 +23,99 @@ void CSVRender::CellArrow::adjustTransform()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// position
|
|
|
|
// position
|
|
|
|
const int cellSize = 8192;
|
|
|
|
const int cellSize = 8192;
|
|
|
|
const int offset = cellSize / 2 + 400;
|
|
|
|
const int offset = cellSize / 2 + 800;
|
|
|
|
|
|
|
|
|
|
|
|
int x = mCoordinates.getX()*cellSize + cellSize/2;
|
|
|
|
int x = mCoordinates.getX()*cellSize + cellSize/2;
|
|
|
|
int y = mCoordinates.getY()*cellSize + cellSize/2;
|
|
|
|
int y = mCoordinates.getY()*cellSize + cellSize/2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float xr = 0;
|
|
|
|
|
|
|
|
float yr = 0;
|
|
|
|
|
|
|
|
float zr = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float angle = osg::DegreesToRadians (90.0f);
|
|
|
|
|
|
|
|
|
|
|
|
switch (mDirection)
|
|
|
|
switch (mDirection)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case Direction_North: y += offset; break;
|
|
|
|
case Direction_North: y += offset; xr = -angle; zr = angle; break;
|
|
|
|
case Direction_West: x -= offset; break;
|
|
|
|
case Direction_West: x -= offset; yr = -angle; break;
|
|
|
|
case Direction_South: y -= offset; break;
|
|
|
|
case Direction_South: y -= offset; xr = angle; zr = angle; break;
|
|
|
|
case Direction_East: x += offset; break;
|
|
|
|
case Direction_East: x += offset; yr = angle; break;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
mBaseNode->setPosition (osg::Vec3f (x, y, 0));
|
|
|
|
mBaseNode->setPosition (osg::Vec3f (x, y, 0));
|
|
|
|
|
|
|
|
|
|
|
|
// orientation
|
|
|
|
// orientation
|
|
|
|
osg::Quat xr (0, osg::Vec3f (1,0,0));
|
|
|
|
osg::Quat xr2 (xr, osg::Vec3f (1,0,0));
|
|
|
|
osg::Quat yr (0, osg::Vec3f (0,1,0));
|
|
|
|
osg::Quat yr2 (yr, osg::Vec3f (0,1,0));
|
|
|
|
osg::Quat zr (0, osg::Vec3f (0,0,1));
|
|
|
|
osg::Quat zr2 (zr, osg::Vec3f (0,0,1));
|
|
|
|
mBaseNode->setAttitude (zr*yr*xr);
|
|
|
|
mBaseNode->setAttitude (zr2*yr2*xr2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSVRender::CellArrow::buildShape()
|
|
|
|
void CSVRender::CellArrow::buildShape()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/// \todo placeholder shape -> replace
|
|
|
|
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry);
|
|
|
|
osg::ref_ptr<osg::Box> shape(new osg::Box(osg::Vec3f(0,0,0), 200));
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::ShapeDrawable> shapedrawable(new osg::ShapeDrawable);
|
|
|
|
const int arrowWidth = 4000;
|
|
|
|
shapedrawable->setShape(shape);
|
|
|
|
const int arrowLength = 1500;
|
|
|
|
|
|
|
|
const int arrowHeight = 500;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::Vec3Array *vertices = new osg::Vec3Array;
|
|
|
|
|
|
|
|
for (int i2=0; i2<2; ++i2)
|
|
|
|
|
|
|
|
for (int i=0; i<2; ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
float height = i ? -arrowHeight/2 : arrowHeight/2;
|
|
|
|
|
|
|
|
vertices->push_back (osg::Vec3f (height, -arrowWidth/2, 0));
|
|
|
|
|
|
|
|
vertices->push_back (osg::Vec3f (height, arrowWidth/2, 0));
|
|
|
|
|
|
|
|
vertices->push_back (osg::Vec3f (height, 0, arrowLength));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
geometry->setVertexArray (vertices);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::DrawElementsUShort *top = new osg::DrawElementsUShort (osg::PrimitiveSet::TRIANGLES, 0);
|
|
|
|
|
|
|
|
top->push_back (0);
|
|
|
|
|
|
|
|
top->push_back (1);
|
|
|
|
|
|
|
|
top->push_back (2);
|
|
|
|
|
|
|
|
geometry->addPrimitiveSet (top);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::DrawElementsUShort *bottom = new osg::DrawElementsUShort (osg::PrimitiveSet::TRIANGLES, 0);
|
|
|
|
|
|
|
|
bottom->push_back (5);
|
|
|
|
|
|
|
|
bottom->push_back (4);
|
|
|
|
|
|
|
|
bottom->push_back (3);
|
|
|
|
|
|
|
|
geometry->addPrimitiveSet (bottom);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::DrawElementsUShort *back = new osg::DrawElementsUShort (osg::PrimitiveSet::QUADS, 0);
|
|
|
|
|
|
|
|
back->push_back (3+6);
|
|
|
|
|
|
|
|
back->push_back (4+6);
|
|
|
|
|
|
|
|
back->push_back (1+6);
|
|
|
|
|
|
|
|
back->push_back (0+6);
|
|
|
|
|
|
|
|
geometry->addPrimitiveSet (back);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::DrawElementsUShort *side1 = new osg::DrawElementsUShort (osg::PrimitiveSet::QUADS, 0);
|
|
|
|
|
|
|
|
side1->push_back (0+6);
|
|
|
|
|
|
|
|
side1->push_back (2+6);
|
|
|
|
|
|
|
|
side1->push_back (5+6);
|
|
|
|
|
|
|
|
side1->push_back (3+6);
|
|
|
|
|
|
|
|
geometry->addPrimitiveSet (side1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::DrawElementsUShort *side2 = new osg::DrawElementsUShort (osg::PrimitiveSet::QUADS, 0);
|
|
|
|
|
|
|
|
side2->push_back (4+6);
|
|
|
|
|
|
|
|
side2->push_back (5+6);
|
|
|
|
|
|
|
|
side2->push_back (2+6);
|
|
|
|
|
|
|
|
side2->push_back (1+6);
|
|
|
|
|
|
|
|
geometry->addPrimitiveSet (side2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::Vec4Array *colours = new osg::Vec4Array;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<6; ++i)
|
|
|
|
|
|
|
|
colours->push_back (osg::Vec4f (1.0f, 0.0f, 0.0f, 1.0f));
|
|
|
|
|
|
|
|
for (int i=0; i<6; ++i)
|
|
|
|
|
|
|
|
colours->push_back (osg::Vec4f (1.0f, 0.0f, 0.4f, 1.0f));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
geometry->setColorArray (colours);
|
|
|
|
|
|
|
|
geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
|
|
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
|
|
|
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
|
|
|
geode->addDrawable(shapedrawable);
|
|
|
|
geode->addDrawable (geometry);
|
|
|
|
|
|
|
|
|
|
|
|
mBaseNode->addChild (geode);
|
|
|
|
mBaseNode->addChild (geode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|