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


Java Vector4f类代码示例

本文整理汇总了Java中javax.vecmath.Vector4f的典型用法代码示例。如果您正苦于以下问题:Java Vector4f类的具体用法?Java Vector4f怎么用?Java Vector4f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getPlaneEquation

import javax.vecmath.Vector4f; //导入依赖的package包/类
public void getPlaneEquation(Vector4f plane, int i) {
	Vector3f halfExtents = getHalfExtentsWithoutMargin(Stack.alloc(Vector3f.class));

	switch (i) {
		case 0:
			plane.set(1f, 0f, 0f, -halfExtents.x);
			break;
		case 1:
			plane.set(-1f, 0f, 0f, -halfExtents.x);
			break;
		case 2:
			plane.set(0f, 1f, 0f, -halfExtents.y);
			break;
		case 3:
			plane.set(0f, -1f, 0f, -halfExtents.y);
			break;
		case 4:
			plane.set(0f, 0f, 1f, -halfExtents.z);
			break;
		case 5:
			plane.set(0f, 0f, -1f, -halfExtents.z);
			break;
		default:
			assert (false);
	}
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:27,代码来源:BoxShape.java

示例2: get_plane_equation_transformed

import javax.vecmath.Vector4f; //导入依赖的package包/类
public static void get_plane_equation_transformed(StaticPlaneShape shape, Transform trans, Vector4f equation) {
	get_plane_equation(shape, equation);

	Vector3f tmp = Stack.alloc(Vector3f.class);

	trans.basis.getRow(0, tmp);
	float x = VectorUtil.dot3(tmp, equation);
	trans.basis.getRow(1, tmp);
	float y = VectorUtil.dot3(tmp, equation);
	trans.basis.getRow(2, tmp);
	float z = VectorUtil.dot3(tmp, equation);

	float w = VectorUtil.dot3(trans.origin, equation) + equation.w;

	equation.set(x, y, z, w);
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:17,代码来源:PlaneShape.java

示例3: rescaleQuad

import javax.vecmath.Vector4f; //导入依赖的package包/类
private static BakedQuad rescaleQuad(BakedQuad quad, Matrix4f transform, int tintDelta) {
	final int delta = quad.getFormat().getIntegerSize();
	final int[] inputVertexData = quad.getVertexData();
	final int[] outputVertexData = Arrays.copyOf(inputVertexData, inputVertexData.length);
	int elementOffset = 0;
	for (int i = 0; i < 4; i++) {
		float x = Float.intBitsToFloat(inputVertexData[elementOffset + 0]);
		float y = Float.intBitsToFloat(inputVertexData[elementOffset + 1]);
		float z = Float.intBitsToFloat(inputVertexData[elementOffset + 2]);

		final Vector4f v = new Vector4f(x, y, z, 1);
		transform.transform(v);

		outputVertexData[elementOffset + 0] = Float.floatToIntBits(v.x);
		outputVertexData[elementOffset + 1] = Float.floatToIntBits(v.y);
		outputVertexData[elementOffset + 2] = Float.floatToIntBits(v.z);

		elementOffset += delta;
	}

	final int tintIndex = quad.hasTintIndex()? quad.getTintIndex() + tintDelta : -1;
	return new BakedQuad(outputVertexData, tintIndex, quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat());
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:24,代码来源:DevNullItemOverride.java

示例4: brus

import javax.vecmath.Vector4f; //导入依赖的package包/类
private List<Brush> brus() throws IOException
{
    chunk("BRUS");
    List<Brush> ret = new ArrayList<Brush>();
    int n_texs = buf.getInt();
    while(buf.hasRemaining())
    {
        String name = readString();
        Vector4f color = new Vector4f(buf.getFloat(), buf.getFloat(), buf.getFloat(), buf.getFloat());
        float shininess = buf.getFloat();
        int blend = buf.getInt();
        int fx = buf.getInt();
        List<Texture> textures = new ArrayList<Texture>();
        for(int i = 0; i < n_texs; i++) textures.add(getTexture(buf.getInt()));
        ret.add(new Brush(name, color, shininess, blend, fx, textures));
    }
    dump("BRUS([" + Joiner.on(", ").join(ret) + "])");
    popLimit();
    this.brushes.addAll(ret);
    return ret;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:B3DModel.java

示例5: maxAxis4

import javax.vecmath.Vector4f; //导入依赖的package包/类
public static int maxAxis4(Vector4f v) {
	int maxIndex = -1;
	float maxVal = -1e30f;
	if (v.x > maxVal) {
		maxIndex = 0;
		maxVal = v.x;
	}
	if (v.y > maxVal) {
		maxIndex = 1;
		maxVal = v.y;
	}
	if (v.z > maxVal) {
		maxIndex = 2;
		maxVal = v.z;
	}
	if (v.w > maxVal) {
		maxIndex = 3;
		maxVal = v.w;
	}

	return maxIndex;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:23,代码来源:VectorUtil.java

示例6: buildTriPlane

import javax.vecmath.Vector4f; //导入依赖的package包/类
public void buildTriPlane(Vector4f plane) {
	Vector3f tmp1 = Stack.alloc(Vector3f.class);
	Vector3f tmp2 = Stack.alloc(Vector3f.class);

	Vector3f normal = Stack.alloc(Vector3f.class);
	tmp1.sub(vertices1[1], vertices1[0]);
	tmp2.sub(vertices1[2], vertices1[0]);
	normal.cross(tmp1, tmp2);
	normal.normalize();

	plane.set(normal.x, normal.y, normal.z, vertices1[0].dot(normal));
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:13,代码来源:TriangleShapeEx.java

示例7: plane_classify

import javax.vecmath.Vector4f; //导入依赖的package包/类
public PlaneIntersectionType plane_classify(Vector4f plane) {
	Vector3f tmp = Stack.alloc(Vector3f.class);

	float[] _fmin = new float[1], _fmax = new float[1];
	tmp.set(plane.x, plane.y, plane.z);
	projection_interval(tmp, _fmin, _fmax);

	if (plane.w > _fmax[0] + BOX_PLANE_EPSILON) {
		return PlaneIntersectionType.BACK_PLANE; // 0
	}

	if (plane.w + BOX_PLANE_EPSILON >= _fmin[0]) {
		return PlaneIntersectionType.COLLIDE_PLANE; //1
	}
	
	return PlaneIntersectionType.FRONT_PLANE; //2
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:18,代码来源:BoxCollision.java

示例8: edge_plane

import javax.vecmath.Vector4f; //导入依赖的package包/类
/**
 * Calc a plane from a triangle edge an a normal.
 */
public static void edge_plane(Vector3f e1, Vector3f e2, Vector3f normal, Vector4f plane) {
	Vector3f planenormal = Stack.alloc(Vector3f.class);
	planenormal.sub(e2, e1);
	planenormal.cross(planenormal, normal);
	planenormal.normalize();

	plane.set(planenormal);
	plane.w = e2.dot(planenormal);
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:13,代码来源:GeometryOperations.java

示例9: line_plane_collision

import javax.vecmath.Vector4f; //导入依赖的package包/类
/**
 * Line plane collision.
 * 
 * @return -0 if the ray never intersects, -1 if the ray collides in front, -2 if the ray collides in back
 */
public static int line_plane_collision(Vector4f plane, Vector3f vDir, Vector3f vPoint, Vector3f pout, float[] tparam, float tmin, float tmax) {
	float _dotdir = VectorUtil.dot3(vDir, plane);

	if (Math.abs(_dotdir) < PLANEDIREPSILON) {
		tparam[0] = tmax;
		return 0;
	}

	float _dis = ClipPolygon.distance_point_plane(plane, vPoint);
	int returnvalue = _dis < 0.0f ? 2 : 1;
	tparam[0] = -_dis / _dotdir;

	if (tparam[0] < tmin) {
		returnvalue = 0;
		tparam[0] = tmin;
	}
	else if (tparam[0] > tmax) {
		returnvalue = 0;
		tparam[0] = tmax;
	}
	pout.scaleAdd(tparam[0], vDir, vPoint);
	return returnvalue;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:29,代码来源:GeometryOperations.java

示例10: getTextureCoordinates

import javax.vecmath.Vector4f; //导入依赖的package包/类
/**
 * Returns a texture coordinates generator that wraps the given texture on front face.
 */
private TexCoordGeneration getTextureCoordinates(Appearance appearance, HomeTexture texture, Vector3f pieceSize,
		BoundingBox modelBounds)
{
	Point3d lower = new Point3d();
	modelBounds.getLower(lower);
	Point3d upper = new Point3d();
	modelBounds.getUpper(upper);
	float minimumSize = ModelManager.getInstance().getMinimumSize();
	float textureWidth = TextureManager.getInstance().getRotatedTextureWidth(texture);
	float textureHeight = TextureManager.getInstance().getRotatedTextureHeight(texture);
	float sx = pieceSize.x / (float) Math.max(upper.x - lower.x, minimumSize) / textureWidth;
	float sw = texture.isLeftToRightOriented() ? (float) -lower.x * sx : 0;
	float ty = pieceSize.y / (float) Math.max(upper.y - lower.y, minimumSize) / textureHeight;
	float tz = pieceSize.z / (float) Math.max(upper.z - lower.z, minimumSize) / textureHeight;
	float tw = texture.isLeftToRightOriented() ? (float) (-lower.y * ty + upper.z * tz) : 0;
	return new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, TexCoordGeneration.TEXTURE_COORDINATE_2,
			new Vector4f(sx, 0, 0, sw), new Vector4f(0, ty, -tz, tw));
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:22,代码来源:HomePieceOfFurniture3D.java

示例11: mapWorldToScreen

import javax.vecmath.Vector4f; //导入依赖的package包/类
/**
   * Given a point in world coordinates, adjust it in place to be in
   * screen coordinates (after projection).
   * 
   * @param point
   */
  public void mapWorldToScreen( Camera view, Point3f point )
  {
      Matrix4d viewMatrix = new Matrix4d();
      this .view .getViewTransform( viewMatrix, 0d );
      Transform3D viewTrans = new Transform3D( viewMatrix );
      viewTrans .transform( point );
      // point is now in view coordinates
      Vector4f p4 = new Vector4f( point.x, point.y, point.z, 1f );

      Transform3D eyeTrans = new Transform3D();
      if ( ! view .isPerspective() ) {
	double edge = view .getWidth() / 2;
	eyeTrans .ortho( -edge, edge, -edge, edge, view .getNearClipDistance(), view .getFarClipDistance() );
}
else
    eyeTrans .perspective( view .getFieldOfView(), 1.0d, view .getNearClipDistance(), view .getFarClipDistance() );
	// TODO - make aspect ratio track the screen window shape
      
      eyeTrans .transform( p4 );
      point .project( new Point4f( p4 ) );
  }
 
开发者ID:vZome,项目名称:vzome-desktop,代码行数:28,代码来源:Java2dExporter.java

示例12: transform

import javax.vecmath.Vector4f; //导入依赖的package包/类
public Vertex transform(Matrix4f matrix, boolean rescaleToUnitCube)
{

    Vector4f tmp = new Vector4f((float) x, (float) y, (float) z, 1f);

    matrix.transform(tmp);
    if (rescaleToUnitCube && Math.abs(tmp.w - 1f) > 1e-5)
    {
        tmp.scale(1f / tmp.w);
    }

    if(this.hasNormal())
    {
        Vector4f tmpNormal = new Vector4f((float)this.normal.x, (float)this.normal.y, (float)this.normal.z, 1f);
        matrix.transform(tmp);
        Vec3d newNormal = new Vec3d(tmpNormal.x, tmpNormal.y, tmpNormal.z);
        newNormal.normalize();
        return new Vertex(tmp.x, tmp.y, tmp.z, u, v, color, newNormal);
    }
    else
    {
        return new Vertex(tmp.x, tmp.y, tmp.z, u, v, color);
    }

}
 
开发者ID:grondag,项目名称:Hard-Science,代码行数:26,代码来源:Vertex.java

示例13: DebugFrustumCullStage

import javax.vecmath.Vector4f; //导入依赖的package包/类
/**
 * Create a basic instance of this class with the list initial internal
 * setup for the given number of renderable surfaces. The size is just an
 * initial esstimate, and is used for optimisation purposes to prevent
 * frequent array reallocations internally. As such, the number does not
 * have to be perfect, just good enough.
 *
 * @param numSurfaces Total number of surfaces to prepare rendering for
 * @param useGlobalView The rendered viewpoint is set to look down on the
 *    entire scene if set true, otherwise uses the normal value
 */
public DebugFrustumCullStage(int numSurfaces, boolean useGlobalView)
{
    super(numSurfaces);

    viewMatrix = new Matrix4f();
    prjMatrix = new Matrix4f();
    frustumPoints = new Point4f[8];
    for(int i=0; i < 8; i++)
        frustumPoints[i] = new Point4f();

    frustumPlanes = new Vector4f[6];
    for(int i=0; i < 6; i++)
        frustumPlanes[i] = new Vector4f();

    t1 = new float[3];
    t2 = new float[3];
    c1 = new float[3];
    c2 = new float[3];
    globalViewpoint = useGlobalView;
}
 
开发者ID:Norkart,项目名称:NK-VirtualGlobe,代码行数:32,代码来源:DebugFrustumCullStage.java

示例14: duplicateAttributes

import javax.vecmath.Vector4f; //导入依赖的package包/类
/**
    * Copies all node information from <code>originalNodeComponent</code> into
    * the current node.  This method is called from the
    * <code>duplicateNode</code> method. This routine does
    * the actual duplication of all "local data" (any data defined in
    * this object). 
    *
    * @param originalNodeComponent the original node to duplicate.
    * @param forceDuplicate when set to <code>true</code>, causes the
    *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
    *  <code>false</code>, the value of each node's
    *  <code>duplicateOnCloneTree</code> variable determines whether
    *  NodeComponent data is duplicated or copied.
    *
    * @see Node#cloneTree
    * @see NodeComponent#setDuplicateOnCloneTree
    */

   void duplicateAttributes(NodeComponent originalNodeComponent, 
		     boolean forceDuplicate) { 

super.duplicateAttributes(originalNodeComponent, forceDuplicate);
     
TexCoordGenerationRetained tex = (TexCoordGenerationRetained) 
    originalNodeComponent.retained;
TexCoordGenerationRetained rt = (TexCoordGenerationRetained) retained;

Vector4f v = new Vector4f();

rt.initGenMode(tex.getGenMode());
tex.getPlaneS(v);
rt.initPlaneS(v);
tex.getPlaneT(v);
rt.initPlaneT(v);
tex.getPlaneR(v);
rt.initPlaneR(v);      
tex.getPlaneQ(v);
rt.initPlaneQ(v);      
rt.initFormat(tex.getFormat());
rt.initEnable(tex.getEnable());
   }
 
开发者ID:philipwhiuk,项目名称:j3d-core,代码行数:42,代码来源:TexCoordGeneration.java

示例15: onCreateInventoryHook

import javax.vecmath.Vector4f; //导入依赖的package包/类
@Override
public void onCreateInventoryHook(UIWindow parent) {

    inventoryParent = parent;
    GridLayout layout = new GridLayout(10);
    //layout.setPadding(new Vector4f(0f, 2f, 2f, 2f));

    inventoryContainer = new UICompositeScrollable();
    inventoryContainer.setHorizontalAlign(UIDisplayElement.EHorizontalAlign.CENTER);
    inventoryContainer.setVerticalAlign(UIDisplayElement.EVerticalAlign.CENTER);
    inventoryContainer.setSize(new Vector2f(495, 288));
    inventoryContainer.setBorderImage("engine:inventory", new Vector2f(0f, 84f), new Vector2f(169f, 61f), new Vector4f(5f, 4f, 3f, 4f));
    inventoryContainer.setEnableScrolling(true);
    inventoryContainer.setEnableScrollbar(true);
    inventoryContainer.setLayout(layout);
    inventoryContainer.setPadding(new Vector4f(0f, 15f, 0f, 0f));
    inventoryContainer.setVisible(true);

    fillInventoryCells();

    inventoryParent.addDisplayElement(inventoryContainer);

}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:24,代码来源:FreeStyleType.java


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