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


Java Vector3f.divideLocal方法代码示例

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


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

示例1: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;	
	
	
	Vector3f pos = toControl.getRelativeFromWorld(from, new Vector3f());
//	System.out.println(pos);
	//pos.subtractLocal(ActionToolSettings.getInstance().getGridOrigin().getValue());
	Vector3f grid = new Vector3f( ActionToolSettings.getInstance().getGridUnits().getValue());
	grid.y/=2f;
	grid.z/=2f;
	pos.divideLocal(grid);
	pos.x = Math.round(pos.x);
	pos.y = Math.round(pos.y);
	pos.z = Math.round(pos.z);
	pos.multLocal(grid);
	return toControl.getWorldFromRelative(pos, from);
}
 
开发者ID:sambayless,项目名称:golems,代码行数:18,代码来源:AxleControlPoint.java

示例2: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;	
	
	
	Vector3f pos = toControl.getRelativeFromWorld(from, new Vector3f());
//	System.out.println(pos);
	//pos.subtractLocal(ActionToolSettings.getInstance().getGridOrigin().getValue());
	Vector3f grid = new Vector3f( ActionToolSettings.getInstance().getGridUnits().getValue());
	grid.x/=2f;
	grid.z/=2f;
	//grid.z = 1;
	grid.x = 1;
	pos.divideLocal(grid);
//	pos.x = Math.round(pos.x);
	pos.y = Math.round(pos.y);
	pos.z = Math.round(pos.z);
	pos.multLocal(grid);
	return toControl.getWorldFromRelative(pos, from);
}
 
开发者ID:sambayless,项目名称:golems,代码行数:20,代码来源:HydraulicControlPoint.java

示例3: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;	
	
	
	Vector3f pos = toControl.getRelativeFromWorld(from, new Vector3f());
//	System.out.println(pos);
	//pos.subtractLocal(ActionToolSettings.getInstance().getGridOrigin().getValue());
	Vector3f grid = new Vector3f( ActionToolSettings.getInstance().getGridUnits().getValue());
//	grid.y/=2f;
	grid.z/=2f;
	pos.divideLocal(grid);
	pos.x = Math.round(pos.x);
	pos.y = Math.round(pos.y); //the rotation implementation is wrong, but it will do for now.
	pos.z = Math.round(pos.z);
	pos.multLocal(grid);
	return toControl.getWorldFromRelative(pos, from);
}
 
开发者ID:sambayless,项目名称:golems,代码行数:18,代码来源:HingeControlPoint.java

示例4: getTetrahedronProperties

import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
 * The centroid of a tetrahedron (or any other simplex) is just the average of each point.
 * The volume of the tetrahedron is given by this formula, where a, b, c and d are the four vertices, in any order: 
 * V = abs[(a-d) dot ((b-d)cross(c-d))]/6
 * 
 * See:
 * http://en.wikipedia.org/wiki/Tetrahedron
 * http://en.wikipedia.org/wiki/Centroid
 * @param v1
 * @param v2
 * @param v3
 * @param v4
 * @param store
 * @return
 */
private float getTetrahedronProperties(Vector3f v1, Vector3f v2,Vector3f v3,Vector3f v4,  Vector3f store)
{
	_aMinusD.set(v1).subtractLocal(v4);
	_bMinusD.set(v2).subtractLocal(v4);
	_cMinusD.set(v3).subtractLocal(v4);
	Vector3f crossProduct = _bMinusD.crossLocal(_cMinusD);
	float volume = FastMath.abs(_aMinusD.dot(crossProduct))/6f;
	
	store.set(v1);
	store.addLocal(v2);
	store.addLocal(v3);
	store.addLocal(v4);
	store.divideLocal(4);

	if (debugMode)
	 drawTetrahedron(v1.subtract(object.getSpatial().getWorldTranslation()),v2.subtract(object.getSpatial().getWorldTranslation()),v3.subtract(object.getSpatial().getWorldTranslation()),v4.subtract(object.getSpatial().getWorldTranslation()));
	return volume;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:34,代码来源:BuoyantBox.java

示例5: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;	
	
	
	Vector3f pos = toControl.getRelativeFromWorld(from, new Vector3f());
//	System.out.println(pos);
	//pos.subtractLocal(ActionToolSettings.getInstance().getGridOrigin().getValue());
	pos.divideLocal(ActionToolSettings.getInstance().getGridUnits().getValue());
	pos.x = Math.round(pos.x);
	pos.y = Math.round(pos.y);
	pos.z = Math.round(pos.z);
	pos.multLocal(ActionToolSettings.getInstance().getGridUnits().getValue());
	return toControl.getWorldFromRelative(pos, from);
}
 
开发者ID:sambayless,项目名称:golems,代码行数:15,代码来源:ControlPoint.java

示例6: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;	
	
	from.subtractLocal(ActionToolSettings.getInstance().getGridOrigin().getValue());
	from.divideLocal(ActionToolSettings.getInstance().getGridUnits().getValue());
	from.x = Math.round(from.x);
	from.y = Math.round(from.y);
	from.z = Math.round(from.z);
	from.multLocal(ActionToolSettings.getInstance().getGridUnits().getValue());
	return from;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:12,代码来源:ActionNode.java

示例7: transformPoint

import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
 * Transform the given point into a new coordinate system. Store the result in a static vector.
 * This transforms the translation, scale, AND rotation of the point.
 * @param point
 * @param coordinateSystem
 * @return
 */
public static Vector3f transformPoint(Vector3f point, Spatial coordinateSystem)
{
       Vector3f testPoint =  point.subtract( coordinateSystem.getWorldTranslation(), _storeVector);//.divideLocal(getWorldScale());
       coordinateSystem.getWorldRotation().inverse().mult(testPoint, testPoint);
	testPoint.divideLocal( coordinateSystem.getWorldScale());	
	return testPoint;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:15,代码来源:PointCollisionTest.java

示例8: calculateCenter

import com.jme.math.Vector3f; //导入方法依赖的package包/类
private void calculateCenter()
{
       center = new Vector3f();
       //average the 4 points to get the center
       for (Vector3f vertex:vertices)
       {
       	center.addLocal(vertex);
       }
       center.divideLocal(vertices.length);
}
 
开发者ID:sambayless,项目名称:golems,代码行数:11,代码来源:Tetrahedron.java

示例9: setNormalData

import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
 * 
 * <code>setNormalData</code> defines the normals of each face of the
 * tetrahedron.
 *  
 */
private void setNormalData() {

	
	FloatBuffer norms = BufferUtils.createVector3Buffer(12);
       
	//for each side, to get the normal of that side, average its vertices, subtract the center from that average, and normalize
	Vector3f[][] sides = new Vector3f[4][];
       sides[0] = new Vector3f[]{vertices[0], vertices[1],vertices[2]};
       sides[1] = new Vector3f[]{vertices[0], vertices[1],vertices[3]};
       sides[2] = new Vector3f[]{vertices[0], vertices[2],vertices[3]};
       sides[3] = new Vector3f[]{vertices[1], vertices[2],vertices[3]};
	
       for (int i = 0; i < sides.length;i++)
       {
       	Vector3f centerOfSide = new Vector3f();
       	for (Vector3f vertex:sides[i])
       	{
       		centerOfSide.addLocal(vertex);
       	}
       	centerOfSide.divideLocal(sides[i].length);
       	centerOfSide.subtractLocal(center);//this is now the normal of this side
       	centerOfSide.normalizeLocal();
       	
       	
       	for (int e = 0;e <sides[i].length;e++)
       	{//Put these normals into the buffer
       		norms.put(centerOfSide.x).put(centerOfSide.y).put(centerOfSide.z);
       	}
       }

       norms.rewind();
       TriangleBatch batch = getBatch(0);
       batch.setNormalBuffer(norms);
}
 
开发者ID:sambayless,项目名称:golems,代码行数:41,代码来源:Tetrahedron.java

示例10: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;
	if (controllable == null)
		return from;
	
	if (type == CapsulePosition.RADIAL_TOP || type == CapsulePosition.RADIAL_BOTTOM)
	{
	
		controllable.getParent().updateWorldData();
		controllable.updateWorldData();

		from = controllable.getParent().worldToLocal(from,from);

		cacheUnit.set(getControlDistance());
		from.subtractLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...
		
		cacheUnit.set(ActionToolSettings.getInstance().getGridUnits().getValue()).divideLocal(2f);

		from.divideLocal(cacheUnit);
		from.x = Math.round(from.x);
		from.y = Math.round(from.y);
		from.z = Math.round(from.z);
		from.multLocal(cacheUnit);			
		
		cacheUnit.set(getControlDistance());
		from.addLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...

		from = controllable.getParent().localToWorld(from,from);
		return from;
	}else
	{
		/*Vector3f axis = new Vector3f( type == CapsulePosition.LENGTH_RIGHT? Vector3f.UNIT_X:Vector3f.UNIT_X.mult(-1f));
		controllable.getParent().updateWorldData();
		controllable.updateWorldData();
		controllable.getParent().updateWorldData();
		from = controllable.getParent().worldToLocal(from,from);
			

	//	Vector3f bottom = controllable.getParent().getLocalTranslation().subtract(axis.mult(controllable.getInterpreter().getHeight())).multLocal(0.5f));
	//	controllable.getParent().getWorldRotation().multLocal(axis);
		from.subtractLocal(axis.divideLocal(2f));

	
		from.subtractLocal(getControlDistance());//Have to account for control distance...
				
		from.divideLocal(ActionToolSettings.getInstance().getGridUnits().getValue());
		//Vector3f orig = new Vector3f(from);
		from.x = Math.round(from.x);
		from.y = Math.round(from.y);
		from.z = Math.round(from.z);
	//	orig.subtractLocal(orig)
		from.multLocal(ActionToolSettings.getInstance().getGridUnits().getValue());			
		
	
		
		from.addLocal(getControlDistance());//Have to account for control distance...

		from.addLocal(axis);
		System.out.println(from);
		from = controllable.getParent().localToWorld(from,from);*/
		return from;
	}			
}
 
开发者ID:sambayless,项目名称:golems,代码行数:65,代码来源:CapsuleControlPoint.java

示例11: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;
	if (controllable == null)
		return from;
	
	if (point == RADIUS)
	{
	
		controllable.getParent().updateWorldData();
		controllable.updateWorldData();

		from = controllable.getParent().worldToLocal(from,from);

		cacheUnit.set(getControlDistance());
		from.subtractLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...
		
		cacheUnit.set(ActionToolSettings.getInstance().getGridUnits().getValue()).divideLocal(2f);

		from.divideLocal(cacheUnit);
		from.x = Math.round(from.x);
		from.y = Math.round(from.y);
		from.z = Math.round(from.z);
		from.multLocal(cacheUnit);			
		
		cacheUnit.set(getControlDistance());
		from.addLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...

		from = controllable.getParent().localToWorld(from,from);
		return from;
	}else
	{
		
		controllable.getParent().updateWorldData();
		controllable.updateWorldData();

		from = controllable.getParent().worldToLocal(from,from);
		
		Vector3f scale = controllable.getLocalScale();
		if (!controllable.getLocalRotation().equals(compareRotation))
		{
			compareRotation = new Quaternion().set(controllable.getLocalRotation());
			cacheRotation = controllable.getLocalRotation().inverse();
			localDirection = compareRotation.mult(point.direction);
			orientation.updateOrientation();
		}		
	

		Vector3f bottom = controllable.getLocalTranslation().subtract(compareRotation.mult(scale.mult(point.direction)).multLocal(0.5f*point.flip));
		
		from.subtractLocal(bottom);

		cacheUnit.set(getControlDistance());
		from.subtractLocal(cacheUnit);//Have to account for control distance...
		
		cacheUnit.set(ActionToolSettings.getInstance().getGridUnits().getValue());
		
		from.divideLocal(cacheUnit);
		from.x = Math.round(from.x);
		from.y = Math.round(from.y);
		from.z = Math.round(from.z);
		from.multLocal(cacheUnit);			
		
		cacheUnit.set(getControlDistance());

		from.addLocal(cacheUnit);//Have to account for control distance...

		from.addLocal(bottom);
		from = controllable.getParent().localToWorld(from,from);
		return from;
	}			
}
 
开发者ID:sambayless,项目名称:golems,代码行数:73,代码来源:CylinderControlPoint.java

示例12: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;
	if (controllable == null)
		return from;
	
	if (type == AxlePosition.RADIAL_LEFT || type == AxlePosition.RADIAL_RIGHT)
	{
	
		controllable.getParent().updateWorldData();
		controllable.updateWorldData();

		from = controllable.getParent().worldToLocal(from,from);

		cacheUnit.set(getControlDistance());
		from.subtractLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...
		
		cacheUnit.set(ActionToolSettings.getInstance().getGridUnits().getValue()).divideLocal(2f);

		from.divideLocal(cacheUnit);
		from.x = Math.round(from.x);
		from.y = Math.round(from.y);
		from.z = Math.round(from.z);
		from.multLocal(cacheUnit);			
		
		cacheUnit.set(getControlDistance());
		from.addLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...

		from = controllable.getParent().localToWorld(from,from);
		return from;
	}else
	{
		/*Vector3f axis = new Vector3f( type == CapsulePosition.LENGTH_RIGHT? Vector3f.UNIT_X:Vector3f.UNIT_X.mult(-1f));
		controllable.getParent().updateWorldData();
		controllable.updateWorldData();
		controllable.getParent().updateWorldData();
		from = controllable.getParent().worldToLocal(from,from);
			

	//	Vector3f bottom = controllable.getParent().getLocalTranslation().subtract(axis.mult(controllable.getInterpreter().getHeight())).multLocal(0.5f));
	//	controllable.getParent().getWorldRotation().multLocal(axis);
		from.subtractLocal(axis.divideLocal(2f));

	
		from.subtractLocal(getControlDistance());//Have to account for control distance...
				
		from.divideLocal(ActionToolSettings.getInstance().getGridUnits().getValue());
		//Vector3f orig = new Vector3f(from);
		from.x = Math.round(from.x);
		from.y = Math.round(from.y);
		from.z = Math.round(from.z);
	//	orig.subtractLocal(orig)
		from.multLocal(ActionToolSettings.getInstance().getGridUnits().getValue());			
		
	
		
		from.addLocal(getControlDistance());//Have to account for control distance...

		from.addLocal(axis);
		System.out.println(from);
		from = controllable.getParent().localToWorld(from,from);*/
		return from;
	}			
}
 
开发者ID:sambayless,项目名称:golems,代码行数:65,代码来源:AxleMVCControlPoint.java

示例13: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;
	if (controllable == null)
		return from;
	
	if (point == RADIUS)
	{
	
		controllable.getParent().updateWorldData();
		controllable.updateWorldData();

		from = controllable.getParent().worldToLocal(from,from);

		cacheUnit.set(getControlDistance());
		from.subtractLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...
		
		cacheUnit.set(ActionToolSettings.getInstance().getGridUnits().getValue()).divideLocal(2f);

		from.divideLocal(cacheUnit);
		from.x = Math.round(from.x);
		from.y = Math.round(from.y);
		from.z = Math.round(from.z);
		from.multLocal(cacheUnit);			
		
		cacheUnit.set(getControlDistance());
		from.addLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...

		from = controllable.getParent().localToWorld(from,from);
		return from;
	}else
	{
		
		controllable.getParent().updateWorldData();
		controllable.updateWorldData();

		from = controllable.getParent().worldToLocal(from,from);
		
		Vector3f scale = controllable.getLocalScale();
	

		Vector3f bottom = controllable.getLocalTranslation().subtract(controllable.getLocalRotation().mult(scale.mult(point.direction)).multLocal(0.5f*point.flip));
		
		from.subtractLocal(bottom);

		cacheUnit.set(getControlDistance());
		from.subtractLocal(cacheUnit);//Have to account for control distance...
		
		cacheUnit.set(ActionToolSettings.getInstance().getGridUnits().getValue());
		
		from.divideLocal(cacheUnit);
		from.x = Math.round(from.x);
		from.y = Math.round(from.y);
		from.z = Math.round(from.z);
		from.multLocal(cacheUnit);			
		
		cacheUnit.set(getControlDistance());

		from.addLocal(cacheUnit);//Have to account for control distance...

		from.addLocal(bottom);
		from = controllable.getParent().localToWorld(from,from);
		return from;
	}			
}
 
开发者ID:sambayless,项目名称:golems,代码行数:66,代码来源:TubeControlPoint.java

示例14: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;
	if (controllable == null)
		return from;

	from = controllable.getRelativeFromWorld(from, from); 

	
	Vector3f scale = controllable.getLocalScale();
	
	Vector3f bottom = controllable.getLocalTranslation().subtract(scale.mult(point.direction).multLocal(0.5f*point.flip));
	from.subtractLocal(bottom);

//	Quaternion rotation = 	controllable.getWorldRotation();
//	Vector3f origin = controllable.getWorldTranslation() ;
	//from.subtractLocal(origin);	
	
	cacheUnit.set(getControlDistance());
	//rotation.multLocal(cacheUnit);
	from.subtractLocal(cacheUnit);//Have to account for control distance...
	
	cacheUnit.set(ActionToolSettings.getInstance().getGridUnits().getValue());
	
	//rotation.multLocal(cacheUnit);
	
	from.divideLocal(cacheUnit);
	from.x = Math.round(from.x);
	from.y = Math.round(from.y);
	from.z = Math.round(from.z);
	from.multLocal(cacheUnit);			
	
	cacheUnit.set(getControlDistance());
	//rotation.multLocal(cacheUnit);
	from.addLocal(cacheUnit);//Have to account for control distance...
	
	//from.addLocal(origin);
	
	from.addLocal(bottom);
	from = controllable.getWorldFromRelative(from, from);
	return from;
	
}
 
开发者ID:sambayless,项目名称:golems,代码行数:44,代码来源:CubeControlPoint.java

示例15: getRestrictedPosition

import com.jme.math.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getRestrictedPosition(Vector3f from) {
	//Get the closest grid node to the provided position;
	if (controllable == null)
		return from;

	if(type == BallSocketPosition.BALL_RADIAL || type ==  BallSocketPosition.JOINT_RADIAL)
	{
		controllable.getParent().updateWorldData();
		controllable.updateWorldData();
	
		from = controllable.getParent().worldToLocal(from,from);
	
		cacheUnit.set(getControlDistance());
	
		from.subtractLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...
		
		cacheUnit.set(ActionToolSettings.getInstance().getGridUnits().getValue()).divideLocal(2f);
	
		from.divideLocal(cacheUnit);
		from.x = Math.round(from.x);
		from.y = Math.round(from.y);
		from.z = Math.round(from.z);
		from.multLocal(cacheUnit);			
		
		cacheUnit.set(getControlDistance());
	
		from.addLocal(cacheUnit.divideLocal(2f));//Have to account for control distance...
	
		from = controllable.getParent().localToWorld(from,from);
	return from;
	}else{
		return from;
		/*Vector3f pos = controllable.getRelativeFromWorld(from, new Vector3f());
	//	System.out.println(pos);
		//pos.subtractLocal(ActionToolSettings.getInstance().getGridOrigin().getValue());
		pos.divideLocal(ActionToolSettings.getInstance().getGridUnits().getValue());
		pos.x = Math.round(pos.x);
		pos.y = Math.round(pos.y);
		pos.z = Math.round(pos.z);
		pos.multLocal(ActionToolSettings.getInstance().getGridUnits().getValue());
		return controllable.getWorldFromRelative(pos, from);*/
	}
}
 
开发者ID:sambayless,项目名称:golems,代码行数:45,代码来源:BallSocketControlPoint.java


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