Exemplo n.º 1
0
AGraph::AGraph()
{
	PrimaryActorTick.bCanEverTick = false;

	ConstructorHelpers::FObjectFinder<UStaticMesh> edgeMesh(TEXT("/Game/Models/EdgeVisualizer"));
	ConstructorHelpers::FObjectFinder<UStaticMesh> vertexMesh(TEXT("/Game/Models/VertexVisualizer"));

	edgeStaticMesh = edgeMesh.Object;
	vertexStaticMesh = vertexMesh.Object;
}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
//!
bool
DFPolygonRenderable::pick( const Viewport& vp, const Vec2f& pos, float r, DFPolygonEditor::Pick& p )
{
   uint32_t idx;
   if( vertexMesh()->pick( vp, pos, r, idx ) )
   {
      p._idx = idx;
      return true;
   }
   return false;
}
Exemplo n.º 3
0
//------------------------------------------------------------------------------
//!
void
DFPolygonRenderable::update()
{
   Vector<float> egver; // vec3: pos, vec3: color
   Vector<float> vgver; // vec3: pos, vec3: color, flt: size
   Vector<uint32_t> eindices;
   Vector<uint32_t> vindices;

   const DFPolygon* poly = _editor->polygon();

   // Vertices.
   for( auto v = poly->begin(); v != poly->end(); ++v )
   {
      vindices.pushBack( uint(vindices.size()) );
      pushBack( vgver, (*v) );
      pushBack( vgver, _col_v_default );
      pushBack( vgver, _siz_v_default );

      pushBack( egver, (*v) );
      pushBack( egver, _col_e_default );
   }
   // Edges.
   const uint n = uint(poly->numVertices());
   for( uint i = 0, j = n-1; i < n; j=i++ )
   {
      eindices.pushBack( j );
      eindices.pushBack( i );
   }

   // Tweak for selection.
   auto& selection = _editor->selection();
   for( auto cur = selection.begin(); cur != selection.end(); ++cur )
   {
      float* ptr         = vgver.data() + cur->_idx*7;
      Vec3f::as( ptr+3 ) = (*cur) == selection.last() ? _col_v_selected_p : _col_v_selected_s;
      ptr[6]             = _siz_v_selected;
   }

   // Updating the meshes.
   MeshGeometry* emesh = edgeMesh();
   MeshGeometry* vmesh = vertexMesh();

   emesh->clearPatches();
   emesh->deallocate();
   if( !egver.empty() )
   {
      emesh->allocateIndices( uint(eindices.size()) );
      emesh->copyIndices( eindices.data() );
      emesh->allocateVertices( uint(egver.size())/6 );
      emesh->copyAttributes( egver.data(), 6, 6, 0 );
      emesh->addPatch( 0, uint(eindices.size()) );
   }
   emesh->updateProperties();
   emesh->invalidateRenderableGeometry();


   vmesh->clearPatches();
   vmesh->deallocate();
   if( !vgver.empty() )
   {
      vmesh->allocateIndices( uint(vindices.size()) );
      vmesh->copyIndices( vindices.data() );
      vmesh->allocateVertices( uint(vgver.size())/7 );
      vmesh->copyAttributes( vgver.data(), 7, 7, 0 );
      vmesh->addPatch( 0, uint(vindices.size()) );
   }
   vmesh->updateProperties();
   vmesh->invalidateRenderableGeometry();
}