x3d drawing a pyramid

Hello fellow programmers. I have to say I just started drawing figures on x3d and I'm really needing to constroy a pyramid for a project of mine. Yet nothing I search seems to help me as I cannot understand the logic beyond how the figures are drawn just from looking at code from other people.

I managed to draw a cone using some keywords i found like : "bottomRadius", "height", etc...

But have no idea how I could convert something like this to a pyramid, what keywords should I be aware of that could help me draw the base triangle isntead of a circle like the cone does with the keyword bottomRadius?

Upvotes: 0

Views: 561

Answers (2)

Traian
Traian

Reputation: 3003

Use IndexedFaceSet's coord to define points in space that you can connect (create triangles) using the coordIndex. e.g.:

   Shape {
        geometry IndexedFaceSet {  
        coord Coordinate {      
        point [ 
            1 0 0,
            0 1 0,
            0 0 1,
            0 0 0,
        ]}
        coordIndex [ 
        0,1,2,-1 #face1
        0,1,3,-1 #face2
        0,2,3,-1 #face3
        1,2,3,-1 #face4
        ]
        color Color {
        color [ 1 0 0,0 1 0,0 0 1,1 0 1,]}
        colorPerVertex TRUE
        }

    }

Upvotes: 1

Daly Realism
Daly Realism

Reputation: 141

There is no fundamental shape of a pyramid. The only fundamental shapes are box, cone, cylinder, and sphere. You will need to use one of the detailed geometry shapes: IndexedFaceSet or TriangleSet. These can be coded by hand where you determine the coordinates of all of the verticies. You can also use a modeling tool (Blender is open source) to construct the geometry and export it as X3D.

Upvotes: 0

Related Questions