Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package engine.rendering.lighting;
- import org.lwjgl.util.vector.Vector3f;
- public class ConeGenerator{
- private Vector3f[] positions;
- private short[] indices;
- public void create(int subdivisions){
- positions = new Vector3f[subdivisions + 1];
- positions[0] = new Vector3f(0, 0, 0);
- for(int i = 0; i < subdivisions; i++){
- positions[i + 1] = new Vector3f((float)Math.cos(Math.PI * 2 * i / subdivisions), (float)Math.sin(Math.PI * 2 * i / subdivisions), 1);
- }
- indices = new short[(subdivisions*2 - 2) * 3];
- int index = 0;
- for(int i = 1; i < subdivisions; i++){
- indices[index++] = 0; //Source point
- indices[index++] = (short)(i+1);
- indices[index++] = (short)i;
- }
- indices[index++] = 0; //Source point
- indices[index++] = 1;
- indices[index++] = (short)subdivisions;
- for(int i = 2; i < subdivisions; i++){
- indices[index++] = 1;
- indices[index++] = (short)i;
- indices[index++] = (short)(i+1);
- }
- }
- public Vector3f[] getPositions(){
- return positions;
- }
- public short[] getIndices(){
- return indices;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement