/** * Sets the scale. * * @param scale * the scale vector to set */ public void setScale(Vector3f scale) { this.setScale(scale.x, scale.y, scale.z); }
public Matrix4f toTransformMatrix(Matrix4f store) { if (store == null) { store = new Matrix4f(); } store.setTranslation(translation); rot.toTransformMatrix(store); store.setScale(scale); return store; }
/** * Converts given transformation parameters into the matrix. * * @param position * the position of the feature * @param rotation * the rotation of the feature * @param scale * the scale of the feature * @param store * the matrix where the result will be stored * @return the store matrix */ private Matrix4f toMatrix(Vector3f position, Quaternion rotation, Vector3f scale, Matrix4f store) { store.loadIdentity(); store.setTranslation(position); store.setRotationQuaternion(rotation); store.setScale(scale); return store; }
public void renderQuad(int x, int y, int width, int height, Color topLeft, Color topRight, Color bottomRight, Color bottomLeft) { ByteBuffer buf = (ByteBuffer) quadColor.getData(); buf.rewind(); buf.putInt(convertColor(topRight)); buf.putInt(convertColor(topLeft)); buf.putInt(convertColor(bottomLeft)); buf.putInt(convertColor(bottomRight)); buf.flip(); quadColor.updateData(buf); tempMat.loadIdentity(); tempMat.setTranslation(x, getHeight() - y, 0); tempMat.setScale(width, height, 0); rm.setWorldMatrix(tempMat); rm.setForcedRenderState(renderState); vertexColorMaterial.render(quadGeom, rm); //System.out.format("renderQuad2(%d, %d, %d, %d, %s, %s, %s, %s)\n", x, y, width, height, topLeft.toString(), // topRight.toString(), // bottomRight.toString(), // bottomLeft.toString()); }
/** * Fetches the world matrix transformation of the given node. * @param node * the node * @return the node's world transformation matrix */ private Matrix4f getWorldMatrix(Node node) { Matrix4f result = new Matrix4f(); result.setTranslation(node.getWorldTranslation()); result.setRotationQuaternion(node.getWorldRotation()); result.setScale(node.getWorldScale()); return result; }
tempMat.setScale(w * scale, h * scale, 0);
tempMat.setScale(sizeX, sizeY, 0);
public void renderQuad(int x, int y, int width, int height, Color color) { //We test for alpha >0 as an optimization to prevent the render of completely transparent quads. //Nifty use layers that are often used for logical positionning and not rendering. //each layer is rendered as a quad, but that can bump up the number of geometry rendered by a lot. //Since we disable depth write, there is absolutely no point in rendering those quads //This optimization can result in a huge increase of perfs on complex Nifty UIs. if(color.getAlpha() >0){ colorMaterial.setColor("Color", convertColor(color, tempColor)); tempMat.loadIdentity(); tempMat.setTranslation(x, getHeight() - y, 0); tempMat.setScale(width, height, 0); rm.setWorldMatrix(tempMat); rm.setForcedRenderState(renderState); colorMaterial.render(quadGeom, rm); } //System.out.format("renderQuad1(%d, %d, %d, %d, %s)\n", x, y, width, height, color.toString()); }
public void renderImage(RenderImage image, int x, int y, int width, int height, Color color, float imageScale) { RenderImageJme jmeImage = (RenderImageJme) image; textureColorMaterial.setColor("Color", convertColor(color, tempColor)); textureColorMaterial.setTexture("ColorMap", jmeImage.getTexture()); quad.clearBuffer(Type.TexCoord); quad.setBuffer(quadDefaultTC); float x0 = x + 0.5f * width * (1f - imageScale); float y0 = y + 0.5f * height * (1f - imageScale); tempMat.loadIdentity(); tempMat.setTranslation(x0, getHeight() - y0, 0); tempMat.setScale(width * imageScale, height * imageScale, 0); rm.setWorldMatrix(tempMat); rm.setForcedRenderState(renderState); textureColorMaterial.render(quadGeom, rm); //System.out.format("renderImage1(%s, %d, %d, %d, %d, %s, %f)\n", jmeImage.getTexture().getKey().toString(), x, y, width, height, color.toString(), imageScale); }
scaleMat.setScale(jmeLocalNodeTransform.getScale());
private void setViewPort(Camera cam) { // this will make sure to update viewport only if needed if (cam != prevCam || cam.isViewportChanged()) { viewX = (int) (cam.getViewPortLeft() * cam.getWidth()); viewY = (int) (cam.getViewPortBottom() * cam.getHeight()); int viewX2 = (int) (cam.getViewPortRight() * cam.getWidth()); int viewY2 = (int) (cam.getViewPortTop() * cam.getHeight()); viewWidth = viewX2 - viewX; viewHeight = viewY2 - viewY; uniformBindingManager.setViewPort(viewX, viewY, viewWidth, viewHeight); renderer.setViewPort(viewX, viewY, viewWidth, viewHeight); renderer.setClipRect(viewX, viewY, viewWidth, viewHeight); cam.clearViewportChanged(); prevCam = cam; // float translateX = viewWidth == viewX ? 0 : -(viewWidth + viewX) / (viewWidth - viewX); // float translateY = viewHeight == viewY ? 0 : -(viewHeight + viewY) / (viewHeight - viewY); // float scaleX = viewWidth == viewX ? 1f : 2f / (viewWidth - viewX); // float scaleY = viewHeight == viewY ? 1f : 2f / (viewHeight - viewY); // // orthoMatrix.loadIdentity(); // orthoMatrix.setTranslation(translateX, translateY, 0); // orthoMatrix.setScale(scaleX, scaleY, 0); orthoMatrix.loadIdentity(); orthoMatrix.setTranslation(-1f, -1f, 0f); orthoMatrix.setScale(2f / cam.getWidth(), 2f / cam.getHeight(), 0f); } }
/** * Sets the scale. * * @param scale * the scale vector to set */ public void setScale(Vector3f scale) { this.setScale(scale.x, scale.y, scale.z); }
public Matrix4f toTransformMatrix() { Matrix4f trans = new Matrix4f(); trans.setTranslation(translation); trans.setRotationQuaternion(rot); trans.setScale(scale); return trans; }
scaleMat.setScale(jmeLocalNodeTransform.getScale());
private void setViewPort(Camera cam) { // this will make sure to update viewport only if needed if (cam != prevCam || cam.isViewportChanged()) { viewX = (int) (cam.getViewPortLeft() * cam.getWidth()); viewY = (int) (cam.getViewPortBottom() * cam.getHeight()); int viewX2 = (int) (cam.getViewPortRight() * cam.getWidth()); int viewY2 = (int) (cam.getViewPortTop() * cam.getHeight()); viewWidth = viewX2 - viewX; viewHeight = viewY2 - viewY; uniformBindingManager.setViewPort(viewX, viewY, viewWidth, viewHeight); renderer.setViewPort(viewX, viewY, viewWidth, viewHeight); renderer.setClipRect(viewX, viewY, viewWidth, viewHeight); cam.clearViewportChanged(); prevCam = cam; // float translateX = viewWidth == viewX ? 0 : -(viewWidth + viewX) / (viewWidth - viewX); // float translateY = viewHeight == viewY ? 0 : -(viewHeight + viewY) / (viewHeight - viewY); // float scaleX = viewWidth == viewX ? 1f : 2f / (viewWidth - viewX); // float scaleY = viewHeight == viewY ? 1f : 2f / (viewHeight - viewY); // // orthoMatrix.loadIdentity(); // orthoMatrix.setTranslation(translateX, translateY, 0); // orthoMatrix.setScale(scaleX, scaleY, 0); orthoMatrix.loadIdentity(); orthoMatrix.setTranslation(-1f, -1f, 0f); orthoMatrix.setScale(2f / cam.getWidth(), 2f / cam.getHeight(), 0f); } }
private void setViewPort(Camera cam) { // this will make sure to update viewport only if needed if (cam != prevCam || cam.isViewportChanged()) { viewX = (int) (cam.getViewPortLeft() * cam.getWidth()); viewY = (int) (cam.getViewPortBottom() * cam.getHeight()); viewWidth = (int) ((cam.getViewPortRight() - cam.getViewPortLeft()) * cam.getWidth()); viewHeight = (int) ((cam.getViewPortTop() - cam.getViewPortBottom()) * cam.getHeight()); renderer.setViewPort(viewX, viewY, viewWidth, viewHeight); renderer.setClipRect(viewX, viewY, viewWidth, viewHeight); cam.clearViewportChanged(); prevCam = cam; // float translateX = viewWidth == viewX ? 0 : -(viewWidth + viewX) / (viewWidth - viewX); // float translateY = viewHeight == viewY ? 0 : -(viewHeight + viewY) / (viewHeight - viewY); // float scaleX = viewWidth == viewX ? 1f : 2f / (viewWidth - viewX); // float scaleY = viewHeight == viewY ? 1f : 2f / (viewHeight - viewY); // // orthoMatrix.loadIdentity(); // orthoMatrix.setTranslation(translateX, translateY, 0); // orthoMatrix.setScale(scaleX, scaleY, 0); orthoMatrix.loadIdentity(); orthoMatrix.setTranslation(-1f, -1f, 0f); orthoMatrix.setScale(2f / cam.getWidth(), 2f / cam.getHeight(), 0f); // orthoMatrix.fillFloatBuffer(orthoMatrixBuf, true); } }
private void computeBindTransforms(BoneWrapper boneWrapper, Skeleton skeleton) { Bone bone = boneWrapper.bone; tmpTransforms.fromTransformMatrix(boneWrapper.modelBindMatrix); if (bone.getParent() != null) { //root bone, model transforms are the same as the local transforms //but for child bones we need to combine it with the parents inverse model transforms. tmpMat.setTranslation(bone.getParent().getModelSpacePosition()); tmpMat.setRotationQuaternion(bone.getParent().getModelSpaceRotation()); tmpMat.setScale(bone.getParent().getModelSpaceScale()); tmpMat.invertLocal(); tmpTransforms2.fromTransformMatrix(tmpMat); tmpTransforms.combineWithParent(tmpTransforms2); } bone.setBindTransforms(tmpTransforms.getTranslation(), tmpTransforms.getRotation(), tmpTransforms.getScale()); //resets the local transforms to bind transforms for all bones. //then computes the model transforms from local transforms for each bone. skeleton.resetAndUpdate(); skeleton.setBindingPose(); for (Integer childIndex : boneWrapper.children) { BoneWrapper child = fetchFromCache("nodes", childIndex, BoneWrapper.class); computeBindTransforms(child, skeleton); } }