vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
467 stars 75 forks source link

Can I add line to mesh? or How can I do it? #88

Closed learnerandtrainer closed 3 years ago

learnerandtrainer commented 3 years ago

Hi, I have a geometry as linestring wkt like below and I want to add this line to mesh. But when I want to use AddLine function witth VertexBuilder<VertexPositionNormal, VertexWithBatchId, VertexEmpty> parameters , it thows exeption as "Lines are not supported for this primitive".

Code Example

var p0 = doublePoint.GetP0();
var p1 = doublePoint.GetP1();
var vp0 = new VertexPositionNormal((float)p0.X, (float)p0.Y, (float)p0.Z,-1,-1,-1);
var vb0 = new VertexBuilder<VertexPositionNormal, VertexWithBatchId, VertexEmpty>(vp0, triangle.GetBatchId());

var vp1 = new VertexPositionNormal((float)p0.X, (float)p0.Y, (float)p0.Z, -1, -1, -1);
var vb1 = new VertexBuilder<VertexPositionNormal, VertexWithBatchId, VertexEmpty>(vp0, triangle.GetBatchId());

var indices = prim.AddLine(vb0,vb1);

Can you give me any advice?

example geometry wkt LINESTRING Z(-0.050057364627719 -4.95065027987584 3.85658505978063, -0.40773748466745 -4.96740795951337 3.49703856976703, -1.39711167477071 -2.76645434973761 4.31435906980187, -3.41709169466048 1.84214789047837 6.15206754999235, -5.93857609480619 1.66874384041876 3.53168269991875, -6.49239724455401 2.94939182046801 4.00929037015885, -10.3402780848555 2.48362592048943 0.340840119868517, -7.50409694481641 -3.25291960965842 -2.07654881011695, -7.39860110497102 -3.24410355975851 -1.96901796991006, -5.07701519457623 -7.75867012981325 -3.98503777012229, -3.01721681468189 -7.79926744988188 -1.6832042299211, -2.70239263493568 -8.43866654951125 -1.93677648017183, -0.263346024788916 -8.49103767983615 1.00543212005869, -0.49896850483492 -7.82721681986004 1.19889017986134, 1.15692434506491 -7.74893179954961 2.96306006982923)

vpenades commented 3 years ago

somewhere outside the code you posted, you might have something like this:

var prim = meshBuilder.UsePrimitive(material);

you have to specify the number of vertices per primitive, like this:

var prim = meshBuilder.UsePrimitive(material, 2);

Where:

  1. points
  2. lines
  3. triangles

A primitive can only support one kind of primitive at a time, so if you want to mix lines and triangles in the same mesh, you have to create separate primitives.

learnerandtrainer commented 3 years ago

thank you vpenades . it works but I couldnt see on 3d map and also cessium returned http 304 , is that normal? or did I missed somethings? image image

vpenades commented 3 years ago

can you try with BabylonJS?