• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difficulty rendering an octahedron (2 pyramids attached at the bottom to each other)

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having difficulty with my homework project rendering an octahedron by modifying an existing project that renders a pyramid. The hint given is to change the vertices, colors, and indices objects. I did that but the best I could generate is the existing pyramid with 1 or 2 faces of the inverted pyramid shown while it is rotating on screen. I have been changing the order of the indices and vertices but still can not solve the problem. I think these values are correct if I draw it on paper. I would appreciate some tips to solve the problem as I have not make any progress after days of fruitless tinkering. Perhaps I need to modify other code? Thanks in advance! Here are the values of the vertices, colors, and indices:

private float[] vertices = { // 6 vertices of the pyramid in (x,y,z)
-1.0f, -1.0f, -1.0f, // 0. left-bottom-back
1.0f, -1.0f, -1.0f, // 1. right-bottom-back
1.0f, -1.0f, 1.0f, // 2. right-bottom-front
-1.0f, -1.0f, 1.0f, // 3. left-bottom-front
0.0f, 1.0f, 0.0f, // 4. top

//added vertex
0.0f, -3.0f, 0.0f // 4. bottom
};

private float[] colors = { // Colors of the 6 vertices in RGBA
0.0f, 0.0f, 1.0f, 1.0f, // 0. blue
0.0f, 1.0f, 0.0f, 1.0f, // 1. green
0.0f, 0.0f, 1.0f, 1.0f, // 2. blue
0.0f, 1.0f, 0.0f, 1.0f, // 3. green
1.0f, 0.0f, 0.0f, 1.0f, // 4. red

//added color
1.0f, 1.0f, 0.0f, 0.0f // 5. yellow
};

private byte[] indices = {
2, 4, 3, // front face (CCW) - same as 4,3,2 or 3,2,4
4, 2, 1, // right face - same as 2,1,4 or 1,4,2
0, 4, 1, // back face - same 4,1,0 or 1,0,4
4, 0, 3, // left face - same 0,3,4 or 3,4,2

// inverted pyramid
3, 5, 2,
2, 5, 1,
1, 5, 0,
3, 5, 0,
};
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic