Package javax.vecmath

Examples of javax.vecmath.Vector2f


            }
        };
    }

    public Vector2f screenToWorld(Vector2i screenPos) {
        Vector2f world = new Vector2f(screenPos.x / pixelSize.x, screenPos.y / pixelSize.y);
        world.add(windowPosition);
        return world;
    }
View Full Code Here


                windowSize.y *= (float) screenSize.y / screenSize.x;
            }
        }

        if ((windowSize.x > 0) && (windowSize.y > 0)) {
            pixelSize = new Vector2f(screenSize.x / windowSize.x, screenSize.y / windowSize.y);
        } else {
            pixelSize = new Vector2f();
        }
    }
View Full Code Here

            pixelSize = new Vector2f();
        }
    }

    public void zoom(float zoomX, float zoomY, Vector2i mousePos) {
        Vector2f mouseBefore = screenToWorld(mousePos);

        windowSize.x *= zoomX;
        windowSize.y *= zoomY;
        calculateSizes();

        Vector2f mouseAfter = screenToWorld(mousePos);

        windowPosition.x -= mouseAfter.x - mouseBefore.x;
        windowPosition.y -= mouseAfter.y - mouseBefore.y;
    }
View Full Code Here

    public Rect2f getRect() {
        return rect;
    }

    public Vector2f mid() {
        Vector2f mid = new Vector2f(rect.size());
        mid.scale(0.5f);
        mid.add(rect.min());
        return mid;

    }
View Full Code Here

            }
            if (activeConnectionStart != null) {
                drawConnection(canvas, activeConnectionStart, mousePos, Color.WHITE);
            }
            if (selectedNode != null) {
                Vector2f size = selectedNode.getSize();
                Vector2f topLeft = selectedNode.getPosition();
                Vector2f topRight = new Vector2f(topLeft);
                topRight.add(new Vector2f(size.x + .1f, 0));
                Vector2f bottomLeft = new Vector2f(topLeft);
                bottomLeft.add(new Vector2f(0, size.y + .1f));
                Vector2f bottomRight = new Vector2f(topLeft);
                bottomRight.add(new Vector2f(size.x + 0.1f, size.y + 0.1f));
                drawConnection(canvas, topLeft, topRight, Color.GREEN);
                drawConnection(canvas, topRight, bottomRight, Color.GREEN);
                drawConnection(canvas, bottomRight, bottomLeft, Color.GREEN);
                drawConnection(canvas, bottomLeft, topLeft, Color.GREEN);
            }
            if (newNode != null) {
                Vector2i screenStart = worldToScreen(mousePos);
                Vector2f worldEnd = new Vector2f(mousePos);
                worldEnd.add(newNode.getSize());
                Vector2i screenEnd = worldToScreen(worldEnd);
                canvas.drawWidget(newNode, Rect2i.createFromMinAndMax(screenStart, screenEnd));
            }

            canvas.setDrawOnTop(false);
View Full Code Here

        canvas.drawLine(s.x, s.y, e.x, e.y, color);

    }

    private void drawConnection(Canvas canvas, Port from, Vector2f to, Color color) {
        Vector2f start = new Vector2f(from.node.getPosition());
        start.add(from.mid());
        drawConnection(canvas, start, to, color);
    }
View Full Code Here

        start.add(from.mid());
        drawConnection(canvas, start, to, color);
    }

    private void drawConnection(Canvas canvas, Port from, Port to, Color color) {
        Vector2f start = new Vector2f(from.node.getPosition());
        start.add(from.mid());
        Vector2f end = new Vector2f(to.node.getPosition());
        end.add(to.mid());
        drawConnection(canvas, start, end, color);
    }
View Full Code Here

                parent.setTarget(copyRenderable.getInputPort());
                nodeToLayout = parent.node;
            } else {
                nodeToLayout = copyRenderable;
            }
            Vector2f oldPos = nodeToLayout.getPosition();
            tree.layout(nodeToLayout);
            oldPos.sub(nodeToLayout.getPosition());
            nodeToLayout.move(oldPos);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

            parent.setTarget(copyRenderable.getInputPort());
            nodeToLayout = parent.node;
        } else {
            nodeToLayout = copyRenderable;
        }
        Vector2f oldPos = nodeToLayout.getPosition();
        tree.layout(nodeToLayout);
        oldPos.sub(nodeToLayout.getPosition());
        nodeToLayout.move(oldPos);
    }
View Full Code Here

                        String[] floats = prefixSplit[1].trim().split("\\s+", 4);
                        if (floats.length < 2 || floats.length > 3) {
                            throw new IOException("Bad statement");
                        }
                        // Need to flip v coord, apparently
                        rawTexCoords.add(new Vector2f(Float.parseFloat(floats[0]), Float.parseFloat(floats[1])));
                        break;
                    }
                    // Vertex normal
                    case "vn": {
                        String[] floats = prefixSplit[1].trim().split("\\s+", 4);
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector2f

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.