Java Code Examples for com.jme3.math.Vector3f#get()

The following examples show how to use com.jme3.math.Vector3f#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MBox.java    From Lemur with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected int fillSide( int lastIndex, int side,
                        int colAxis, int colCount,
                        int rowAxis, int rowCount, int otherAxis,
                        FloatBuffer verts, FloatBuffer norms,
                        FloatBuffer texes, ShortBuffer index )
{
    // Waste some space because I don't care too much
    Vector3f normal = normals[side];
    Vector3f tangent = tangents[side];
    Vector3f binormal = binormals[side];

    float rowMin = binormal.get(rowAxis) * -extents.get(rowAxis);
    float rowMax = binormal.get(rowAxis) * extents.get(rowAxis);
    float colMin = tangent.get(colAxis) * -extents.get(colAxis);
    float colMax = tangent.get(colAxis) * extents.get(colAxis);

    float[] rowVals = spread(rowMin, rowMax, rowCount);
    float[] colVals = spread(colMin, colMax, colCount);

    Vector3f pos = new Vector3f();
    pos.set(otherAxis, normal.get(otherAxis) * extents.get(otherAxis));

    int lastBaseIndex = 0;
    for( int j = 0; j < rowCount; j++ ) {
        pos.set(rowAxis, rowVals[j]);

        int baseIndex = lastIndex + j * colCount;

        for( int i = 0; i < colCount; i++ ) {
            pos.set(colAxis, colVals[i]);

            verts.put(pos.x);
            verts.put(pos.y);
            verts.put(pos.z);

            norms.put(normal.x);
            norms.put(normal.y);
            norms.put(normal.z);

            texes.put((float)i/(colCount-1));
            texes.put((float)j/(rowCount-1));

            if( j > 0 && i < colCount - 1 ) {
                // From the second row on, we can emit indexes
                // 2---3   baseIndex+
                // | / |
                // 0---1   lastBaseIndex+
                //
                // 0, 1, 3 ... which is really lbi, lbi+, bi+1
                // 0, 3, 2 ... lbi, bi+1, bi
                //
                index.put((short)lastBaseIndex);
                index.put((short)(lastBaseIndex + 1));
                index.put((short)(baseIndex + 1));
                index.put((short)lastBaseIndex);
                index.put((short)(baseIndex + 1));
                index.put((short)baseIndex);

                baseIndex++;
                lastBaseIndex++;
            }
        }

        lastBaseIndex = lastIndex + j * colCount;
    }

    return lastIndex + colCount * rowCount;
}
 
Example 2
Source File: SpringGridLayout.java    From Lemur with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected final float getMajor( Vector3f v ) {
    return v.get(mainAxis.index());
}
 
Example 3
Source File: SpringGridLayout.java    From Lemur with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected final float getMinor( Vector3f v ) {
    return v.get(minorAxis.index());
}
 
Example 4
Source File: SpringGridLayout.java    From Lemur with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected final float getAlternate( Vector3f v ) {
    return v.get(altAxis.index());
}
 
Example 5
Source File: DynamicInsetsComponent.java    From Lemur with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void reshape( Vector3f pos, Vector3f size ) {
    Vector3f prefSize = lastPreferredSize;
    if( prefSize == null ) {
    
        // Dynamic insets by its nature is going to be the
        // 'base' component or very close to it.  If we don't have
        // a lastPreferredSize then it means calculatePreferredSize
        // was never called.  This can be the result of our parent
        // already knowing what it's preferred size is.  So if 
        // we are attached we will assume that our parent knows
        // best.  We won't cache the value, though, since it implies
        // that we might be incorrect later.  We'll fetch it every time.
        if( isAttached() ) {
            prefSize = getGuiControl().getPreferredSize(); 
        } else {           
            // There is nothing we can do, so we won't do anything
            return;
        }
    }

    // Otherwise, see what the difference is between our
    // desired size and
    Vector3f delta = size.subtract(prefSize);
    Insets3f insets = getInsets();
    for( int i = 0; i < 3; i++ ) {
        float d = delta.get(i);
        if( d <= 0 ) {
            // We don't go smaller than preferred size so
            // we skip if less than 0 and 0 would be a no-op
            // anyway so we skip then too
            continue;
        }

        float min = insets.min.get(i);
        float max = insets.max.get(i);
        float p = pos.get(i);
        float s = size.get(i);

        if( i == 1 ) {
            // To match regular insets we invert y adjustment
            // so that min is at the top.
            pos.set(i, p - min * d);
        } else {
            pos.set(i, p + min * d);
        }
        
        // Set the size such that min and max are accounted
        // for
        size.set(i, s - (min * d + max * d));
    }
}