Java 类javax.vecmath.Vector2f 实例源码

项目:CustomWorldGen    文件:B3DModel.java   
private List<Texture> texs() throws IOException
{
    chunk("TEXS");
    List<Texture> ret = new ArrayList<Texture>();
    while(buf.hasRemaining())
    {
        String path = readString();
        int flags = buf.getInt();
        int blend = buf.getInt();
        Vector2f pos = new Vector2f(buf.getFloat(), buf.getFloat());
        Vector2f scale = new Vector2f(buf.getFloat(), buf.getFloat());
        float rot = buf.getFloat();
        ret.add(new Texture(path, flags, blend, pos, scale, rot));
    }
    dump("TEXS([" + Joiner.on(", ").join(ret) + "])");
    popLimit();
    this.textures.addAll(ret);
    return ret;
}
项目:Analyst    文件:ComparisonGLEventListener.java   
private Vector2f findPointOnCurve(Vector2f pt, Vector2f n, LinkedList<LinkedList<Vector2f>> lists) {
    Vector2f intersection = null;
    float dist = Float.MAX_VALUE;
    for (LinkedList<Vector2f> list : lists) {
        for (int i = 1; i < list.size(); i++) {
            Vector2f tmp = lineSegmentIntersection(pt, n, list.get(i - 1), list.get(i));
            if (tmp != null) {
                Vector2f tmp2 = new Vector2f(tmp);
                tmp2.sub(pt);
                if (tmp2.length() < dist) {
                    intersection = tmp;
                    dist = tmp2.length();
                }
            }
        }
    }
    //threshold
    if (dist < 20) {
        return intersection;
    } else {
        return null;
    }
}
项目:Qbar    文件:BeltGrid.java   
public boolean insert(final IBelt belt, final ItemStack stack, final boolean doInsert)
{
    if (!belt.isSlope())
    {
        boolean enoughSpace = true;
        for (final ItemBelt item : belt.getItems())
        {
            if (item.getPos().y < 13 / 32F)
            {
                enoughSpace = false;
                break;
            }
        }
        if (!enoughSpace)
            return false;
        if (doInsert)
        {
            belt.getItems().add(new ItemBelt(stack, new Vector2f(this.BELT_MIDDLE, 0)));
            belt.itemUpdate();
        }
    }
    return true;
}
项目:ct-sim    文件:Parcours.java   
/**
 * Prueft, ob ein Punkt ueber einem Loch liegt
 * 
 * @param pos
 * @return true, wenn der Bot ueber dem loch steht
 */
public boolean checkHole(Point3d pos) {
    if ((pos.x < 0) || (pos.y < 0) || (pos.x > dimX * blockSizeInM) || (pos.y > dimY * blockSizeInM)) {
        return true;
    }

    Iterator it = holes.iterator();
    while (it.hasNext()) {
        Vector2f min = new Vector2f((Vector2d) it.next());
        min.scale(blockSizeInM);

        Vector2f max = new Vector2f(min);
        max.add(new Vector2f(blockSizeInM, blockSizeInM));

        if ((pos.x > min.x) && (pos.x < max.x) && (pos.y > min.y) && (pos.y < max.y)) {
            return true;
        }
    }

    return false;
}
项目:codeswarm    文件:PhysicsEngineChaotic.java   
/**
 * Legacy method that calculate the attractive/repulsive force between a person and one of its file along their link (the edge).
 * 
 * @param edge the link between a person and one of its file 
 * @return force force calculated between those two nodes
 */
private Vector2f calculateForceAlongAnEdge( code_swarm.Edge edge )
{
  float distance;
  float deltaDistance;
  Vector2f force = new Vector2f();
  Vector2f tforce = new Vector2f();

  // distance calculation
  tforce.sub(edge.nodeTo.mPosition, edge.nodeFrom.mPosition);
  distance = tforce.length();
  if (distance > 0) {
    // force calculation (increase when distance is different from targeted len")
    deltaDistance = (edge.len - distance) / (distance * 3);
    // force ponderation using a re-mapping life from 0-255 scale to 0-1.0 range
    // This allows nodes to drift apart as their life decreases.
    deltaDistance *= ((float)edge.life / edge.LIFE_INIT);

    // force projection onto x and y axis
    tforce.scale(deltaDistance);

    force.set(tforce);
  }

  return force;
}
项目:codeswarm    文件:PhysicsEngineSimple.java   
/**
 * Simple method that calculate the attractive/repulsive force between a person and one of its file along their link (the edge).
 * 
 * @param edge the link between a person and one of its file 
 * @return force force calculated between those two nodes
 */
private Vector2f calculateForceAlongAnEdge( code_swarm.Edge edge )
{
  float distance;
  float deltaDistance;
  Vector2f force = new Vector2f();
  Vector2f tforce = new Vector2f();

  // distance calculation
  tforce.sub( edge.nodeTo.mPosition, edge.nodeFrom.mPosition);
  distance = tforce.length();
  // force calculation (increase when distance is different from targeted len)
  deltaDistance = (edge.len - distance);
  // force projection onto x and y axis
  tforce.scale( deltaDistance * FORCE_EDGE_MULTIPLIER );
  force.set(tforce);

  return force;
}
项目:codeswarm    文件:PhysicsEngineSimple.java   
/**
 * Simple method that calculate the repulsive force between two similar nodes (either files or persons).
 * 
 * @param nodeA [in]
 * @param nodeB [in]
 * @return force force calculated between those two nodes
 */
private Vector2f calculateForceBetweenNodes( code_swarm.Node nodeA, code_swarm.Node nodeB )
{
  float distance;
  Vector2f force = new Vector2f();
  Vector2f normVec = new Vector2f();

  /**
   * Get the distance between nodeA and nodeB
   */
  normVec.sub(nodeA.mPosition, nodeB.mPosition);
  distance = normVec.length();
  if (distance > 0) {
    // No collision
    normVec.scale(1/distance * FORCE_NODES_MULTIPLIER);
    force.set(normVec);
  }

  return force;
}
项目:codeswarm    文件:PhysicsEngineSimple.java   
/**
 * Simple method that apply a force to a node, converting acceleration to speed.
 * 
 * @param node the node to which the force apply
  */
private void applySpeedTo( code_swarm.Node node )
{
  float div;
  // This block enforces a maximum absolute velocity.
  // TODO : I want to remove all this
  if (node.mSpeed.length() > node.maxSpeed) {
    Vector2f mag = new Vector2f(node.mSpeed.x / node.maxSpeed, node.mSpeed.y / node.maxSpeed);
    div = mag.length();
    node.mSpeed.scale( 1/div );
  }

  // This block convert Speed to Position
  node.mPosition.add(node.mSpeed);

  // Apply drag (reduce Speed for next frame calculation)
  node.mSpeed.scale( SPEED_TO_POSITION_MULTIPLIER );
}
项目:codeswarm    文件:PhysicsEngineSimple.java   
/**
 * Method that allows Physics Engine to modify Speed / Position during the relax phase.
 * 
 * @param fNodes the nodes to which the force apply
 *
 * @return Returns a LinkedList of nodes which are still alive after the function call.
 * 
 * @Note Standard physics is "Position Variation = Speed x Duration" with a convention of "Duration=1" between to frames
 */
public LinkedList<code_swarm.FileNode> onRelaxNodes(LinkedList<code_swarm.FileNode> fNodes ) {
    for (code_swarm.FileNode fNode : fNodes) {
      Vector2f forceBetweenFiles = new Vector2f();
      Vector2f forceSummation    = new Vector2f();

      // Calculation of repulsive force between persons
      for (code_swarm.FileNode n : fNodes) {
        if (n != fNode) {
          // elemental force calculation, and summation
          forceBetweenFiles = calculateForceBetweenNodes(fNode, n);
          forceSummation.add(forceBetweenFiles);
        }
      }
      // Apply repulsive force from other files to this Node
      applyForceTo(fNode, forceSummation);
    }

    return fNodes;
}
项目:codeswarm    文件:PhysicsEngineSimple.java   
/**
 * Method that allows Physics Engine to modify Speed / Position during the relax phase.
 * 
 * @param pNodes the nodes to which the force apply
 *
 * @return Returns a LinkedList of nodes which are still alive after the function call.
 * 
 * @Note Standard physics is "Position Variation = Speed x Duration" with a convention of "Duration=1" between to frames
 */
public LinkedList<code_swarm.PersonNode> onRelaxPeople(LinkedList<code_swarm.PersonNode> pNodes) {
    for (code_swarm.PersonNode pNode : pNodes) {
      Vector2f forceBetweenPersons = new Vector2f();
      Vector2f forceSummation      = new Vector2f();

      // Calculation of repulsive force between persons
      for (code_swarm.PersonNode p : pNodes) {
        if (p != pNode) {
          // elemental force calculation, and summation
          forceBetweenPersons = calculateForceBetweenNodes(pNode, p);
          forceSummation.add(forceBetweenPersons);
        }
      }

      // Apply repulsive force from other persons to this Node
      applyForceTo(pNode, forceSummation);
    }
    return pNodes;
}
项目:codeswarm    文件:PhysicsEngineMaxwellsDemon.java   
/**
 * Calculate the attractive/repulsive force between a person and one of its file
 * along their link (the edge).
 * 
 * @param edge the link between a person and one of its file 
 * @return Vector2f force calculated between those two nodes
 */
private Vector2f calculateForceAlongAnEdge( code_swarm.Edge edge )
{
  float distance;
  float deltaDistance;
  Vector2f force = new Vector2f();
  Vector2f tforce = new Vector2f();

  // distance calculation
  tforce.sub(edge.nodeTo.mPosition, edge.nodeFrom.mPosition);
  distance = tforce.length();
  if (distance > 0) {
    // force calculation (increase when distance is different from targeted len")
    deltaDistance = (edge.len - distance) / (distance * 3);
    // force ponderation using a re-mapping life from 0-255 scale to 0-1.0 range
    // This allows nodes to drift apart as their life decreases.
    deltaDistance *= ((float)edge.life / edge.LIFE_INIT);

    // force projection onto x and y axis
    tforce.scale(deltaDistance);

    force.set(tforce);
  }

  return force;
}
项目:codeswarm    文件:PhysicsEngineMaxwellsDemon.java   
/**
 * Method that allows Physics Engine to modify forces between files and people during the relax stage
 * 
 * @param edges the edges to which the force apply (both ends)
 *
 * @return Returns a LinkedList of nodes which are still alive after the function call.
 * 
 * @Note Standard physics is "Position Variation = Speed x Duration" with a convention of "Duration=1" between to frames
 */
public LinkedList<code_swarm.Edge> onRelaxEdges(LinkedList<code_swarm.Edge> edges) {
    for (code_swarm.Edge edge : edges){
        boolean fSide = whichSide(edge.nodeFrom);
        boolean pSide = whichSide(edge.nodeTo);

        if ((!doorOpen && fSide != pSide) || ((doorOpen && edge.nodeFrom.mPosition.y < startDoorY) || (doorOpen && edge.nodeFrom.mPosition.y > startDoorY + doorSize))) {
            continue;
        }

        // Calculate force between the node "from" and the node "to"
        Vector2f force = calculateForceAlongAnEdge(edge);

        // transmit force projection to file and person nodes
        force.negate();
        applyForceTo(edge.nodeFrom, force); // fNode: attract fNode to pNode
        // which half of the screen are we on?
        applySpeedTo(edge.nodeFrom); // fNode: move it.
        constrainNode(edge.nodeFrom, whichSide(edge.nodeFrom)); // Keep it in bounds.
    }
    return edges;
}
项目:codeswarm    文件:PhysicsEngineMaxwellsDemon.java   
/**
 * Method that allows Physics Engine to modify Speed / Position during the relax phase.
 * 
 * @param fNodes the nodes to which the force apply
 *
 * @return Returns a LinkedList of nodes which are still alive after the function call.
 * 
 * @Note Standard physics is "Position Variation = Speed x Duration" with a convention of "Duration=1" between to frames
 */
public LinkedList<code_swarm.FileNode> onRelaxNodes(LinkedList<code_swarm.FileNode> fNodes ) {
    for (code_swarm.FileNode fNode : fNodes) {
        boolean mySide = whichSide(fNode);

        Vector2f forceBetweenFiles = new Vector2f();
        Vector2f forceSummation    = new Vector2f();

        // Calculation of repulsive force between persons
        for (code_swarm.FileNode n : fNodes) {
            if (n != fNode && mySide == whichSide(n)) {
                // elemental force calculation, and summation
                forceBetweenFiles = calculateForceBetweenfNodes(fNode, n);
                forceSummation.add(forceBetweenFiles);
            }
        }
        // Apply repulsive force from other files to this Node
        applyForceTo(fNode, forceSummation);
    }
    return fNodes;
}
项目:codeswarm    文件:PhysicsEngineLegacy.java   
/**
 * Legacy method that calculate the attractive/repulsive force between a person and one of its file along their link (the edge).
 * 
 * @param edge the link between a person and one of its file 
 * @return force force calculated between those two nodes
 */
private Vector2f calculateForceAlongAnEdge( code_swarm.Edge edge )
{
  float distance;
  float deltaDistance;
  Vector2f force = new Vector2f();
  Vector2f tforce = new Vector2f();

  // distance calculation
  tforce.sub(edge.nodeTo.mPosition, edge.nodeFrom.mPosition);
  distance = tforce.length();
  if (distance > 0) {
    // force calculation (increase when distance is different from targeted len")
    deltaDistance = (edge.len - distance) / (distance * 3);
    // force ponderation using a re-mapping life from 0-255 scale to 0-1.0 range
    // This allows nodes to drift apart as their life decreases.
    deltaDistance *= ((float)edge.life / edge.LIFE_INIT);

    // force projection onto x and y axis
    tforce.scale(deltaDistance*FORCE_EDGE_MULTIPLIER);

    force.set(tforce);
  }

  return force;
}
项目:codeswarm    文件:PhysicsEngineLegacy.java   
/**
 * Legacy method that apply a force to a node, converting acceleration to speed.
 * 
 * @param node the node to which the force apply
  */
private void applySpeedTo( code_swarm.Node node )
{
  float div;
  // This block enforces a maximum absolute velocity.
  if (node.mSpeed.length() > node.maxSpeed) {
    Vector2f mag = new Vector2f(node.mSpeed.x / node.maxSpeed, node.mSpeed.y / node.maxSpeed);
    div = mag.length();
    node.mSpeed.scale( 1/div );
  }

  // This block convert Speed to Position
  node.mPosition.add(node.mSpeed);

  // Apply drag (reduce Speed for next frame calculation)
  node.mSpeed.scale( SPEED_TO_POSITION_MULTIPLIER );
}
项目:codeswarm    文件:PhysicsEngineLegacy.java   
/**
 * Method that allows Physics Engine to modify Speed / Position during the relax phase.
 * 
 * @param fNodes the nodes to which the force apply
 *
 * @return Returns a LinkedList of nodes which are still alive after the function call.
 * 
 * @Note Standard physics is "Position Variation = Speed x Duration" with a convention of "Duration=1" between to frames
 */
public LinkedList<code_swarm.FileNode> onRelaxNodes(LinkedList<code_swarm.FileNode> fNodes ) {
    for (code_swarm.FileNode fNode : fNodes) {
        Vector2f forceBetweenFiles = new Vector2f();
        Vector2f forceSummation    = new Vector2f();

        // Calculation of repulsive force between persons
        for (code_swarm.FileNode n : fNodes) {
            if (n != fNode) {
                // elemental force calculation, and summation
                forceBetweenFiles = calculateForceBetweenNodes(fNode, n);
                forceSummation.add(forceBetweenFiles);
            }
        }
        // Apply repulsive force from other files to this Node
        applyForceTo(fNode, forceSummation);
    }
    return fNodes;
}
项目:codeswarm    文件:PhysicsEngineLegacy.java   
/**
 * Method that allows Physics Engine to modify Speed / Position during the relax phase.
 * 
 * @param pNodes the nodes to which the force apply
 *
 * @return Returns a LinkedList of nodes which are still alive after the function call.
 * 
 * @Note Standard physics is "Position Variation = Speed x Duration" with a convention of "Duration=1" between to frames
 */
public LinkedList<code_swarm.PersonNode> onRelaxPeople(LinkedList<code_swarm.PersonNode> pNodes) {
    for (code_swarm.PersonNode pNode : pNodes) {
        Vector2f forceBetweenPersons = new Vector2f();
        Vector2f forceSummation      = new Vector2f();

        // Calculation of repulsive force between persons
        for (code_swarm.PersonNode p : pNodes) {
            if (p != pNode) {
                // elemental force calculation, and summation
                forceBetweenPersons = calculateForceBetweenNodes(pNode, p);
                forceSummation.add(forceBetweenPersons);
            }
        }
        // Apply repulsive force from other persons to this Node
        applyForceTo(pNode, forceSummation);

        // Don't know why, but the prototype had this.
        pNode.mSpeed.scale(1.0f/12);
    }
    return pNodes;
}
项目:MCAnm    文件:TesselationPoint.java   
public static TesselationPoint readFrom(DataInputStream di) throws IOException {
    TesselationPoint tessP = new TesselationPoint();
    // Read coords
    Vector3f coords = Utils.readVector3f(di);
    // Read normal
    Vector3f normal = Utils.readVector3f(di);
    if (normal.length() == 0)
        throw new ModelFormatException("Normal vector can't have zerolength.");
    // Read materialIndex coordinates
    Vector2f texCoords = Utils.readVector2f(di);
    // Read bindings
    BoneBinding[] bindings = BoneBinding.readMultipleFrom(di);
    // Apply attributes
    tessP.coords = coords;
    tessP.normal = normal;
    tessP.texCoords = texCoords;
    tessP.boneBindings = bindings;
    return tessP;
}
项目:Mineworld    文件:FreeStyleType.java   
@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);

}
项目:Mineworld    文件:EntitySystemBuilder.java   
private void registerTypeHandlers(ComponentLibrary library) {
    library.registerTypeHandler(BlockFamily.class, new BlockFamilyTypeHandler());
    library.registerTypeHandler(Color4f.class, new Color4fTypeHandler());
    library.registerTypeHandler(Quat4f.class, new Quat4fTypeHandler());
    library.registerTypeHandler(Mesh.class, new AssetTypeHandler(AssetType.MESH, Mesh.class));
    library.registerTypeHandler(Sound.class, new AssetTypeHandler(AssetType.SOUND, Sound.class));
    library.registerTypeHandler(Material.class, new AssetTypeHandler(AssetType.MATERIAL, Material.class));
    library.registerTypeHandler(SkeletalMesh.class, new AssetTypeHandler(AssetType.SKELETON_MESH, SkeletalMesh.class));
    library.registerTypeHandler(MeshAnimation.class, new AssetTypeHandler(AssetType.ANIMATION, MeshAnimation.class));
    library.registerTypeHandler(Vector3f.class, new Vector3fTypeHandler());
    library.registerTypeHandler(Vector2f.class, new Vector2fTypeHandler());
    Vector3iTypeHandler vector3iHandler = new Vector3iTypeHandler();
    library.registerTypeHandler(Vector3i.class, vector3iHandler);
    library.registerTypeHandler(CollisionGroup.class, new CollisionGroupTypeHandler());
    library.registerTypeHandler(Region3i.class, new Region3iTypeHandler(vector3iHandler));
}
项目:Mineworld    文件:UIDisplayContainerScrollable.java   
/**
 * Move the scrollbar.
 * @param pos The position (y direction) where to move the scrollbar.
 */
private void moveScrollbar(float pos) {
    float scrollbarPos = pos - getAbsolutePosition().y - scrollbarPressedOffset;

    if (scrollbarPos < 0) {
        scrollbarPos = 0;
    }

    if (scrollbarPos > (getSize().y - scrollbar.getSize().y)) {
        scrollbarPos = getSize().y - scrollbar.getSize().y;
    }

    //calculate the different in the position
    scrollbar.setPosition(new Vector2f(0f, scrollbarPos));

    //move the content
    container.setPosition(new Vector2f(padding.w, -multiplier * scrollbar.getPosition().y + padding.x));

    notifyScrollListeners();
}
项目:Mineworld    文件:BlockLoader.java   
private void applyShape(Block block, BlockShape shape, Map<BlockPart, AssetUri> tileUris, Rotation rot) {
    for (BlockPart part : BlockPart.values()) {
        // TODO: Need to be more sensible with the texture atlas. Because things like block particles read from a part that may not exist, we're being fairly lenient
        int tileIndex = getTileIndex(tileUris.get(part), shape.getMeshPart(part) != null);
        Vector2f atlasPos = calcAtlasPositionForId(tileIndex);
        BlockPart targetPart = rot.rotate(part);
        block.setTextureAtlasPos(targetPart, atlasPos);
        if (shape.getMeshPart(part) != null) {
            block.setMeshPart(targetPart, shape.getMeshPart(part).rotate(rot.getQuat4f()).mapTexCoords(atlasPos, Block.TEXTURE_OFFSET_WIDTH));
            if (part.isSide()) {
                block.setFullSide(targetPart.getSide(), shape.isBlockingSide(part.getSide()));
            }
        }
    }
    block.setCollision(shape.getCollisionOffset(rot), shape.getCollisionShape(rot));
}
项目:Mineworld    文件:CraftBlocksRenderer.java   
private void drawQuad(Vector2f texturePosition, Vector2f textureSize){
    glBegin(GL_QUADS);
    glColor4f(1f, 1f, 1f, 1f);
    GL11.glTexCoord2f(texturePosition.x, texturePosition.y + textureSize.y);
    GL11.glVertex3f(-0.5f, -0.5f, 0.0f);

    GL11.glTexCoord2f(texturePosition.x + textureSize.x, texturePosition.y + textureSize.y);
    GL11.glVertex3f(0.5f, -0.5f, 0.0f);

    GL11.glTexCoord2f(texturePosition.x + textureSize.x, texturePosition.y);
    GL11.glVertex3f(0.5f, 0.5f, 0.0f);

    GL11.glTexCoord2f(texturePosition.x, texturePosition.y);
    GL11.glVertex3f(-0.5f, 0.5f, 0.0f);
    glEnd();
}
项目:Mineworld    文件:TessellatorHelper.java   
public static void addGUIQuadMesh(Tessellator tessellator, Vector4f color, float sizeX, float sizeY) {
    tessellator.resetParams();
    tessellator.setColor(new Vector4f(color.x, color.y, color.z, color.w));
    tessellator.setUseLighting(false);
    tessellator.setUseNormals(false);

    tessellator.addPoly(
            new Vector3f[]{
                    new Vector3f(0, 0, 0),
                    new Vector3f(sizeX, 0, 0),
                    new Vector3f(sizeX, sizeY, 0),
                    new Vector3f(0, sizeY, 0)
            },
            new Vector2f[]{
                    new Vector2f(0, 0),
                    new Vector2f(1, 0),
                    new Vector2f(1, 1),
                    new Vector2f(0, 1)
            }
    );
    tessellator.setUseLighting(true);
    tessellator.setUseNormals(true);
}
项目:Mineworld    文件:UIScreenContainer.java   
public void openContainer(EntityRef container, EntityRef creature) {
    this.container = container;
    this.creature = creature;

    playerToolbar.setEntity(creature, 0, 9);
    playerInventory.setEntity(creature, 10);
    containerInventory.setEntity(container);

    playerToolbar.setConnected(container);
    playerInventory.setConnected(container);
    containerInventory.setConnected(creature);
    //TODO connect toolbar <-> inventory somehow to allow fast transfer.

    getGUIManager().getWindowById("hud").getElementById("leftGearWheel").setVisible(false);
    getGUIManager().getWindowById("hud").getElementById("rightGearWheel").setVisible(false);
    layout();

    playerInventory.setPosition(new Vector2f(Display.getWidth() / 2 - playerInventory.getSize().x / 2, Display.getHeight() + 5f));
    playerInventory.addAnimation(new AnimationMove(new Vector2f(Display.getWidth() / 2 - playerInventory.getSize().x / 2, Display.getHeight() - 192f), 20f));
    playerInventory.getAnimation(AnimationMove.class).start();
    leftGearWheel.addAnimation(new AnimationRotate(-120f, 10f));
    leftGearWheel.getAnimation(AnimationRotate.class).start();
    rightGearWheel.addAnimation(new AnimationRotate(120f, 10f));
    rightGearWheel.getAnimation(AnimationRotate.class).start();
}
项目:Mineworld    文件:UIScreenLoading.java   
public UIScreenLoading() {
    setId("loading");
    setBackgroundImage("engine:loadingbackground");
    setModal(true);
    maximize();

    background = new UIImage(Assets.getTexture("engine:menuBackground"));
    background.setVisible(true);

    _progressBar = new UIProgressBar();
    _progressBar.setSize(new Vector2f(256f, 15f));
    _progressBar.setHorizontalAlign(EHorizontalAlign.CENTER);
    _progressBar.setVerticalAlign(EVerticalAlign.BOTTOM);
    _progressBar.setPosition(new Vector2f(0f, -80f));
    _progressBar.setVisible(true);

    addDisplayElement(background);
    addDisplayElement(_progressBar);
}
项目:Mineworld    文件:UITabFolder.java   
/**
 * Add an tab item to a specific location in the tab folder.
 * @param index The index, where the tab item should be added.
 * @param item The tab item to add.
 */
public void addItem(int index, UITabItem item) {
    item.setPosition(new Vector2f(0f, 0f));
    item.setTabFolder(this);
    item.setVisible(true);

    tabsBar.addDisplayElement(item.getTab());
    tabs.addDisplayElement(item);
    container.applyLayout();

    notifyChangedListeners();

    if (getItemCount() == 1) {
        select(item);
    }

    tabs.setSize(new Vector2f(getSize().x, getSize().y - tabsBar.getSize().y));
}
项目:Mineworld    文件:UIProgressBar.java   
public UIProgressBar() {
    setBackgroundImage("engine:gui_menu", new Vector2f(0f, 175f), new Vector2f(256f, 15f));

    label = new UILabel();
    label.setHorizontalAlign(EHorizontalAlign.CENTER);
    label.setColor(Color.white);
    label.setCrop(false);
    label.setVisible(true);

    progressLine = new UIProgressLine();
    progressLine.setPosition(new Vector2f(4f, 3f));
    progressLine.updateProgress(minValue, maxValue - minValue);
    progressLine.setVisible(true);

    progressLine.addDisplayElement(label);
    addDisplayElement(progressLine);

    setTextPosition(labelPosition);
    calcRange();
}
项目:Mineworld    文件:UISlider.java   
/**
 * Changes the slider position based on the mouse position.
 * @param pos The position of the mouse in x direction.
 */
private void changeSlider(float pos) {
    float sliderPos = pos - getPosition().x - slider.getSize().x / 2;
    if (sliderPos < 0)
    {
        sliderPos = 0;
    }
    else if (sliderPos > (getSize().x - slider.getSize().x))
    {
        sliderPos = getSize().x - slider.getSize().x;
    }

    slider.setPosition(new Vector2f(sliderPos, 0f));

    int newValue = posToValue(sliderPos);
    if (newValue != currentValue)
    {
        currentValue = newValue;

        notifyChangedListeners();
    }
}
项目:Mineworld    文件:UIText.java   
public void updateSelection(int start, int end) {
    if (start != end) {
        rectangles.clear();

        //loop through all selected lines and add a selection rectangle for each
        int nextLine;
        Vector2f pos;
        for (int i = start; i < end;) {
            nextLine = findNextChar(i, '\n', false);
            pos = toDisplayPosition(i);
            pos.x = pos.x * 2;
            pos.y = pos.y * 2 - cursor.getSize().y;
            Vector2f size = new Vector2f(calcTextWidth(text.getText().substring(i, Math.min(end, nextLine))), cursor.getSize().y);

            rectangles.add(new Vector2f[] {pos, size});

            i = nextLine;
        }

        selectionRectangle.setVisible(true);
    } else {
        selectionRectangle.setVisible(false);
    }
}
项目:Mineworld    文件:UIText.java   
/**
 * Get the position on the display at the given position in the text.
 * @param index The position in the text. From 0 to the length of the text.
 * @return Returns the display position.
 */
private Vector2f toDisplayPosition(int index) {
    Vector2f displayPos = new Vector2f();

    String substr = text.getText().substring(0, index);
    String lastLine = substr;

    int indexLastLine = substr.lastIndexOf('\n');
    if (indexLastLine != -1) {
        lastLine = substr.substring(indexLastLine, substr.length());
    }

    displayPos.x = calcTextWidth(lastLine) / 2;
    displayPos.y = calcTextHeight(substr) / 2;

    return displayPos;
}
项目:Mineworld    文件:UIDisplayContainer.java   
@Override
public boolean processMouseInput(int button, boolean state, int wheelMoved, boolean consumed, boolean croped) {
    if (!isVisible())
        return consumed;

    //cancel mouse click event if the click is out of the cropped area
    if (cropContainer) {
        if (!intersects(new Vector2f(Mouse.getX(), Display.getHeight() - Mouse.getY()))) {
            croped = true;
        }
    }

    // Pass the mouse event to all display elements
    for (int i = displayElements.size() - 1; i >= 0; i--) {
        consumed = displayElements.get(i).processMouseInput(button, state, wheelMoved, consumed, croped);
    }

    consumed = super.processMouseInput(button, state, wheelMoved, consumed, croped);

    return consumed;
}
项目:Mineworld    文件:UIDisplayContainer.java   
/**
 * Set the background Image.
 * @param texture The texture to load.
 * @param origin The origin of the texture.
 * @param size The size of the texture.
 */
public void setBackgroundImage(String texture, Vector2f origin, Vector2f size) {
    StyleBackgroundImage style = getStyle(StyleBackgroundImage.class);

    if (style == null) {
        style = new StyleBackgroundImage(Assets.getTexture(texture));
        style.setTextureOrigin(origin);
        style.setTextureSize(size);
        style.setVisible(true);
        addStyle(style);
    } else {
        //check if same texture is already loaded
        if (!style.getTexture().getURI().toString().equals("texture:" + texture)) {
            style.setTexture(Assets.getTexture(texture));
        }

        style.setTextureOrigin(origin);
        style.setTextureSize(size);
    }
}
项目:PurificatiMagicae    文件:SPacketUseSipAmulet.java   
@Override
public IMessage onMessage(SPacketUseSipAmulet message, MessageContext ctx)
{
    (ctx.getServerHandler().player.getServerWorld()).addScheduledTask(() ->
    {
        EntityPlayer p = ctx.getServerHandler().player;
        if (ItemSipAmulet.checkForAmulet(p))
        {
            ItemStack amulet = ItemUtils.getBauble(p, BaubleType.AMULET.getValidSlots()[0]);
            Map<String, Integer> sips = amulet.getCapability(CapabilityRegistry.SIP_STORE_CAP, null).getStored();
            for (Map.Entry<String, Integer> entr : sips.entrySet())
            {
                SipEffect eff = PurMag.INSTANCE.getSipEffects().getMap().get(entr.getKey());
                int lvl = amulet.getMetadata();
                if (eff.getMaxLevel() != -1 && lvl > eff.getMaxLevel())
                    lvl = eff.getMaxLevel();
                p.addPotionEffect(new PotionEffect(eff.getEffect(), eff.getTicks() * entr.getValue(), lvl, false, false));
                float rads = (float) Math.toRadians(p.rotationYaw + 180);
                Vector2f vec = new Vector2f(MathHelper.sin(rads), -MathHelper.cos(rads));
                for (int i = entr.getValue(); i > 0; i -= 8)
                {
                    NetworkManager.sendToAllAround(new CPacketSpawnSipParticle(
                                    new Vector3d(p.posX, p.posY + 1.3f, p.posZ),
                                    new Vector3d(p.posX + (vec.x * 5) + (PurMag.INSTANCE.random.nextFloat() * 4 - 2), p.posY + 1.3f + (PurMag.INSTANCE.random.nextFloat() * 4 - 2), p.posZ + (vec.y * 5) + (PurMag.INSTANCE.random.nextFloat() * 4 - 2)),
                                    0.1f,
                                    entr.getKey(),
                                    i >= 8 ? 8 : i
                            ),
                            (int) p.posX, (int) p.posY, (int) p.posZ, p.dimension, 300);
                }
            }
            amulet.getCapability(CapabilityRegistry.SIP_STORE_CAP, null).clear();
            ItemUtils.setBauble(ctx.getServerHandler().player, BaubleType.AMULET.getValidSlots()[0], amulet);
        }
    });
    return null;
}
项目:FastNoise_Java    文件:FastNoise.java   
public void GradientPerturbFractal(Vector2f v2) {
    int seed = m_seed;
    float amp = m_gradientPerturbAmp * m_fractalBounding;
    float freq = m_frequency;

    SingleGradientPerturb(seed, amp, m_frequency, v2);

    for (int i = 1; i < m_octaves; i++) {
        freq *= m_lacunarity;
        amp *= m_gain;
        SingleGradientPerturb(++seed, amp, freq, v2);
    }
}
项目:CustomWorldGen    文件:OBJModel.java   
public Texture(String path, Vector2f position, Vector2f scale, float rotation)
{
    this.path = path;
    this.position = position;
    this.scale = scale;
    this.rotation = rotation;
}
项目:CustomWorldGen    文件:B3DModel.java   
public Texture(String path, int flags, int blend, Vector2f pos, Vector2f scale, float rot)
{
    this.path = path;
    this.flags = flags;
    this.blend = blend;
    this.pos = pos;
    this.scale = scale;
    this.rot = rot;
}
项目:Analyst    文件:ComparisonGLEventListener.java   
private void sampleList(LinkedList<LinkedList<Vector2f>> lists) {
    ArrayList<Vector2f> points = new ArrayList<>();
    ArrayList<Vector2f> normals = new ArrayList<>();
    float step = 15;

    if (lists != null && lists.size() > 0) {

        if (lists.getFirst().size() > 1) {
            points.add(lists.getFirst().getFirst());
            Vector2f x = new Vector2f(lists.getFirst().get(1));
            x.sub(lists.getFirst().get(0));
            normals.add(new Vector2f(x.y, -x.x));
        }

        for (LinkedList<Vector2f> list : lists) {
            float distance = 0;
            for (int i = 1; i < list.size(); i++) {
                Vector2f v = new Vector2f(list.get(i));
                v.sub(list.get(i - 1));
                if ((distance + v.length()) >= step) {
                    Vector2f u = new Vector2f(list.get(i - 1));
                    float tmpDistance = v.length() - (step - distance);
                    v.scale((step - distance) / v.length());
                    u.add(v);
                    points.add(u);
                    Vector2f n = new Vector2f(v.y, -v.x);
                    normals.add(n);

                    distance = tmpDistance;
                } else {
                    distance += v.length();
                }
            }
        }
    }
    info.setSamplePoints(points);
    info.setSampleNormals(normals);
}
项目:Analyst    文件:ComparisonGLEventListener.java   
private void rotateToXY(ArrayList<LinkedList<LinkedList<Vector3f>>> lists) {
    Vector3f axe = new Vector3f();
    Vector3f n = new Vector3f(info.getPlaneNormal());
    n.normalize();
    Vector3f XYnormal = new Vector3f(0, 0, 1);
    axe.cross(n, XYnormal);
    axe.normalize();
    double angle = Math.acos(n.dot(XYnormal));

    ArrayList<LinkedList<LinkedList<Vector2f>>> finalLists = new ArrayList<>();

    for (LinkedList<LinkedList<Vector3f>> list : lists) {
        LinkedList<LinkedList<Vector2f>> tmpLists = new LinkedList<>();
        for (LinkedList<Vector3f> l : list) {
            LinkedList<Vector2f> tmp = new LinkedList<>();
            for (Vector3f l1 : l) {
                if (Float.isNaN(axe.x)) {
                    tmp.add(new Vector2f(l1.x, l1.y));
                } else {
                    Vector3f v = rotateAroundAxe(l1, axe, angle);
                    tmp.add(new Vector2f(v.x, v.y));
                    //  tmp.getLast().setZ(0);
                }

            }
            tmpLists.add(tmp);
        }
        finalLists.add(tmpLists);
    }

    info.setLists2(finalLists);
}
项目:Analyst    文件:ComparisonGLEventListener.java   
private void drawArrow(Vector2f from, Vector2f t) {
    Vector2f u = new Vector2f(t);
    u.sub(from);
    u.scale(vetctorScale);
    Vector2f to = new Vector2f(from);
    to.add(u);

    double angle = Math.toRadians(45);
    Vector2f v = new Vector2f(from);
    v.sub(to);
    v.normalize();
    if (!info.isRender()) {
        v.scale((float) Math.abs(2 * (zCameraPosition / 80f)));
    } else {
        v.scale(2);
    }

    v.add(to);
    double newX1 = to.x + (Math.cos(angle) * (v.x - to.x) + Math.sin(angle) * (v.y - to.y));
    double newY1 = to.y + (-Math.sin(angle) * (v.x - to.x) + Math.cos(angle) * (v.y - to.y));
    double newX2 = to.x + (Math.cos(-angle) * (v.x - to.x) + Math.sin(-angle) * (v.y - to.y));
    double newY2 = to.y + (-Math.sin(-angle) * (v.x - to.x) + Math.cos(-angle) * (v.y - to.y));

    gl.glBegin(GL_LINES);

    gl.glVertex2d(from.x, from.y);

    gl.glVertex2d(to.x, to.y);

    gl.glVertex2d(newX1, newY1);

    gl.glVertex2d(to.x, to.y);

    gl.glVertex2d(newX2, newY2);

    gl.glVertex2d(to.x, to.y);

    gl.glEnd();
}