Java 类javax.vecmath.Matrix4f 实例源码

项目:OpenGL-Bullet-engine    文件:EntityCrazyCube.java   
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);
    }
项目:Infernum    文件:ModelSpellPage.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
    if (baseSpellPageModel instanceof IPerspectiveAwareModel) {
        Matrix4f matrix4f = ((IPerspectiveAwareModel) baseSpellPageModel).handlePerspective(cameraTransformType)
                .getRight();
        return Pair.of(this, matrix4f);
    }
    ItemCameraTransforms itemCameraTransforms = baseSpellPageModel.getItemCameraTransforms();
    ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType);
    TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f);
    Matrix4f mat = null;
    if (tr != null) {
        mat = tr.getMatrix();
    }
    return Pair.of(this, mat);
}
项目:Infernum    文件:ModelKnowledgeBook.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
    if (baseKnowledgeBookModel instanceof IPerspectiveAwareModel) {
        Matrix4f matrix4f = ((IPerspectiveAwareModel) baseKnowledgeBookModel).handlePerspective(cameraTransformType)
                .getRight();
        return Pair.of(this, matrix4f);
    }
    ItemCameraTransforms itemCameraTransforms = baseKnowledgeBookModel.getItemCameraTransforms();
    ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType);
    TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f);
    Matrix4f mat = null;
    if (tr != null) {
        mat = tr.getMatrix();
    }
    return Pair.of(this, mat);
}
项目:Infernum    文件:BakedModelKnowledgeBook.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
    if (parentModel instanceof IPerspectiveAwareModel) {
        Matrix4f matrix4f = ((IPerspectiveAwareModel) parentModel).handlePerspective(cameraTransformType)
                .getRight();
        return Pair.of(this, matrix4f);
    }
    ItemCameraTransforms itemCameraTransforms = parentModel.getItemCameraTransforms();
    ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType);
    TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f);
    Matrix4f mat = null;
    if (tr != null) {
        mat = tr.getMatrix();
    }
    return Pair.of(this, mat);
}
项目:Infernum    文件:BakedModelSpellPage.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
    if (parentModel instanceof IPerspectiveAwareModel) {
        Matrix4f matrix4f = ((IPerspectiveAwareModel) parentModel).handlePerspective(cameraTransformType)
                .getRight();
        return Pair.of(this, matrix4f);
    }
    ItemCameraTransforms itemCameraTransforms = parentModel.getItemCameraTransforms();
    ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType);
    TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f);
    Matrix4f mat = null;
    if (tr != null) {
        mat = tr.getMatrix();
    }
    return Pair.of(this, mat);
}
项目:CustomWorldGen    文件:ForgeHooksClient.java   
@SuppressWarnings("deprecation")
public static Matrix4f getMatrix(net.minecraft.client.renderer.block.model.ItemTransformVec3f transform)
{
    javax.vecmath.Matrix4f m = new javax.vecmath.Matrix4f(), t = new javax.vecmath.Matrix4f();
    m.setIdentity();
    m.setTranslation(TRSRTransformation.toVecmath(transform.translation));
    t.setIdentity();
    t.rotY(transform.rotation.y);
    m.mul(t);
    t.setIdentity();
    t.rotX(transform.rotation.x);
    m.mul(t);
    t.setIdentity();
    t.rotZ(transform.rotation.z);
    m.mul(t);
    t.setIdentity();
    t.m00 = transform.scale.x;
    t.m11 = transform.scale.y;
    t.m22 = transform.scale.z;
    m.mul(t);
    return m;
}
项目:CustomWorldGen    文件:ForgeBlockStateV1.java   
public static Matrix4f parseMatrix(JsonElement e)
{
    if (!e.isJsonArray()) throw new JsonParseException("Matrix: expected an array, got: " + e);
    JsonArray m = e.getAsJsonArray();
    if (m.size() != 3) throw new JsonParseException("Matrix: expected an array of length 3, got: " + m.size());
    Matrix4f ret = new Matrix4f();
    for (int i = 0; i < 3; i++)
    {
        if (!m.get(i).isJsonArray()) throw new JsonParseException("Matrix row: expected an array, got: " + m.get(i));
        JsonArray r = m.get(i).getAsJsonArray();
        if (r.size() != 4) throw new JsonParseException("Matrix row: expected an array of length 4, got: " + r.size());
        for (int j = 0; j < 4; j++)
        {
            try
            {
                ret.setElement(i, j, r.get(j).getAsNumber().floatValue());
            }
            catch (ClassCastException ex)
            {
                throw new JsonParseException("Matrix element: expected number, got: " + r.get(j));
            }
        }
    }
    return ret;
}
项目:CustomWorldGen    文件:TRSRTransformation.java   
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;
}
项目:CustomWorldGen    文件:TRSRTransformation.java   
public static boolean isInteger(Matrix4f matrix)
{
    Matrix4f m = new Matrix4f();
    m.setIdentity();
    m.m30 = m.m31 = m.m32 = 1;
    m.m33 = 0;
    m.mul(matrix, m);
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            float v = m.getElement(i, j) / m.getElement(3, j);
            if(Math.abs(v - Math.round(v)) > 1e-5) return false;
        }
    }
    return true;
}
项目:CustomWorldGen    文件:TRSRTransformation.java   
@SideOnly(Side.CLIENT)
public static org.lwjgl.util.vector.Matrix4f toLwjgl(Matrix4f m)
{
    org.lwjgl.util.vector.Matrix4f r = new org.lwjgl.util.vector.Matrix4f();
    r.m00 = m.m00;
    r.m01 = m.m10;
    r.m02 = m.m20;
    r.m03 = m.m30;
    r.m10 = m.m01;
    r.m11 = m.m11;
    r.m12 = m.m21;
    r.m13 = m.m31;
    r.m20 = m.m02;
    r.m21 = m.m12;
    r.m22 = m.m22;
    r.m23 = m.m32;
    r.m30 = m.m03;
    r.m31 = m.m13;
    r.m32 = m.m23;
    r.m33 = m.m33;
    return r;
}
项目:CrystalMod    文件:Fixed3DBlockModel.java   
/** Get the default transformations for inside inventories and third person */
    protected static ImmutableMap<TransformType, TRSRTransformation> getBlockTransforms() {
        ImmutableMap.Builder<TransformType, TRSRTransformation> builder = ImmutableMap.builder();

        // Copied from ForgeBlockStateV1
        /*builder.put(TransformType.THIRD_PERSON, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(new Vector3f(0, 1.5f / 16, -2.75f / 16),
                TRSRTransformation.quatFromYXZDegrees(new Vector3f(10, -45, 170)), new Vector3f(0.375f, 0.375f, 0.375f), null)));
*/
        // Gui
        {
            Matrix4f rotationMatrix = new Matrix4f();
            rotationMatrix.setIdentity();
            rotationMatrix = rotateTowardsFace(EnumFacing.SOUTH, EnumFacing.EAST);

            Matrix4f result = new Matrix4f();
            result.setIdentity();
            // Multiply by the last matrix transformation FIRST
            result.mul(rotationMatrix);

            TRSRTransformation trsr = new TRSRTransformation(result);

            builder.put(TransformType.GUI, trsr);
        }

        return builder.build();
    }
项目:JACWfA    文件:Domino.java   
public boolean makeDomino(float mass, Vector3f inertia, Vector3f loc,
        float angle) {
    if (cntCreated >= numDominoes)
        return false;
    int i = cntCreated++;
    dominoOrigTransform[i] = new Transform(new Matrix4f(new Quat4f(0,
            sin(angle) / (float) Math.sqrt(2), 0, 1), loc, 1.0f));
    DefaultMotionState dominoMotion = new DefaultMotionState(
            dominoOrigTransform[i]);
    RigidBodyConstructionInfo dominoRigidBodyCI = new RigidBodyConstructionInfo(
            mass, dominoMotion, dominoShape, inertia);
    domino[i] = new RigidBody(dominoRigidBodyCI);
    domino[i].setRestitution(0.5f);
    world.addRigidBody(domino[i]);
    return true;
}
项目:PhET    文件:Graphics3D.java   
public void fillEllipsoid(Point3f center, Point3f[] points, int x, int y,
                            int z, int diameter, Matrix3f mToEllipsoidal,
                            double[] coef, Matrix4f mDeriv,
                            int selectedOctant, Point3i[] octantPoints) {
  switch (diameter) {
  case 1:
    plotPixelClipped(argbCurrent, x, y, z);
    return;
  case 0:
    return;
  }
  if (diameter <= (antialiasThisFrame ? Sphere3D.maxSphereDiameter2
      : Sphere3D.maxSphereDiameter))
    sphere3d.render(shadesCurrent, !addAllPixels, diameter, x, y, z,
        mToEllipsoidal, coef, mDeriv, selectedOctant, octantPoints);
}
项目:PhET    文件:SymmetryOperation.java   
final static String getXYZFromMatrix(Matrix4f mat, boolean is12ths,
                                     boolean allPositive, boolean halfOrLess) {
  String str = "";
  float[] row = new float[4];
  for (int i = 0; i < 3; i++) {
    mat.getRow(i, row);
    String term = "";
    if (row[0] != 0)
      term += (row[0] < 0 ? "-" : "+") + "x";
    if (row[1] != 0)
      term += (row[1] < 0 ? "-" : "+") + "y";
    if (row[2] != 0)
      term += (row[2] < 0 ? "-" : "+") + "z";
    term += xyzFraction((is12ths ? row[3] : row[3] * 12), allPositive,
        halfOrLess);
    if (term.length() > 0 && term.charAt(0) == '+')
      term = term.substring(1);
    str += "," + term;
  }
  return str.substring(1);
}
项目:PhET    文件:Escape.java   
public static Object unescapeMatrix(String strMatrix) {
  if (strMatrix == null || strMatrix.length() == 0)
    return strMatrix;
  String str = strMatrix.replace('\n', ' ').trim();
  if (str.lastIndexOf("[[") != 0 || str.indexOf("]]") != str.length() - 2)
    return strMatrix;
  float[] points = new float[16];
  str = str.substring(2, str.length() - 2).replace('[',' ').replace(']',' ').replace(',',' ');
  int[] next = new int[1];
  int nPoints = 0;
  for (; nPoints < 16; nPoints++) {
    points[nPoints] = Parser.parseFloat(str, next);
    if (Float.isNaN(points[nPoints])) {
      break;
    }
  }
  if (!Float.isNaN(Parser.parseFloat(str, next)))
    return strMatrix; // overflow
  if (nPoints == 9)
    return new Matrix3f(points);
  if (nPoints == 16)
    return new Matrix4f(points);
  return strMatrix;
}
项目:JglTF    文件:ExternalCameraRendering.java   
/**
 * Writes the given matrix into the given array, in column-major order.
 * Neither the matrix nor the array may be <code>null</code>. The given
 * array must have a length of at least <code>offset+16</code>.
 * 
 * @param m The matrix
 * @param a The array
 * @param offset The offset where to start writing into the array
 */
private static void writeMatrixToArrayColumnMajor4f(
    Matrix4f m, float a[], int offset)
{
    int i = offset;
    a[i++] = m.m00;
    a[i++] = m.m10;
    a[i++] = m.m20;
    a[i++] = m.m30;
    a[i++] = m.m01;
    a[i++] = m.m11;
    a[i++] = m.m21;
    a[i++] = m.m31;
    a[i++] = m.m02;
    a[i++] = m.m12;
    a[i++] = m.m22;
    a[i++] = m.m32;
    a[i++] = m.m03;
    a[i++] = m.m13;
    a[i++] = m.m23;
    a[i++] = m.m33;
}
项目:PhET    文件:_IdtfExporter.java   
private void outputEllipsoid(Point3f center, Matrix4f sphereMatrix, short colix) {
  if (!haveSphere) {
    models.append(getSphereResource());
    haveSphere = true;
  }
  checkPoint(center);
  addColix(colix, false);
  String key = "Sphere_" + colix;
  List<String> v = htNodes.get(key);
  if (v == null) {
    v = new ArrayList<String>();
    htNodes.put(key, v);
    addShader(key, colix);
  }
  v.add(getParentItem("Jmol", sphereMatrix));
}
项目:PhET    文件:_IdtfExporter.java   
private void outputCircle(Point3f ptCenter, Point3f ptPerp, short colix, float radius) {
  if (!haveCircle) {
    models.append(getCircleResource());
    haveCircle = true;
    cylinderMatrix = new Matrix4f();
  }
  addColix(colix, false);
  String key = "Circle_" + colix;
  List<String> v = htNodes.get(key);
  if (v == null) {
    v = new ArrayList<String>();
    htNodes.put(key, v);
    addShader(key, colix);
  }
  checkPoint(ptCenter);
  cylinderMatrix.set(getRotationMatrix(ptCenter, ptPerp, radius));
  cylinderMatrix.m03 = ptCenter.x;
  cylinderMatrix.m13 = ptCenter.y;
  cylinderMatrix.m23 = ptCenter.z;
  cylinderMatrix.m33 = 1;
  v.add(getParentItem("Jmol", cylinderMatrix));
}
项目:PhET    文件:__CartesianExporter.java   
protected void setSphereMatrix(Point3f center, float rx, float ry, float rz,
                               AxisAngle4f a, Matrix4f sphereMatrix) {
  if (a != null) {
    Matrix3f mq = new Matrix3f();
    Matrix3f m = new Matrix3f();
    m.m00 = rx;
    m.m11 = ry;
    m.m22 = rz;
    mq.set(a);
    mq.mul(m);
    sphereMatrix.set(mq);
  } else {
    sphereMatrix.setIdentity();
    sphereMatrix.m00 = rx;
    sphereMatrix.m11 = ry;
    sphereMatrix.m22 = rz;
  }
  sphereMatrix.m03 = center.x;
  sphereMatrix.m13 = center.y;
  sphereMatrix.m23 = center.z;
  sphereMatrix.m33 = 1;
}
项目:CraftStudioAPI    文件:CSModelRenderer.java   
/** Set the rotation matrix values based on the given matrix. */
public void setRotationMatrix(Matrix4f matrix) {
    this.rotationMatrix.m00 = matrix.m00;
    this.rotationMatrix.m01 = matrix.m01;
    this.rotationMatrix.m02 = matrix.m02;
    this.rotationMatrix.m03 = matrix.m03;
    this.rotationMatrix.m10 = matrix.m10;
    this.rotationMatrix.m11 = matrix.m11;
    this.rotationMatrix.m12 = matrix.m12;
    this.rotationMatrix.m13 = matrix.m13;
    this.rotationMatrix.m20 = matrix.m20;
    this.rotationMatrix.m21 = matrix.m21;
    this.rotationMatrix.m22 = matrix.m22;
    this.rotationMatrix.m23 = matrix.m23;
    this.rotationMatrix.m30 = matrix.m30;
    this.rotationMatrix.m31 = matrix.m31;
    this.rotationMatrix.m32 = matrix.m32;
    this.rotationMatrix.m33 = matrix.m33;
}
项目:CraftStudioAPI    文件:MathHelper.java   
/**
 * Create a direct FloatBuffer from a Matrix4f.
 *
 * @param mat
 *            The Matrix4f.
 * @return The FloatBuffer.
 */
public static FloatBuffer makeFloatBuffer(Matrix4f mat) {
    final ByteBuffer bb = ByteBuffer.allocateDirect(64);
    bb.order(ByteOrder.nativeOrder());
    final FloatBuffer fb = bb.asFloatBuffer();
    fb.put(mat.m00);
    fb.put(mat.m01);
    fb.put(mat.m02);
    fb.put(mat.m03);
    fb.put(mat.m10);
    fb.put(mat.m11);
    fb.put(mat.m12);
    fb.put(mat.m13);
    fb.put(mat.m20);
    fb.put(mat.m21);
    fb.put(mat.m22);
    fb.put(mat.m23);
    fb.put(mat.m30);
    fb.put(mat.m31);
    fb.put(mat.m32);
    fb.put(mat.m33);
    fb.position(0);
    return fb;
}
项目:Qbar    文件:BlueprintRender.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(
        final ItemCameraTransforms.TransformType cameraTransformType)
{
    if (cameraTransformType.equals(TransformType.GUI))
    {
        return Pair.of(this,
                new TRSRTransformation(new Vector3f(0F, 0, 0F), null,
                        new Vector3f(0.625F * 1.5f, 0.625F * 1.5f, 0.625F * 1.5f),
                        TRSRTransformation.quatFromXYZ(0, (float) Math.PI, 0)).getMatrix());
    }
    return Pair.of(this,
            new TRSRTransformation(new Vector3f(0F, -.2F, 0F), null,
                    new Vector3f(0.625F / 2, 0.625F / 2, 0.625F / 2),
                    TRSRTransformation.quatFromXYZ((float) -Math.PI / 2, 0, 0)).getMatrix());
}
项目:3DManeuverGear    文件:RenderItemHandle.java   
@Override
public Matrix4f apply(ItemCameraTransforms.TransformType transformType) {
    switch (transformType) {
        /*
        case FIRST_PERSON_LEFT_HAND: return this.matrixFirstPersonLeft;
        case FIRST_PERSON_RIGHT_HAND: return this.matrixFirstPersonRight;
        case THIRD_PERSON_LEFT_HAND: return this.matrixThirdPersonLeft;
        case THIRD_PERSON_RIGHT_HAND: return this.matrixThirdPersonRight;
        case GROUND: return this.matrixGround;
        case GUI: return this.matrixGui;
        */
        case FIRST_PERSON_LEFT_HAND: return this.transformFirstPersonLeft();
        case FIRST_PERSON_RIGHT_HAND: return this.transformFirstPersonRight();
        case THIRD_PERSON_LEFT_HAND: return this.transformThirdPersonLeft();
        case THIRD_PERSON_RIGHT_HAND: return this.transformThirdPersonRight();
        case GROUND: return this.transformGround();
        case GUI: return this.transformGui();
    }
    return this.none;
}
项目:Toms-Mod    文件:CableModel.java   
private static Matrix4f getMatrix(EnumFacing facing) {
    switch (facing) {
    case DOWN:
        return ModelRotation.X180_Y0.getMatrix();
    case UP:
        return ModelRotation.X0_Y0.getMatrix();
    case NORTH:
        return ModelRotation.X90_Y0.getMatrix();
    case SOUTH:
        return ModelRotation.X90_Y180.getMatrix();
    case WEST:
        return ModelRotation.X90_Y270.getMatrix();
    case EAST:
        return ModelRotation.X90_Y90.getMatrix();
    default:
        return new Matrix4f();
    }
}
项目:Point-Engine    文件:MeshObject.java   
@Override
public void render(Scene scene, Camera cam) {
    Shader s = getShader("pbr");
    s.bind();

    s.uniformMaterial(this.material);

    Transform trans = new Transform();
    Quat4f q = new Quat4f();
    rb.getMotionState().getWorldTransform(trans);
    trans.getRotation(q);

    Matrix4f mat = new Matrix4f();
    trans.getMatrix(mat);
    s.uniformMat4("model", mat4(mat).scale(this.scale));
    mesh.draw();
}
项目:Toms-Mod    文件:AdvRouterModel.java   
private static Matrix4f getMatrix(EnumFacing facing) {
    switch (facing) {
    case DOWN:
        return ModelRotation.X180_Y0.getMatrix();
    case UP:
        return ModelRotation.X0_Y0.getMatrix();
    case NORTH:
        return ModelRotation.X90_Y0.getMatrix();
    case SOUTH:
        return ModelRotation.X90_Y180.getMatrix();
    case WEST:
        return ModelRotation.X90_Y270.getMatrix();
    case EAST:
        return ModelRotation.X90_Y90.getMatrix();
    default:
        return new Matrix4f();
    }
}
项目:Infernum    文件:ModelKnowledgeBook.java   
private static BakedModelKnowledgeBook rebake(ModelKnowledgeBook model, String name) {  
    Matrix4f m = new Matrix4f();
       m.m20 = 1f / 128f;
       m.m01 = m.m12 = -m.m20;
       m.m33 = 1;
       Matrix3f rotation = new Matrix3f();
       m.getRotationScale(rotation);
       Matrix3f angleZ = new Matrix3f();
       angleZ.rotZ(-1.5708F);
       rotation.mul(rotation, angleZ);
       m.setRotationScale(rotation);
       m.setScale(0.66666666667F * m.getScale());
       m.setTranslation(new Vector3f(0.1875F, 0.2505F, 0.125F));
    SimpleModelFontRenderer fontRenderer = new SimpleModelFontRenderer(Minecraft.getMinecraft().gameSettings, font, Minecraft.getMinecraft().getTextureManager(), false, m, DefaultVertexFormats.ITEM) {
        @Override
        protected float renderUnicodeChar(char c, boolean italic) {
            return super.renderDefaultChar(126, italic);
        }
    };
    int maxLineWidth = 96;
    TextureAtlasSprite fontSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(font2.toString());
    List<BakedQuad> textQuads = new ArrayList<BakedQuad>();

    fontRenderer.setSprite(fontSprite);
       fontRenderer.setFillBlanks(false);

       int yOffset = 2;
       String title = I18n.translateToLocal(name);
       List<String> lines = fontRenderer.listFormattedStringToWidth(title, maxLineWidth);
       for (int line = 0; line < lines.size(); line++) {
        int offset = ((maxLineWidth - fontRenderer.getStringWidth(lines.get(line))) / 2);
        fontRenderer.drawString(lines.get(line), offset, yOffset, 0x00000000);
        yOffset += (fontRenderer.FONT_HEIGHT - 1 + 4);
       }

       textQuads.addAll(fontRenderer.build());
       return new BakedModelKnowledgeBook(model, textQuads);
}
项目:Mass    文件:TestRoom.java   
/**
 * 
 */
@Override
public void initPhysics() {
    DefaultMotionState groundMotionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, -1, 0), 1.0f))); 

    //TODO: Un uglify this code.
    TriangleIndexVertexArray vertArray = new TriangleIndexVertexArray();

    for (Mesh mesh : this.getMeshes()) {
        // Construct collision shape based on the mesh vertices in the Mesh.
        float[] positions = mesh.getPositions();
        int[] indices = mesh.getIndices();

        IndexedMesh indexedMesh = new IndexedMesh();
        indexedMesh.numTriangles = indices.length / 3;
        indexedMesh.triangleIndexBase = ByteBuffer.allocateDirect(indices.length*4).order(ByteOrder.nativeOrder());
        indexedMesh.triangleIndexBase.asIntBuffer().put(indices);
        indexedMesh.triangleIndexStride = 3 * 4;
        indexedMesh.numVertices = positions.length / 3;
        indexedMesh.vertexBase = ByteBuffer.allocateDirect(positions.length*4).order(ByteOrder.nativeOrder());
        indexedMesh.vertexBase.asFloatBuffer().put(positions);
        indexedMesh.vertexStride = 3 * 4;


        vertArray.addIndexedMesh(indexedMesh);
    }

    BvhTriangleMeshShape collShape = new BvhTriangleMeshShape(vertArray, false);
    System.out.println("SCALE: " + this.getScale());
    //collisionShape = new ScaledBvhTriangleMeshShape(collShape, new Vector3f(this.getcale(), this.getScale(), this.getScale()));
    collisionShape = collShape;
    collisionShape.setLocalScaling(new Vector3f(this.getScale(), this.getScale(), this.getScale()));
    RigidBodyConstructionInfo groundRigidBodyCI = new RigidBodyConstructionInfo(0, groundMotionState, collisionShape, new Vector3f(0,0,0)); 
    rigidBody = new RigidBody(groundRigidBodyCI);
    this.rigidBody.activate();
}
项目:Mass    文件:MassterBall.java   
/**
 * Method to initialize all physics related
 * values.
 */
@Override
public void initPhysics() {
    motionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(-2, -400, 0), 1.0f)));

    // Construct collision shape based on the mesh vertices in the Mesh.
    fallInertia = new Vector3f(0,0,0); 
    collisionShape = new BoxShape(new Vector3f(1, 1, 1));
    collisionShape.calculateLocalInertia(mass,fallInertia);

    // Construct the RigidBody.
    RigidBodyConstructionInfo rigidBodyCI = new RigidBodyConstructionInfo(mass, motionState, collisionShape, fallInertia); 
    rigidBody = new RigidBody(rigidBodyCI);
}
项目:PurificatiMagicae    文件:StandardModels.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
{
    if (cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND || cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND)
    {
        return Pair.of(this, mat_fp);
    }
    if (cameraTransformType == ItemCameraTransforms.TransformType.GUI)
    {
        return Pair.of(this, mat_gui);
    }
    return Pair.of(this, null);
}
项目:PurificatiMagicae    文件:StandardModels.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
{
    if (cameraTransformType == ItemCameraTransforms.TransformType.GUI)
        return Pair.of(this, mat_gui);
    return Pair.of(this, mat);
}
项目:PurificatiMagicae    文件:StandardModels.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
{
    if (cameraTransformType == ItemCameraTransforms.TransformType.GUI)
        return Pair.of(this, mat_gui);
    return Pair.of(this, mat);
}
项目:PurificatiMagicae    文件:StandardModels.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
{
    switch (cameraTransformType)
    {
        case GUI:
            return Pair.of(this, mat_gui);
    }
    return Pair.of(this, mat);
}
项目:PurificatiMagicae    文件:StandardModels.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
{
    if(cameraTransformType == ItemCameraTransforms.TransformType.GUI)
        return Pair.of(this, mat_gui);
    return Pair.of(this, mat);
}
项目:PurificatiMagicae    文件:StandardModels.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
{
    if(cameraTransformType == ItemCameraTransforms.TransformType.GUI)
        return Pair.of(this, mat_gui);
    return Pair.of(this, mat);
}
项目:PurificatiMagicae    文件:StandardModels.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
{
    if(cameraTransformType == ItemCameraTransforms.TransformType.GUI)
        return Pair.of(this, mat_gui);
    return Pair.of(this, mat);
}
项目:Clef    文件:BakedModelInstrument.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType type)
{
    if(instrument != null)
    {
        HashMap<ItemCameraTransforms.TransformType, TRSRTransformation> map = new HashMap<>();
        map.put(ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, new TRSRTransformation(new Vector3f(1F, 0F, 1F), TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 180F, 0F)), new Vector3f(1F, 1F, 1F), new Quat4f()));
        map.put(ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, new TRSRTransformation(new Vector3f(0.1F, 0F + (instrument.handImg.getHeight() <= 16F ? 0F : MathHelper.clamp((float)instrument.info.activeHandPosition[1], -0.3F, 0.3F)), 0.025F - (instrument.handImg.getWidth() <= 16F ? 0F : MathHelper.clamp((float)instrument.info.activeHandPosition[0], -0.5F, 0.5F))), TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 80F, 0F)), new Vector3f(-1F, 1F, 1F),  TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 0F, 0F))));
        map.put(ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, new TRSRTransformation(new Vector3f(-0.1F, 0F + (instrument.handImg.getHeight() <= 16F ? 0F : MathHelper.clamp((float)instrument.info.activeHandPosition[1], -0.3F, 0.3F)), 1F - (instrument.handImg.getWidth() <= 16F ? 0F : MathHelper.clamp((float)instrument.info.activeHandPosition[0], -0.5F, 0.5F))), TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 80F, 0F)), new Vector3f(1F, 1F, 1F), TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 0F, 0F))));
        ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms = ImmutableMap.copyOf(map);
        return PerspectiveMapWrapper.handlePerspective(ModelBaseWrapper.isEntityRender(type) ? instrument.handModel : instrument.iconModel, transforms, type);
    }
    return PerspectiveMapWrapper.handlePerspective(this, transforms, type);
}
项目:SimpleTubes    文件:AbstractPerspective.java   
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {

    // if (transformMap.containsValue(cameraTransformType))
    // return Pair.of(this,
    // transformMap.get(cameraTransformType).getMatrix());

    if (applyTransfomation(cameraTransformType) != null)
        return Pair.of(this, applyTransfomation(cameraTransformType).getMatrix());

    return MapWrapper.handlePerspective(this, MapWrapper.getTransforms(getItemCameraTransforms()), cameraTransformType);
}
项目:CustomWorldGen    文件:ForgeHooksClient.java   
@SuppressWarnings("deprecation")
public static IBakedModel handleCameraTransforms(IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType, boolean leftHandHackery)
{
    if(model instanceof IPerspectiveAwareModel)
    {
        Pair<? extends IBakedModel, Matrix4f> pair = ((IPerspectiveAwareModel)model).handlePerspective(cameraTransformType);

        if(pair.getRight() != null)
        {
            Matrix4f matrix = new Matrix4f(pair.getRight());
            if(leftHandHackery)
            {
                matrix.mul(flipX, matrix);
                matrix.mul(matrix, flipX);
            }
            multiplyCurrentGlMatrix(matrix);
        }
        return pair.getLeft();
    }
    else
    {
        //if(leftHandHackery) GlStateManager.scale(-1, 1, 1);
        ItemCameraTransforms.applyTransformSide(model.getItemCameraTransforms().getTransform(cameraTransformType), leftHandHackery);
        //if(leftHandHackery) GlStateManager.scale(-1, 1, 1);
    }
    return model;
}
项目:CustomWorldGen    文件:ForgeHooksClient.java   
public static void multiplyCurrentGlMatrix(Matrix4f matrix)
{
    matrixBuf.clear();
    float[] t = new float[4];
    for(int i = 0; i < 4; i++)
    {
        matrix.getColumn(i, t);
        matrixBuf.put(t);
    }
    matrixBuf.flip();
    glMultMatrix(matrixBuf);
}