本文整理汇总了Java中javax.vecmath.Vector3f类的典型用法代码示例。如果您正苦于以下问题:Java Vector3f类的具体用法?Java Vector3f怎么用?Java Vector3f使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector3f类属于javax.vecmath包,在下文中一共展示了Vector3f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bake
import javax.vecmath.Vector3f; //导入依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state);
TRSRTransformation transform = state.apply(Optional.empty()).orElse(TRSRTransformation.identity());
TextureAtlasSprite widgetSprite = bakedTextureGetter.apply(getWidgetTexture(widget));
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
int width = widget.getWidth() + (widget.getParameters() != null && widget.getParameters().length > 0 ? 10 : 0);
int height = widget.getHeight() + (widget.hasStepOutput() ? 5 : 0);
Pair<Double, Double> maxUV = widget.getMaxUV();
int textureSize = widget.getTextureSize();
float scale = 1F / (float) Math.max(maxUV.getLeft(), maxUV.getRight());
float transX = 0;//maxUV.getLeft().floatValue();
float transY = -1 + maxUV.getRight().floatValue();
transform = transform.compose(new TRSRTransformation(new Vector3f(0, 0, 0), null, new Vector3f(scale, scale, 1), null));
transform = transform.compose(new TRSRTransformation(new Vector3f(transX, transY, 0), null, new Vector3f(1, 1, 1), null));
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16 * maxUV.getLeft().floatValue(), 16 * maxUV.getRight().floatValue(), NORTH_Z_BASE, widgetSprite, EnumFacing.NORTH, 0xffffffff));
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16 * maxUV.getLeft().floatValue(), 16 * maxUV.getRight().floatValue(), SOUTH_Z_BASE, widgetSprite, EnumFacing.SOUTH, 0xffffffff));
return new BakedProgrammingPuzzle(this, builder.build(), widgetSprite, format, Maps.immutableEnumMap(transformMap), Maps.newHashMap());
}
示例2: EntityCrazyCube
import javax.vecmath.Vector3f; //导入依赖的package包/类
public EntityCrazyCube(World world, Vec3f pos){
super(world, getModel0(), pos);
float s=Rand.f()+1;
scale.set(s, s, s);
// model.getMaterial(2).getDiffuse().set(177/256F, 0, 177/256F, 1);
// model.getMaterial(1).getDiffuse().set(0x00C7E7);
// model.getMaterial(1).getAmbient().set(0x00C7E7).a(1);
// model.getMaterial(0).getDiffuse().set(0x0000FF);
float massKg=0.5F*scale.x*scale.y*scale.z;
if(CAM==null) CAM=this;
getPhysicsObj().init(massKg, new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(pos.x, pos.y, pos.z), 0.5F)), new SphereShape(scale.x/2), Vec3f.single(0.9F));
// getPhysicsObj().init(massKg, new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(pos.x, pos.y, pos.z), 0.5F)), new BoxShape(new Vector3f(scale.x/2, scale.y/2, scale.z/2)), Vec3f.single(0.9F));
getPhysicsObj().body.setDamping(0.15F, 0.15F);
getPhysicsObj().hookPos(this.pos);
getPhysicsObj().hookRot(rot);
}
示例3: movePosition
import javax.vecmath.Vector3f; //导入依赖的package包/类
/**
* Move the position of the player by the specified deltaX,
* deltaY and deltaZ using the specified camera rotation.
*
* @param deltaX - Value to move the x position by.
* @param deltaY - Value to move the y position by.
* @param deltaZ - Value to move the z position by.
* @param camY - Camera y rotation to use for movement.
*/
public void movePosition(float deltaX, float deltaY, float deltaZ, float camY) {
deltaX *= WALK_SPEED;
deltaY *= WALK_SPEED;
deltaZ *= WALK_SPEED;
Vector3f position = new Vector3f(0, 0, 0);
if (deltaZ != 0) {
position.x += (float)Math.sin(Math.toRadians(camY)) * -1.0f * deltaZ;
position.z += (float)Math.cos(Math.toRadians(camY)) * deltaZ;
}
if (deltaX != 0) {
position.x += (float)Math.sin(Math.toRadians(camY - 90)) * -1.0f * deltaX;
position.z += (float)Math.cos(Math.toRadians(camY - 90)) * deltaX;
}
position.y += deltaY;
characterController.setWalkDirection(position);
}
示例4: getCalibrationMatrix
import javax.vecmath.Vector3f; //导入依赖的package包/类
/**
* Get a matrix usable for zero calibration (only position and compass direction)
*/
public float[] getCalibrationMatrix() {
float[] t = new float[3];
float[] m = new float[16];
mFrame.getPose().getTranslation(t, 0);
float[] z = mFrame.getPose().getZAxis();
Vector3f zAxis = new Vector3f(z[0], z[1], z[2]);
zAxis.y = 0;
zAxis.normalize();
double rotate = Math.atan2(zAxis.x, zAxis.z);
Matrix.setIdentityM(m, 0);
Matrix.translateM(m, 0, t[0], t[1], t[2]);
Matrix.rotateM(m, 0, (float) Math.toDegrees(rotate), 0, 1, 0);
return m;
}
示例5: setMemory
import javax.vecmath.Vector3f; //导入依赖的package包/类
/**
*
* setMemory is a helper method used to add the stroke data to the float[] buffers
* @param index
* @param pos
* @param prev
* @param next
* @param counter
* @param width
* @param side
*/
private void setMemory(int index, Vector3f pos, Vector3f prev, Vector3f next, float counter, float width, float side){
mPositions[index*3] = pos.x;
mPositions[index*3+1] = pos.y;
mPositions[index*3+2] = pos.z;
mNext[index*3] = next.x;
mNext[index*3+1] = next.y;
mNext[index*3+2] = next.z;
mPrevious[index*3] = prev.x;
mPrevious[index*3+1] = prev.y;
mPrevious[index*3+2] = prev.z;
mCounters[index] = counter;
mSide[index] = side;
mWidth[index] = width;
}
示例6: fillNormal
import javax.vecmath.Vector3f; //导入依赖的package包/类
/**
* internal, relies on fixed format of FaceBakery
*/
public static void fillNormal(int[] faceData, EnumFacing facing)
{
Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
v1.sub(t);
t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
v2.sub(t);
v1.cross(v2, v1);
v1.normalize();
int x = ((byte)(v1.x * 127)) & 0xFF;
int y = ((byte)(v1.y * 127)) & 0xFF;
int z = ((byte)(v1.z * 127)) & 0xFF;
for(int i = 0; i < 4; i++)
{
faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
}
}
示例7: mul
import javax.vecmath.Vector3f; //导入依赖的package包/类
public static Matrix4f mul(Vector3f translation, Quat4f leftRot, Vector3f scale, Quat4f rightRot)
{
Matrix4f res = new Matrix4f(), t = new Matrix4f();
res.setIdentity();
if(leftRot != null)
{
t.set(leftRot);
res.mul(t);
}
if(scale != null)
{
t.setIdentity();
t.m00 = scale.x;
t.m11 = scale.y;
t.m22 = scale.z;
res.mul(t);
}
if(rightRot != null)
{
t.set(rightRot);
res.mul(t);
}
if(translation != null) res.setTranslation(translation);
return res;
}
示例8: addKFElement
import javax.vecmath.Vector3f; //导入依赖的package包/类
/**
* Add an element to a keyframe. If the keyframe does exist it's created.
*
* @param keyFrame
* Key of the keyframe.
* @param type
* Type of the element. See {@link CSReadedAnimBlock}.
* @param value
* Value of the element.
*/
public void addKFElement(int keyFrame, EnumFrameType type, Vector3f value) {
if (!this.keyFrames.containsKey(keyFrame))
this.keyFrames.put(keyFrame, new ReadedKeyFrame());
switch (type) {
case POSITION:
this.keyFrames.get(keyFrame).position = value;
break;
case ROTATION:
this.keyFrames.get(keyFrame).rotation = value;
break;
case OFFSET:
this.keyFrames.get(keyFrame).offset = value;
break;
case SIZE:
this.keyFrames.get(keyFrame).size = value;
break;
case STRETCH:
this.keyFrames.get(keyFrame).stretching = value;
break;
}
}
示例9: getHelixData
import javax.vecmath.Vector3f; //导入依赖的package包/类
/**
*
* @param tokType
* @param qType
* @param mStep
* @return helix data of some sort
*/
public Object getHelixData(int tokType, char qType, int mStep) {
switch (tokType) {
case Token.point:
return new Point3f();
case Token.axis:
case Token.radius:
return new Vector3f();
case Token.angle:
return new Float(Float.NaN);
case Token.array:
case Token.list:
return new String[] {};
}
return "";
}
示例10: nearestDistance
import javax.vecmath.Vector3f; //导入依赖的package包/类
@Override
public double nearestDistance(Vector3f p, Vector3f pNormal, boolean useRelative) {
Vector3f found = nearestNeighbour(p);
if(found == null){
//error
return Double.MAX_VALUE;
}
float sign = 1f;
if(useRelative){
sign = getSign(p, found, pNormal);
}
return sign * MathUtils.instance().distancePoints(found, p);
}
示例11: calchull
import javax.vecmath.Vector3f; //导入依赖的package包/类
private int calchull(ObjectArrayList<Vector3f> verts, int verts_count, IntArrayList tris_out, int[] tris_count, int vlimit) {
int rc = calchullgen(verts, verts_count, vlimit);
if (rc == 0) return 0;
IntArrayList ts = new IntArrayList();
for (int i=0; i<tris.size(); i++) {
if (tris.getQuick(i) != null) {
for (int j = 0; j < 3; j++) {
ts.add((tris.getQuick(i)).getCoord(j));
}
deAllocateTriangle(tris.getQuick(i));
}
}
tris_count[0] = ts.size() / 3;
MiscUtil.resize(tris_out, ts.size(), 0);
for (int i=0; i<ts.size(); i++) {
tris_out.set(i, ts.get(i));
}
MiscUtil.resize(tris, 0, Tri.class);
return 1;
}
示例12: isVariableType
import javax.vecmath.Vector3f; //导入依赖的package包/类
static public boolean isVariableType(Object x) {
return (x instanceof ScriptVariable
|| x instanceof BitSet
|| x instanceof Boolean
|| x instanceof Float
|| x instanceof Integer
|| x instanceof Point3f // stored as point3f
|| x instanceof Vector3f // stored as point3f
|| x instanceof Point4f // stored as point4f
|| x instanceof Quaternion // stored as point4f
|| x instanceof String
|| x instanceof Map<?, ?> // stored as Map<String, ScriptVariable>
|| x instanceof List<?> // stored as list
|| x instanceof ScriptVariable[] // stored as list
|| x instanceof double[] // stored as list
|| x instanceof float[] // stored as list
|| x instanceof Float[] // stored as list
|| x instanceof int[] // stored as list
|| x instanceof int[][] // stored as list
|| x instanceof Point4f[] // stored as list
|| x instanceof String[]); // stored as list
}
示例13: update
import javax.vecmath.Vector3f; //导入依赖的package包/类
@Override
public void update() {
accum += Engine.deltaTime;
//spawns cubes and lights, test if accum is a certain length
if (Input.isButtonDown(1) && accum > 0.1f) {
Camera cam = Engine.camera;
MeshObject c = new MeshObject(cam.getPosition(), cam.front.multiply(30), new Quat4f(1.0f, 0.3f, 0.5f, 0f), new BoxShape(new Vector3f(0.5f, 0.5f, 0.5f)), 1f, cubeMesh, 1f, crateMaterial);
Engine.scene.add(c);
accum = 0;
}
if (Input.isButtonDown(2) && accum > 1f) {
PointLight p = new PointLight(Engine.camera.getPosition(), vec3(1.0f, 1.0f, 2.0f), 5f, 10f);
Engine.scene.add(p);
accum = 0;
}
}
示例14: drawCylinder
import javax.vecmath.Vector3f; //导入依赖的package包/类
private void drawCylinder(Vector3f from, Vector3f to, GL2 gl, GLUT glut) {
Vector3f zAxis = new Vector3f(0, 0, 1);
Vector3f vector = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
float length = vector.length();
vector.normalize();
float angle = zAxis.angle(vector);
Vector3f axis = new Vector3f();
axis.cross(zAxis, vector);
float convert = (float) (180f / Math.PI);
gl.glPushMatrix();
gl.glTranslatef(from.x, from.y, from.z);
gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
glut.glutSolidCylinder(info.getPointSize() / 4.5, length - info.getPointSize(), 20, 20);
gl.glPopMatrix();
}
示例15: BvhTriangleMeshShape
import javax.vecmath.Vector3f; //导入依赖的package包/类
/**
* Optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb.
*/
public BvhTriangleMeshShape(StridingMeshInterface meshInterface, boolean useQuantizedAabbCompression, Vector3f bvhAabbMin, Vector3f bvhAabbMax, boolean buildBvh) {
super(meshInterface);
this.bvh = null;
this.useQuantizedAabbCompression = useQuantizedAabbCompression;
this.ownsBvh = false;
// construct bvh from meshInterface
//#ifndef DISABLE_BVH
if (buildBvh) {
bvh = new OptimizedBvh();
bvh.build(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax);
ownsBvh = true;
}
// JAVA NOTE: moved from TriangleMeshShape
recalcLocalAabb();
//#endif //DISABLE_BVH
}