Somerussian
Somerussian

Reputation: 391

x3d - how to create polygon (polyhedron)?

I'm new to x3d and have no idea how to create flat area like on picture in x3d? polygon Here are the coordinates of dots:
2360,1746,2246,1746,2139,1746,2139,1611,1923,1611,1923,2053,2246,2053,2246,1984,2371,1984,2371,2053,2462,2053,2462,1993,2496,1993,2496,2053,2555,2053,2556,1746

Can anybody help me with that?
And which way is better: extrusion or faceset or indexedfaceset?
Thanks.

Update:

I've tried this

    <shape>
      <appearance alphaclipthreshold="0.1" sorttype="auto">
        <material specularcolor="0,0,0" shininess="0.2" emissivecolor="0,0,0" ambientintensity="0.2" diffusecolor="1 1 0.94" transparency="0"></material>
      </appearance>
      <indexedfaceset>
        <coordinate point="2360 1746 2246 1746 2139 1746 2139 1611 1923 1611 1923 2053 2246 2053 2246 1984 2371 1984 2371 2053 2462 2053 2462 1993 2496 1993 2496 2053 2555 2053 2556 1746"></coordinate>
      </indexedfaceset>
    </shape>

And this:

    <Shape>
      <Appearance alphaClipThreshold="0.1" sortType="auto">
        <Material ambientIntensity="0.2" shininess="0.2" transparency="0.0" emissiveColor="#000000" specularColor="#2A2A2A" diffuseColor="#3F7EBD"></Material>
      </Appearance>
      <Extrusion scale="1,1" orientation="0,0,0,0" height="0.1" crossSection="2360,1746,2246,1746,2139,1746,2139,1611,1923,1611,1923,2053,2246,2‌053,2246,1984,2371,1984,2371,2053,2462,2053,2462,1993,2496,1993,2496,2053,2555,20‌​53,2556,1746"></Extrusion> </Shape>

And result was either blank or some random-looking picture.
Any ideas?

Upvotes: 2

Views: 862

Answers (1)

ViennaMike
ViennaMike

Reputation: 2337

You have multiple issues. For a good reference, I recommend X3D: Extensible 3D graphics for web authors. An IndexedFaceSet is actually NOT one of the easier X3D nodes to start with.

First, the IndexedFaceSet use camel case, e.g., IndexedFaceSet. Second, an IndexedFaceSet geometry has two, not one, key components to set the geometry. One is the coordinate point list, as you have. But that's an unordered list of points. as part of the IndexedFaceSet element you have to specify the vertices by point number, with each face ending with a "-1" to signal the end. Preferably in counter-clockwise order (otherwise you need to set ccw="false").

Also, if your polygon is not convex (yours isn't), you need to set convex = "false" as the default is true.

Remember too that X3D is indeed 3D. Your point list has to provide x, y AND z coordinates, even though an indexed face set is a plane, since it could be at any orientation in 3D space. You only provided two coordinates per point.

Here's a simple example:

<X3D>
<Scene>
<Shape>
  <IndexedFaceSet ccw = "true" colorPerVertex = "false" solid = "false" convex = "false" coordIndex='0 1 2 3 4 5 6 7 -1'>
    <Color color='0 0 1'/>
    <coordinate point='-4 -4 0 -1 -4 0 -1 1 0 1 1 0 1 -4 0 4 -4 0 4 3 0 -4 3 0'></coordinate>
  </IndexedFaceSet>
</Shape>
</Scene>
</X3D> 

Upvotes: 2

Related Questions