Display a triangular surface as transparent object with a pretty shader using conventional depth-sorting (NOT depth-peeling).
#include <ocean/plankton/VPipeline.hpp>
#include <ocean/GLvish/VGLRenderObject.hpp>
#include <ocean/GLvish/BoundingBox.hpp>
#include <ocean/GLvish/ArrayTypes.hpp>
#include <ocean/GLvish/colors.hpp>
#include <ocean/shrimp/VObjectStatus.hpp>
#include <ocean/shrimp/VEnum.hpp>
#include <eagle/PhysicalSpace.hpp>
#include <field/Cell.hpp>
#include <GL/fiberGL.hpp>
#include <GL/FieldBuffer.hpp>
#include <baseop/ExpandBBox.hpp>
#include <eye/retina/VSkeletonRenderObject.hpp>
#include <grid/types/TriangularSurface.hpp>
#include <bundle/BundleProperty.hpp>
#include <bone/GridActor.hpp>
#include <GL/PartialElementRenderer.hpp>
#include <GLvish/Programmable.hpp>
#include <bone/FishField.hpp>
#include <ocean/GLvish/VGLColormap.hpp>
#include <baseop/GridField.hpp>
namespace
{
#define FSHADER_COLORMAP_NAME "ColormapTexture"
{
public:
using glsl = RenderNamespace::glsl;
{
#embed "TransparentColoredSurface.vert"
} );
}
{
#embed "TransparentColoredSurface.frag"
} );
}
{
string ColorFieldName,
ErrorMessage;
using TriangularSurface::operator=;
};
{
return new MyState();
}
Shininess,
Alpha,
Speculartransparency;
enum { NumberOfInputFields = 1 };
, Transparency(this, "transparency", 0.0, 0)
, Shininess(this, "shininess", 0.5, 0)
, Alpha(this, "alpha", 1.0, 2)
, Speculartransparency(this, "speculartransparency", 0.0,3)
, InputRange(
this,
"range",
Range(0,1), 0 )
, SurfaceColorField(this, "field" )
{}
bool update(
VRequest&R,
double precision)
override;
static string createChildname(
const string&
parent_name)
{
return "TransparentColoredSurface(" +
parent_name +
")";
}
};
{
if (!*S)
return setStatusError(
Context,
"No surface available.");
if (!S->CartesianVertices)
return setStatusError(
Context,
"No vertices on the surface available.");
S->ColorFieldName =
FS();
if (S->ColorField)
{
puts(
"YAYYYYYYYY HAVE COLORFIELD");
printf("And it should have a name: %s\n", S->ColorFieldName.c_str() );
}
else
puts(
"NOPE. NO COLORFIELD");
setBoundingBall(
Context, getBoundingBox( S->CoordField ) );
if (S->ErrorMessage.length()>0)
return setStatusError(
Context, S->ErrorMessage );
return setStatusInfo(
Context,
"Surface ready to render.");
}
{
{
assert( Cells->getTypedStorage() );
}
{
}
{
}
};
{
if (!myState)
return false;
myState->ErrorMessage = "";
{
myState->ErrorMessage = "Grid is not a surface";
return false;
}
{
printf("Did not find coordinates :( \n");
myState->ErrorMessage = "Did not find surface coordinates.";
return false;
}
{
printf("Did not find triangles :( \n");
myState->ErrorMessage = "Did not find triangles.";
return false;
}
if (!myState->CellField->getData() )
{
printf("Did not find triangles indices :( \n");
myState->ErrorMessage = "Did not find triangle indices (no data in triangle field)";
return false;
}
if (!Colors)
{
myState->ErrorMessage = "No such field: \"" + myState->ColorFieldName + "\"";
return false;
}
MyProgram->use();
string VBOKey = myState->ColorFieldName ;
GLColormap::Enable(
Cmap,
TC, 1,
true);
{
MyProgram->setUniformTexture( FSHADER_COLORMAP_NAME , *
CmapTexture);
}
try
{
&& (Colors && !
myVBO->isOlderThan( *Colors) ) )
{
{
{
myState->ErrorMessage = "";
return true;
}
}
}
}
{}
{
}
#if 0
if (!Colors)
{
index_t
nVertices =
Surface.CartesianVertices->getPositions()->getData()->nElements();
{
(*SurfaceColors)[ MIndex(i) ] =
fi;
}
}
#endif
{
}
{
{
}
else
}
{
puts(
"TransparentColoredSurface::render() Apparently this is not called!?!?");
{
}
else
}
else
{
puts(
"TransparentColoredSurface::render() Apparently this IS called!?!?");
myState->ErrorMessage = "Color field has unsupported type "
+ Typename(Colors->getElementType())
+ ", only RGB or double supported";
return false;
}
return true;
}
{
{
}
};
}
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
An internal class that stores a couple of textual names.
Definition FieldSelector.hpp:18
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
Context information to select a grid from within a bundle.
Definition GridSelector.hpp:26
A concrete Grid Property which looks for the existence of a Skeleton of the specified dimension and i...
Definition BundleProperty.hpp:76
Base class for objects that render information given on the triangle of a Grid.
Definition TriangleRenderer.hpp:22
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
note: cannot derive from FloatingSkeletonRenderer as long as independent base class TriangleRenderer ...
RenderNamespace::glsl embed_glsl(const char(&file_content)[N])
Class for ranges of types, such as minimum/maximum.
Definition Range.hpp:379
Definition fs/init.hpp:20
A helper class to retrieve fields given on a Grid.
Definition GridField.hpp:19
Definition GridInspector.hpp:13
A triangular surface stored on a Grid.
Definition TriangularSurface.hpp:43
Base class to draw a selection of elements as OpenGL points.
Definition PartialElementRenderer.hpp:85