More advanced surface renderers are PolychromeSurface, TransparentSurface and CrystalSurface_8cpp-example.html ( CrystalSurface.cpp ).
#include <ocean/GLvish/VGLRenderObject.hpp>
#include <ocean/GLvish/BoundingBox.hpp>
#include <ocean/GLvish/ArrayTypes.hpp>
#include <ocean/GLvish/colors.hpp>
#include <ocean/shrimp/VEnum.hpp>
#include <eagle/PhysicalSpace.hpp>
#include <field/Cell.hpp>
#include <GL/fiberGL.hpp>
#include <baseop/ExpandBBox.hpp>
#include <eye/retina/VSkeletonRenderObject.hpp>
#include <grid/types/TriangularSurface.hpp>
#include <bundle/BundleProperty.hpp>
#include <bone/GridActor.hpp>
#include <ocean/Anemonia/FloatOrigin.hpp>
namespace
{
{
public:
{
using TriangularSurface::operator=;
Eagle::tvector3 TranslationVector = {0,0,0};
};
RefPtr<State> newState() const override
{
return new MyState();
}
MonochromeSurface(const string&name, int p, const RefPtr<VCreationPreferences>&VP)
, LineWidth(this, "linewidth", 1.5, 1)
, SurfaceColor(this, "color", Color(.8,.5,.1, 1.0),0)
, SurfaceMode(this, "mode", VEnum("solid", "line", "points") )
{
}
bool update(
VRequest&R,
double precision)
override;
};
{
RefPtr<MyState> S = myState(
Context);
RefPtr<Grid> G = findMostRecentGrid(
Context );
if (!G)
{
return setStatusError(
Context,
"No Grid found.");
}
*S = G;
if (!*S)
{
return setStatusError(
Context,
"No surface available.");
}
setBoundingBall(
Context, getBoundingBox( S->CoordField ) );
return setStatusInfo(
Context,
"Surface ready to render.");
}
{
RefPtr<TriangularSurface::CellArray_t> Cells;
GLenum face;
GLenum mode;
void setMode(int i)
{
switch(i)
{
case 0: mode = GL_FILL; break;
case 1: mode = GL_LINE; break;
case 2: mode = GL_POINT; break;
}
}
TriangleRenderer(const RefPtr<TriangularSurface::CellArray_t>&TriangleCells )
: Cells(TriangleCells)
, face(GL_FRONT_AND_BACK)
, mode(GL_FILL)
{
mode = GL_LINE;
}
void prefix() override
{
glPolygonMode( face, mode);
glEnable(GL_NORMALIZE);
glDisable( GL_BLEND );
}
bool draw() override
{
glPolygonMode( face, mode);
GL::DrawElements( Triangles );
return true;
}
void setLineWidth( double width )
{
glLineWidth( width );
glEnable(GL_POINT_SMOOTH);
glPointSize( width );
}
};
{
RefPtr<MyState> myState = getState(
Context);
if (!myState)
return false;
if (!Surface)
return false;
{
printf("Did not find coordinates :( \n");
return false;
}
{
printf("Did not find cells :( \n");
return false;
}
{
puts("MonochromeSurface: No triangles.");
return false;
}
glEnable(GL_LIGHTING);
glMaterialf( GL_FRONT, GL_SHININESS, 3 );
glMaterialf( GL_BACK , GL_SHININESS, 50 );
glMaterial( GL::FRONT_AND_BACK, GL::AMBIENT , Color( 0,0,.01,0) );
glMaterial( GL::FRONT_AND_BACK, GL::SPECULAR, Color( 0.5,0.5,.53, 0) );
glMaterial( GL::FRONT_AND_BACK, GL::EMISSION, Color( 0., 0.,0., 0) );
glColor4f(1,0,0, 0.5);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glColorMaterial( GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable( GL_COLOR_MATERIAL );
SurfaceColor << Context >> SurfColor;
VEnum Mode;
SurfaceMode << Context >> Mode;
double line_width = 1.0;
LineWidth << Context >> line_width;
if( line_width < 1.0 )
line_width = 1.0;
glColor( SurfColor );
const string VBOKey = "";
RefPtr<ValueSet> V;
Eagle::tvector3 TranslationVector = {0,0,0};
VRenderContext::ModelViewState MVS
= getCoordinateTranslation(
Context, TranslationVector);
RefPtr<VBO> myVBO;
try
{
if (myVBO
&& myState->TranslationVector == TranslationVector)
{
if (RefPtr<TriangleRenderer> TR = myVBO->getRenderer() )
{
TR->setLineWidth( line_width );
TR->setMode( Mode.Case("solid", "line", "points") );
if (myVBO->call() )
{
return true;
}
}
}
}
{}
if (!myVBO)
assert( myVBO );
myVBO->clear();
computeShiftedCoordinates( myState->getCoords()->myChunk(), TranslationVector ) ));
if (RefPtr<TriangularSurface::NormalVectorArray_t> VertexNormals = Surface.
getNormals() )
{
}
myState->TranslationVector = TranslationVector;
RefPtr<TriangleRenderer> TR = new TriangleRenderer(myState->CellField->getData() );
TR->setLineWidth( line_width );
TR->setMode( Mode.Case("solid", "line", "points") );
myVBO->setRenderer( TR );
myVBO->call();
return true;
}
}
namespace
{
MyCreator(
Category(
"Display" ) + VIdentifier(
"MonochromeSurface" ) +
Application(
"General" ) +
Description(
"Display a triangular surface using standard rendering methods. ")
}
Context information to select a grid from within a bundle.
Definition GridSelector.hpp:26
Definition MultiArray.hpp:371
bool setProperty(const string &theName, const Type &theValue) const
Base class for objects rendering skeletons of a fiber bundle.
Definition VSkeletonRenderObject.hpp:21
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Wizt::VCreatorProperty< Wizt::VCreatorProperties::APPLICATION > Application
Wizt::VCreatorProperty< Wizt::VCreatorProperties::DESCRIPTION > Description
Wizt::VCreatorProperty< Wizt::VCreatorProperties::CATEGORY > Category
note: cannot derive from FloatingSkeletonRenderer as long as independent base class TriangleRenderer ...
A triangular surface stored on a Grid.
Definition TriangularSurface.hpp:43
RefPtr< Field > CellField
Field for the triangle indices.
Definition TriangularSurface.hpp:66
RefPtr< Field > CoordField
Field for the vertex coordinates.
Definition TriangularSurface.hpp:59