summaryrefslogtreecommitdiffstats
path: root/src/OrientedShape3D
diff options
context:
space:
mode:
authorkcr <kcr@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-02-11 00:33:01 +0000
committerkcr <kcr@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-02-11 00:33:01 +0000
commit3480d115b5f73c2ea535322cae88a245d82801e0 (patch)
treeb00123f1d34e517b1ceabb9f0cb5a08f894d80d9 /src/OrientedShape3D
parent4d8aa28ce803e78a1253a6a17bc6f488c9970dd5 (diff)
Updated Downloads section
Diffstat (limited to 'src/OrientedShape3D')
0 files changed, 0 insertions, 0 deletions
ef='#n103'>103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820
/* San Angeles Observation OpenGL ES version example
 * Copyright 2004-2005 Jetro Lauha
 * All rights reserved.
 * Web: http://iki.fi/jetro/
 *
 * This source is free software; you can redistribute it and/or
 * modify it under the terms of EITHER:
 *   (1) The GNU Lesser General Public License as published by the Free
 *       Software Foundation; either version 2.1 of the License, or (at
 *       your option) any later version. The text of the GNU Lesser
 *       General Public License is included with this source in the
 *       file LICENSE-LGPL.txt.
 *   (2) The BSD-style license that is included with this source in
 *       the file LICENSE-BSD.txt.
 *
 * This source is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
 * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
 *
 * $Id$
 * $Revision$
 */

package demos.es1.angeles;

import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import com.jogamp.opengl.util.*;
import com.jogamp.opengl.util.glsl.fixedfunc.*;
import java.nio.*;

public class AngelesGL implements GLEventListener {

    public AngelesGL() {
        this(true);
    }

    public AngelesGL(boolean enableBlending) {
        blendingEnabled = enableBlending;
        quadVertices = GLBuffers.newDirectFloatBuffer(12);
        quadVertices.put(new float[]{
            -1.0f, -1.0f,
             1.0f, -1.0f,
            -1.0f,  1.0f,
             1.0f, -1.0f,
             1.0f,  1.0f,
            -1.0f,  1.0f
        });
        quadVertices.flip();

        light0Position=GLBuffers.newDirectFloatBuffer(4);
        light0Diffuse=GLBuffers.newDirectFloatBuffer(4);
        light1Position=GLBuffers.newDirectFloatBuffer(4);
        light1Diffuse=GLBuffers.newDirectFloatBuffer(4);
        light2Position=GLBuffers.newDirectFloatBuffer(4);
        light2Diffuse=GLBuffers.newDirectFloatBuffer(4);
        materialSpecular=GLBuffers.newDirectFloatBuffer(4);

        light0Position.put(new float[] { FixedPoint.toFloat(-0x40000), 1.0f, 1.0f, 0.0f });
        light0Diffuse.put(new float[] { 1.0f, FixedPoint.toFloat(0x6666), 0.0f, 1.0f });
        light1Position.put(new float[] { 1.0f, FixedPoint.toFloat(-0x20000), -1.0f, 0.0f });
        light1Diffuse.put(new float[] { FixedPoint.toFloat(0x11eb), FixedPoint.toFloat(0x23d7), FixedPoint.toFloat(0x5999), 1.0f });
        light2Position.put(new float[] { -1.0f, 0.0f, FixedPoint.toFloat(-0x40000), 0.0f });
        light2Diffuse.put(new float[] { FixedPoint.toFloat(0x11eb), FixedPoint.toFloat(0x2b85), FixedPoint.toFloat(0x23d7), 1.0f });
        materialSpecular.put(new float[] { 1.0f, 1.0f, 1.0f, 1.0f });

        light0Position.flip();
        light0Diffuse.flip();
        light1Position.flip();
        light1Diffuse.flip();
        light2Position.flip();
        light2Diffuse.flip();
        materialSpecular.flip();

        seedRandom(15);

        width=0;
        height=0;
        x=0;
        y=0;
    }

    public void init(GLAutoDrawable drawable) {
        // FIXME: gl.setSwapInterval(1);

        cComps = drawable.getGL().isGLES1() ? 4: 3;

        this.gl = FixedFuncUtil.wrapFixedFuncEmul(drawable.getGL());
        System.err.println("AngelesGL: "+this.gl);
        
        this.glu = GLU.createGLU();

        gl.glEnable(GL2ES1.GL_NORMALIZE);
        gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glDisable(GL.GL_CULL_FACE);
        gl.glCullFace(GL.GL_BACK);
        gl.glShadeModel(gl.GL_FLAT);

        gl.glEnable(gl.GL_LIGHTING);
        gl.glEnable(gl.GL_LIGHT0);
        gl.glEnable(gl.GL_LIGHT1);
        gl.glEnable(gl.GL_LIGHT2); 

        gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
        gl.glEnableClientState(gl.GL_COLOR_ARRAY);

        for (int a = 0; a < SuperShape.COUNT; ++a)
        {
            sSuperShapeObjects[a] = createSuperShape(SuperShape.sParams[a]);
        }
        sGroundPlane = createGroundPlane();

        gAppAlive = 1;

        sStartTick = System.currentTimeMillis();
        frames=0;

        /*
        gl.glGetError(); // flush error ..
        if(gl.isGLES2()) {
            GLES2 gles2 = gl.getGLES2();

            // Debug ..
            //DebugGLES2 gldbg = new DebugGLES2(gles2);
            //gles2.getContext().setGL(gldbg);
            //gles2 = gldbg;

            // Trace ..
            TraceGLES2 gltrace = new TraceGLES2(gles2, System.err);
            gles2.getContext().setGL(gltrace);
            gles2 = gltrace;
        } */
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        this.width = width;
        this.height=height;
        this.x = x;
        this.y = y;

        this.gl = drawable.getGL().getGL2ES1();

        gl.glMatrixMode(gl.GL_MODELVIEW);
        gl.glLoadIdentity();

        gl.glClearColor(0.1f, 0.2f, 0.3f, 1.0f);

        // JAU gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);

        //gl.glShadeModel(gl.GL_SMOOTH);
        gl.glShadeModel(gl.GL_FLAT);
        gl.glDisable(GL.GL_DITHER);

        //gl.glMatrixMode(gl.GL_PROJECTION);
        //gl.glLoadIdentity();
        //glu.gluPerspective(45.0f, (float)width / (float)height, 0.5f, 150.0f);

        //System.out.println("reshape ..");
    }

    public void dispose(GLAutoDrawable drawable) {
    }

    public void display(GLAutoDrawable drawable) {
        long tick = System.currentTimeMillis();

        if (gAppAlive==0)
            return;

        this.gl = drawable.getGL().getGL2ES1();

        // Actual tick value is "blurred" a little bit.
        sTick = (sTick + tick - sStartTick) >> 1;

        // Terminate application after running through the demonstration once.
        if (sTick >= RUN_LENGTH)
        {
            gAppAlive = 0;
            return;
        }

        gl.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT);

        gl.glMatrixMode(gl.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluPerspective(45.0f, (float)width / (float)height, 0.5f, 150.0f);

        // Update the camera position and set the lookat.
        camTrack();

        // Configure environment.
        configureLightAndMaterial();

        if(blendingEnabled) {
            gl.glEnable(GL.GL_CULL_FACE);
            // Draw the reflection by drawing models with negated Z-axis.
            gl.glPushMatrix();
            drawModels(-1);
            gl.glPopMatrix();
        }

        // Draw the ground plane to the window. (opt. blending)
        drawGroundPlane(); 

        if(blendingEnabled) {
            gl.glDisable(GL.GL_CULL_FACE);
        }

        // Draw all the models normally.
        drawModels(1);

        if(blendingEnabled) {
            // Draw fade quad over whole window (when changing cameras).
            drawFadeQuad();
        }

        frames++;
        tick = System.currentTimeMillis();
    }

    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
    }

 private boolean blendingEnabled = true;
 private GL2ES1 gl; // temp cache
 private GLU glu;

 // Total run length is 20 * camera track base unit length (see cams.h).
 private int RUN_LENGTH  = (20 * CamTrack.CAMTRACK_LEN) ;
 private int RANDOM_UINT_MAX = 65535 ;

 private long sRandomSeed = 0;

void seedRandom(long seed)
{
    sRandomSeed = seed;
}

int randomUInt()
{
    sRandomSeed = sRandomSeed * 0x343fd + 0x269ec3;
    return Math.abs((int) (sRandomSeed >> 16));
}

private int cComps;

// Definition of one GL object in this demo.
public class GLSpatial {
    /* Vertex array and color array are enabled for all objects, so their
     * pointers must always be valid and non-null. Normal array is not
     * used by the ground plane, so when its pointer is null then normal
     * array usage is disabled.
     *
     * Vertex array is supposed to use GL.GL_FLOAT datatype and stride 0
     * (i.e. tightly packed array). Color array is supposed to have 4
     * components per color with GL.GL_UNSIGNED_BYTE datatype and stride 0.
     * Normal array is supposed to use GL.GL_FLOAT datatype and stride 0.
     */
    private int vboName, count;
    private int vComps, nComps;
    private ByteBuffer pBuffer=null;
    private FloatBuffer vertexArray=null;
    private FloatBuffer colorArray=null;
    private FloatBuffer normalArray=null;
    protected GLArrayDataWrapper vArrayData, cArrayData, nArrayData=null;
    
    public GLSpatial(int vertices, int vertexComponents,
                    boolean useNormalArray) {
        count = vertices;
        vComps= vertexComponents;
        nComps = useNormalArray ? 3 : 0;

        int bSize = GLBuffers.sizeOfGLType(GL.GL_FLOAT) * count * ( vComps + cComps + nComps) ;
        pBuffer = GLBuffers.newDirectByteBuffer(bSize);

        int pos = 0;
        int size= GLBuffers.sizeOfGLType(GL.GL_FLOAT) * count * vComps ;
        vertexArray = (FloatBuffer) GLBuffers.sliceGLBuffer(pBuffer, pos, size, GL.GL_FLOAT);
        int vOffset = 0;
        pos+=size;

        size=GLBuffers.sizeOfGLType(GL.GL_FLOAT) * count * cComps ;
        colorArray = (FloatBuffer) GLBuffers.sliceGLBuffer(pBuffer, pos, size, GL.GL_FLOAT);
        int cOffset=pos;
        pos+=size;

        int nOffset=0;
        if(useNormalArray) {
            size=GLBuffers.sizeOfGLType(GL.GL_FLOAT) * count * nComps ;
            normalArray = (FloatBuffer) GLBuffers.sliceGLBuffer(pBuffer, pos, size, GL.GL_FLOAT);
            nOffset=pos;
            pos+=size;
        }
        pBuffer.position(pos);
        pBuffer.flip();

        int[] tmp = new int[1];
        gl.glGenBuffers(1, tmp, 0);
        vboName = tmp[0];
        
        vArrayData = GLArrayDataWrapper.createFixed(gl.GL_VERTEX_ARRAY, vComps, GL.GL_FLOAT, false,
                                                    0, pBuffer, vboName, vOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
        cArrayData = GLArrayDataWrapper.createFixed(gl.GL_COLOR_ARRAY, cComps, GL.GL_FLOAT, false,
                                                    0, pBuffer, vboName, cOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
        if(useNormalArray) {
            nArrayData = GLArrayDataWrapper.createFixed(gl.GL_NORMAL_ARRAY, nComps, GL.GL_FLOAT, false,
                                                        0, pBuffer, vboName, nOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
        }
    }

    void setCount(int c) { 
        if(count != c) {
            throw new RuntimeException("diff count: "+count+" -> "+c);
        }
        count = c; 
    }

    private boolean sealed = false;

    void seal()
    {
        if(sealed) return;
        sealed = true;

        vertexArray.position(count);
        vertexArray.flip();
        colorArray.position(count);
        colorArray.flip();
        if(nComps>0) {
            normalArray.position(count);
            normalArray.flip();
        }

        if(nComps>0) {
            gl.glEnableClientState(gl.GL_NORMAL_ARRAY);
        }

        gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboName);
        gl.glBufferData(GL.GL_ARRAY_BUFFER, pBuffer.limit(), pBuffer, GL.GL_STATIC_DRAW);
        gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);

        if(nComps>0) {
            gl.glDisableClientState(gl.GL_NORMAL_ARRAY);
        }
    }

    void draw()
    {
        seal();
        if(nComps>0) {
           gl.glEnableClientState(gl.GL_NORMAL_ARRAY);
        }

        gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboName);

        gl.glVertexPointer(vArrayData);
        gl.glColorPointer(cArrayData);
        if(nComps>0) {
            gl.glNormalPointer(nArrayData);
        }


        gl.glDrawArrays(GL.GL_TRIANGLES, 0, count);

        gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);

        if(nComps>0) {
            gl.glDisableClientState(gl.GL_NORMAL_ARRAY);
        }
    }
}

long sStartTick = 0;
long sTick = 0;

int sCurrentCamTrack = 0;
long sCurrentCamTrackStartTick = 0;
long sNextCamTrackStartTick = 0x7fffffff;

GLSpatial sSuperShapeObjects[] = new GLSpatial[SuperShape.COUNT];
GLSpatial sGroundPlane;


public class VECTOR3 {
    float x, y, z;

    public VECTOR3() {
        x=0f; y=0f; z=0f;
    }
    public VECTOR3(float x, float y, float z) {
        this.x=x;
        this.y=y;
        this.z=z;
    }
}



static void vector3Sub(VECTOR3 dest, VECTOR3 v1, VECTOR3 v2)
{
    dest.x = v1.x - v2.x;
    dest.y = v1.y - v2.y;
    dest.z = v1.z - v2.z;
}


static void superShapeMap(VECTOR3 point, float r1, float r2, float t, float p)
{
    // sphere-mapping of supershape parameters
    point.x = (float)(Math.cos(t) * Math.cos(p) / r1 / r2);
    point.y = (float)(Math.sin(t) * Math.cos(p) / r1 / r2);
    point.z = (float)(Math.sin(p) / r2);
}


float ssFunc(final float t, final float p[])
{
    return ssFunc(t, p, 0);
}

float ssFunc(final float t, final float p[], int pOff)
{
    return (float)(Math.pow(Math.pow(Math.abs(Math.cos(p[0+pOff] * t / 4)) / p[1+pOff], p[4+pOff]) +
                            Math.pow(Math.abs(Math.sin(p[0+pOff] * t / 4)) / p[2+pOff], p[5+pOff]), 1 / p[3+pOff]));
}


// Creates and returns a supershape object.
// Based on Paul Bourke's POV-Ray implementation.
// http://astronomy.swin.edu.au/~pbourke/povray/supershape/
GLSpatial createSuperShape(final float params[])
{
    final int resol1 = (int)params[SuperShape.PARAMS - 3];
    final int resol2 = (int)params[SuperShape.PARAMS - 2];
    // latitude 0 to pi/2 for no mirrored bottom
    // (latitudeBegin==0 for -pi/2 to pi/2 originally)
    final int latitudeBegin = resol2 / 4;
    final int latitudeEnd = resol2 / 2;    // non-inclusive
    final int longitudeCount = resol1;
    final int latitudeCount = latitudeEnd - latitudeBegin;
    final int triangleCount = longitudeCount * latitudeCount * 2;
    final int vertices = triangleCount * 3;
    GLSpatial result;
    float baseColor[] = new float[3];
    int a, longitude, latitude;
    int currentVertex, currentQuad;

    result = new GLSpatial(vertices, 3, true);
    if (result == null)
        return null;

    for (a = 0; a < 3; ++a)
        baseColor[a] = ((randomUInt() % 155) + 100) / 255.f;

    currentQuad = 0;
    currentVertex = 0;

    // longitude -pi to pi
    for (longitude = 0; longitude < longitudeCount; ++longitude)
    {

        // latitude 0 to pi/2
        for (latitude = latitudeBegin; latitude < latitudeEnd; ++latitude)
        {
            float t1 = (float) ( -Math.PI + longitude * 2 * Math.PI / resol1 );
            float t2 = (float) ( -Math.PI + (longitude + 1) * 2 * Math.PI / resol1 );
            float p1 = (float) ( -Math.PI / 2 + latitude * 2 * Math.PI / resol2 );
            float p2 = (float) ( -Math.PI / 2 + (latitude + 1) * 2 * Math.PI / resol2 );
            float r0, r1, r2, r3;

            r0 = ssFunc(t1, params);
            r1 = ssFunc(p1, params, 6);
            r2 = ssFunc(t2, params);
            r3 = ssFunc(p2, params, 6);

            if (r0 != 0 && r1 != 0 && r2 != 0 && r3 != 0)
            {
                VECTOR3 pa=new VECTOR3(), pb=new VECTOR3(), pc=new VECTOR3(), pd=new VECTOR3();
                VECTOR3 v1=new VECTOR3(), v2=new VECTOR3(), n=new VECTOR3();
                float ca;
                int i;
                //float lenSq, invLenSq;

                superShapeMap(pa, r0, r1, t1, p1);
                superShapeMap(pb, r2, r1, t2, p1);
                superShapeMap(pc, r2, r3, t2, p2);
                superShapeMap(pd, r0, r3, t1, p2);

                // kludge to set lower edge of the object to fixed level
                if (latitude == latitudeBegin + 1)
                    pa.z = pb.z = 0;

                vector3Sub(v1, pb, pa);
                vector3Sub(v2, pd, pa);

                // Calculate normal with cross product.
                /*   i    j    k      i    j
                 * v1.x v1.y v1.z | v1.x v1.y
                 * v2.x v2.y v2.z | v2.x v2.y
                 */

                n.x = v1.y * v2.z - v1.z * v2.y;
                n.y = v1.z * v2.x - v1.x * v2.z;
                n.z = v1.x * v2.y - v1.y * v2.x;

                /* Pre-normalization of the normals is disabled here because
                 * they will be normalized anyway later due to automatic
                 * normalization (GL2ES1.GL_NORMALIZE). It is enabled because the
                 * objects are scaled with glScale.
                 */
                /*
                lenSq = n.x * n.x + n.y * n.y + n.z * n.z;
                invLenSq = (float)(1 / sqrt(lenSq));
                n.x *= invLenSq;
                n.y *= invLenSq;
                n.z *= invLenSq;
                */

                ca = pa.z + 0.5f;

                if(result.normalArray!=null) {
                    for (i = currentVertex * 3;
                         i < (currentVertex + 6) * 3;
                         i += 3)
                    {
                        result.normalArray.put(i    , (n.x));
                        result.normalArray.put(i + 1, (n.y));
                        result.normalArray.put(i + 2, (n.z));
                    }
                }
                for (i = currentVertex * cComps;
                     i < (currentVertex + 6) * cComps;
                     i += cComps)
                {
                    int j;
                    float color[] = new float[3];
                    for (j = 0; j < 3; ++j)
                    {
                        color[j] = ca * baseColor[j];
                        if (color[j] > 1.0f) color[j] = 1.0f;
                    }
                    result.colorArray.put(i    , color[0]);
                    result.colorArray.put(i + 1, color[1]);
                    result.colorArray.put(i + 2, color[2]);
                    if(3<cComps) {
                        result.colorArray.put(i + 3, 0f);
                    }
                }
                result.vertexArray.put(currentVertex * 3, (pa.x));
                result.vertexArray.put(currentVertex * 3 + 1, (pa.y));
                result.vertexArray.put(currentVertex * 3 + 2, (pa.z));
                ++currentVertex;
                result.vertexArray.put(currentVertex * 3, (pb.x));
                result.vertexArray.put(currentVertex * 3 + 1, (pb.y));
                result.vertexArray.put(currentVertex * 3 + 2, (pb.z));
                ++currentVertex;
                result.vertexArray.put(currentVertex * 3, (pd.x));
                result.vertexArray.put(currentVertex * 3 + 1, (pd.y));
                result.vertexArray.put(currentVertex * 3 + 2, (pd.z));
                ++currentVertex;
                result.vertexArray.put(currentVertex * 3, (pb.x));
                result.vertexArray.put(currentVertex * 3 + 1, (pb.y));
                result.vertexArray.put(currentVertex * 3 + 2, (pb.z));
                ++currentVertex;
                result.vertexArray.put(currentVertex * 3, (pc.x));
                result.vertexArray.put(currentVertex * 3 + 1, (pc.y));
                result.vertexArray.put(currentVertex * 3 + 2, (pc.z));
                ++currentVertex;
                result.vertexArray.put(currentVertex * 3, (pd.x));
                result.vertexArray.put(currentVertex * 3 + 1, (pd.y));