当前位置: 首页>>代码示例>>Java>>正文


Java BufferUtils.setInBuffer方法代码示例

本文整理汇总了Java中com.jme3.util.BufferUtils.setInBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java BufferUtils.setInBuffer方法的具体用法?Java BufferUtils.setInBuffer怎么用?Java BufferUtils.setInBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.util.BufferUtils的用法示例。


在下文中一共展示了BufferUtils.setInBuffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * Applies the offsets of this pose to the vertex buffer given by the blend factor.
 *
 * @param blend Blend factor, 0 = no change to vert buf, 1 = apply full offsets
 * @param vertbuf Vertex buffer to apply this pose to
 */
public void apply(float blend, FloatBuffer vertbuf){
    for (int i = 0; i < indices.length; i++){
        Vector3f offset = offsets[i];
        int vertIndex   = indices[i];

        tempVec.set(offset).multLocal(blend);

        // aquire vert
        BufferUtils.populateFromBuffer(tempVec2, vertbuf, vertIndex);

        // add offset multiplied by factor
        tempVec2.addLocal(tempVec);

        // write modified vert
        BufferUtils.setInBuffer(tempVec2, vertbuf, vertIndex);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:Pose.java

示例2: writeNormalArray

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public FloatBuffer writeNormalArray(FloatBuffer store, Vector3f scale) {
        if (!isLoaded())
            throw new NullPointerException();
        
        if (store!=null){
            if (store.remaining() < getWidth()*getHeight()*3)
                throw new BufferUnderflowException();
        }else{
            store = BufferUtils.createFloatBuffer(getWidth()*getHeight()*3);
        }
        store.rewind();
        
        if (!hasNormalmap()){
            Vector3f oppositePoint = new Vector3f();
            Vector3f adjacentPoint = new Vector3f();
            Vector3f rootPoint = new Vector3f();
            Vector3f tempNorm = new Vector3f();
            int normalIndex = 0;

            for (int y = 0; y < getHeight(); y++) {
                for (int x = 0; x < getWidth(); x++) {
                    rootPoint.set(x, getValue(x,y), y);
                    if (y == getHeight() - 1) {
                        if (x == getWidth() - 1) {  // case #4 : last row, last col
                            // left cross up
//                            adj = normalIndex - getWidth();
//                            opp = normalIndex - 1;
                            adjacentPoint.set(x, getValue(x,y-1), y-1);
                            oppositePoint.set(x-1, getValue(x-1, y), y);
                        } else {                    // case #3 : last row, except for last col
                            // right cross up
//                            adj = normalIndex + 1;
//                            opp = normalIndex - getWidth();
                            adjacentPoint.set(x+1, getValue(x+1,y), y);
                            oppositePoint.set(x, getValue(x,y-1), y-1);
                        }
                    } else {
                        if (x == getWidth() - 1) {  // case #2 : last column except for last row
                            // left cross down
                            adjacentPoint.set(x-1, getValue(x-1,y), y);
                            oppositePoint.set(x, getValue(x,y+1), y+1);
//                            adj = normalIndex - 1;
//                            opp = normalIndex + getWidth();
                        } else {                    // case #1 : most cases
                            // right cross down
                            adjacentPoint.set(x, getValue(x,y+1), y+1);
                            oppositePoint.set(x+1, getValue(x+1,y), y);
//                            adj = normalIndex + getWidth();
//                            opp = normalIndex + 1;
                        }
                    }



                    tempNorm.set(adjacentPoint).subtractLocal(rootPoint)
                            .crossLocal(oppositePoint.subtractLocal(rootPoint));
                    tempNorm.multLocal(scale).normalizeLocal();
//                    store.put(tempNorm.x).put(tempNorm.y).put(tempNorm.z);
                    BufferUtils.setInBuffer(tempNorm, store,
                            normalIndex);
                    normalIndex++;
                }
            }
        }else{
            Vector3f temp = new Vector3f();
            for (int z = 0; z < getHeight(); z++){
                for (int x = 0; x < getWidth(); x++){
                    getNormal(x,z,temp);
                    store.put(temp.x).put(temp.y).put(temp.z);
                }
            }
        }

        return store;
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:76,代码来源:AbstractGeomap.java

示例3: recurseMini

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * Used from calcWelzl. This function recurses to calculate a minimum
 * bounding sphere a few points at a time.
 *
 * @param points
 *            The array of points to look through.
 * @param p
 *            The size of the list to be used.
 * @param b
 *            The number of points currently considering to include with the
 *            sphere.
 * @param ap
 *            A variable simulating pointer arithmatic from C++, and offset
 *            in <code>points</code>.
 */
private void recurseMini(FloatBuffer points, int p, int b, int ap) {
    TempVars vars = TempVars.get();

    Vector3f tempA = vars.vect1;
    Vector3f tempB = vars.vect2;
    Vector3f tempC = vars.vect3;
    Vector3f tempD = vars.vect4;

    switch (b) {
        case 0:
            this.radius = 0;
            this.center.set(0, 0, 0);
            break;
        case 1:
            this.radius = 1f - RADIUS_EPSILON;
            BufferUtils.populateFromBuffer(center, points, ap - 1);
            break;
        case 2:
            BufferUtils.populateFromBuffer(tempA, points, ap - 1);
            BufferUtils.populateFromBuffer(tempB, points, ap - 2);
            setSphere(tempA, tempB);
            break;
        case 3:
            BufferUtils.populateFromBuffer(tempA, points, ap - 1);
            BufferUtils.populateFromBuffer(tempB, points, ap - 2);
            BufferUtils.populateFromBuffer(tempC, points, ap - 3);
            setSphere(tempA, tempB, tempC);
            break;
        case 4:
            BufferUtils.populateFromBuffer(tempA, points, ap - 1);
            BufferUtils.populateFromBuffer(tempB, points, ap - 2);
            BufferUtils.populateFromBuffer(tempC, points, ap - 3);
            BufferUtils.populateFromBuffer(tempD, points, ap - 4);
            setSphere(tempA, tempB, tempC, tempD);
            vars.release();
            return;
    }
    for (int i = 0; i < p; i++) {
        BufferUtils.populateFromBuffer(tempA, points, i + ap);
        if (tempA.distanceSquared(center) - (radius * radius) > RADIUS_EPSILON - 1f) {
            for (int j = i; j > 0; j--) {
                BufferUtils.populateFromBuffer(tempB, points, j + ap);
                BufferUtils.populateFromBuffer(tempC, points, j - 1 + ap);
                BufferUtils.setInBuffer(tempC, points, j + ap);
                BufferUtils.setInBuffer(tempB, points, j - 1 + ap);
            }
            vars.release();
            recurseMini(points, i, b + 1, ap + 1);

        }
    }
    vars.release();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:69,代码来源:BoundingSphere.java

示例4: update

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
@Override
public void update(float tpf) {

	// #################### BEGIN Asynchronous solution #################

	boolean pointAdded = false;

	int lastMeasurementIndex = sim.mbuffer.getLastRecordedPointIndex();

	// Was a new point added since the previous update of the point cloud VBO?
	if (lastMeasurementIndex != lastVisualizedPointIndex) {

		VertexBuffer pointCloudVB = pointCloudMesh.getBuffer(Type.Position);
		//VertexBuffer pointSize = pointCloudMesh.getBuffer(Type.Size);

		while (true) {

			Measurement m = sim.mbuffer.getEntryAt(lastVisualizedPointIndex);

			lastVisualizedPointIndex++;

			if (lastVisualizedPointIndex >= sim.mbuffer.getSize() - 1) {
				lastVisualizedPointIndex = 0;
			}

			if (m != null) {

				newPointPos = am2jme_vector(m.beamOrigin.add(m.beamDirection.scalarMultiply(m.distance - mPointDistOffset)));

				BufferUtils.setInBuffer(newPointPos, (FloatBuffer) pointCloudVB.getData(), pointCloudVboAddIndex);

				pointCloudVboAddIndex++;

				if (pointCloudVboAddIndex == cfg_pointCloudBufferSize - 1) {
					pointCloudVboAddIndex = 0;
				}

				pointAdded = true;
			}

			if (lastVisualizedPointIndex == lastMeasurementIndex) {
				break;
			}
		}

		// #################### END Asynchronous solution #################

		// #################### BEGIN Synchronous (single-thread) solution #################
		/*
		 * lastPoint = sim.getScanner().lastPoint;
		 * 
		 * if (lastPoint != null) {
		 * 
		 * Vector3f newPoint = am2jme_vector(lastPoint.position);
		 * 
		 * BufferUtils.setInBuffer(newPoint, (FloatBuffer) pointCloudVB.getData(), pointCloudVboAddIndex);
		 * 
		 * pointCloudVboAddIndex++;
		 * 
		 * if (pointCloudVboAddIndex == cfg_pointCloudBufferSize - 1) { pointCloudVboAddIndex = 0; }
		 * 
		 * pointAdded = true; }
		 */
		// #################### END Synchronous (single-thread) solution #################

		// If a new point was added to the point cloud VBO, update the VBO:
		if (pointAdded) {
	
			// ATTENTION:
			// Apparently, pointCloudMesh.updateBound() isn't needed.
			// Not doing it gives about 50% more FPS on the Thinkpad.
			// pointCloudMesh.updateBound();
			pointCloudVB.setUpdateNeeded();
			pointCloudGeometry.updateModelBound();
		}
	}

}
 
开发者ID:GIScience,项目名称:helios,代码行数:79,代码来源:ShowPointCloudAppState.java


注:本文中的com.jme3.util.BufferUtils.setInBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。