@@ -31,6 +31,7 @@ public class BezierRotation {
3131 */
3232 public BezierRotation (int nPoints , ArrayList <Vector4f > controlPoints , int nRotations , RenderContext renderContext ) {
3333 bCurve = new BezierCurve (nPoints , controlPoints );
34+ int nSegments = controlPoints .size ()/4 %4 ;
3435
3536 // bCurves = new ArrayList<BezierCurve>();
3637
@@ -50,13 +51,14 @@ public BezierRotation(int nPoints, ArrayList<Vector4f> controlPoints, int nRotat
5051 if (!test ) {
5152 concatinateCurves (nRotations );
5253 calculateColors (nPoints , nRotations );
53- calculateIndices (nPoints , nRotations );
54- createShape (nRotations * nPoints , renderContext );
54+ calculateIndices (nPoints , nRotations , nSegments );
55+ createShape (points . length / 3 , renderContext );
5556 }
5657 }
5758
5859 private void test (BezierCurve bCurve , int nPoints , RenderContext renderContext ) {
5960 bCurve .getPoints ().add (new Vector4f (0 , 1 , 0 , 1 ));
61+ bCurve .getNormals ().add (new Vector4f (-1 ,0 ,0 ,0 ));
6062
6163 points = toBArray (bCurve .getPoints ());
6264 colors = new float [points .length ];
@@ -66,7 +68,7 @@ private void test(BezierCurve bCurve, int nPoints, RenderContext renderContext)
6668 for (int i = 0 ; i < colors .length ; i ++)
6769 colors [i ] = 1 ;
6870
69- VertexData vData = renderContext .makeVertexData (nPoints + 1 );
71+ VertexData vData = renderContext .makeVertexData (points . length / 3 );
7072
7173 vData .addElement (points , VertexData .Semantic .POSITION , 3 );
7274 vData .addElement (colors , VertexData .Semantic .COLOR , 3 );
@@ -118,27 +120,27 @@ private void concatinateCurves(int nRotations) {
118120 * set all colors to white
119121 */
120122 private void calculateColors (int nPoints , int nRotations ) {
121- this .colors = new float [nPoints * nRotations * 3 ];
123+ this .colors = new float [points . length ];
122124
123125 for (int i = 0 ; i < colors .length ; i ++) {
124126 colors [i ] = 1 ;
125127 }
126128 }
127129
128130 // TODO: not yet finished
129- private void calculateIndices (int nPoints , int nRotations ) {
131+ private void calculateIndices (int nPoints , int nRotations , int nSegments ) {
130132 ArrayList <Integer > indices = new ArrayList <Integer >();
131133
132134 for (int j = 0 ; j < nRotations ; j ++) {
133- for (int i = 0 ; i < 6 * (nPoints - 1 ); i += 6 ) {
135+ for (int i = 0 ; i < 6 * (nPoints * nSegments - 1 ); i += 6 ) {
134136
135- indices .add ((i / 6 + (j * nPoints )));
136- indices .add (((i / 6 + (j * nPoints )) + 1 + (nPoints )) % ((nPoints ) * nRotations ));
137- indices .add (((i / 6 + (j * nPoints )) + (nPoints )) % ((nPoints ) * nRotations ));
137+ indices .add ((i / 6 + (j * nPoints * nSegments )));
138+ indices .add (((i / 6 + (j * nPoints * nSegments )) + 1 + (nPoints * nSegments )) % ((nPoints * nSegments ) * nRotations ));
139+ indices .add (((i / 6 + (j * nPoints * nSegments )) + (nPoints * nSegments )) % ((nPoints * nSegments ) * nRotations ));
138140
139- indices .add ((i / 6 + (j * nPoints )));
140- indices .add (((i / 6 + (j * nPoints )) + 1 ) % ((nPoints ) * nRotations ));
141- indices .add (((i / 6 + (j * nPoints ) + 1 ) + (nPoints )) % ((nPoints ) * nRotations ));
141+ indices .add ((i / 6 + (j * nPoints * nSegments )));
142+ indices .add (((i / 6 + (j * nPoints * nSegments )) + 1 ) % ((nPoints * nSegments ) * nRotations ));
143+ indices .add (((i / 6 + (j * nPoints * nSegments ) + 1 ) + (nPoints * nSegments )) % ((nPoints * nSegments ) * nRotations ));
142144 }
143145 }
144146 this .indices = toIArray (indices );
0 commit comments