This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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,
};
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!