当前位置: 首页>>代码示例>>Java>>正文


Java Vector2f类代码示例

本文整理汇总了Java中com.jme.math.Vector2f的典型用法代码示例。如果您正苦于以下问题:Java Vector2f类的具体用法?Java Vector2f怎么用?Java Vector2f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Vector2f类属于com.jme.math包,在下文中一共展示了Vector2f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pickDynamicPhysics

import com.jme.math.Vector2f; //导入依赖的package包/类
/**
 * Return this closest dynamic physics node, from the camera, that intersects the ray leaving the screen at location
 * @param pickAt
 * @return
 */
public PhysicsComponent pickDynamicPhysics(Vector2f location)
{
	Ray pickRay = new Ray();
	DisplaySystem.getDisplaySystem().getPickRay(location, StateManager.IS_AWT_MOUSE, pickRay);
	///PickResults res = new TrianglePickResults();
//	res.setCheckDistance(true);
	ArrayList<ModelIntersectionData> results = new ArrayList<ModelIntersectionData>();
	this.world.getSpatial().intersectRay(pickRay, results, true);
	for(ModelIntersectionData d:results)
	{
		PhysicsComponent comp = world.getComponent((SpatialModel)d.getModel());
		if(comp==null && d.getModel()!=null)
		{
			comp = world.getComponent((SpatialModel)d.getModel().getParent());
		}
		if(comp!=null)
		{
			return comp;
		}
	}
	return null;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:28,代码来源:PhysicsInteractionManager.java

示例2: componentMovedWorld

import com.jme.math.Vector2f; //导入依赖的package包/类
protected void componentMovedWorld(HUDComponent2D component) {
    if (logger.isLoggable(Level.FINEST)) {
        logger.finest("moving HUD component in world: " + component);
    }

    HUDComponentState state = (HUDComponentState) hudStateMap.get(component);
    if (state == null) {
        return;
    }

    HUDView3D view = state.getWorldView();
    if (view != null) {
        Vector3f worldLocation = component.getWorldLocation();
        view.setOffset(new Vector2f(worldLocation.x, worldLocation.y));
        view.applyDeltaTranslationUser(worldLocation);
    }
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:18,代码来源:WonderlandHUDComponentManager.java

示例3: componentViewChanged

import com.jme.math.Vector2f; //导入依赖的package包/类
protected void componentViewChanged(HUDComponent2D component) {
    if (logger.isLoggable(Level.FINEST)) {
        logger.fine("changing HUD component view: " + component);
    }

    HUDComponentState state = (HUDComponentState) hudStateMap.get(component);
    if (state == null) {
        return;
    }

    HUDView2D view = state.getView();
    if (component.getDisplayMode().equals(DisplayMode.HUD)) {
        // moving to HUD
        view.setLocationOrtho(new Vector2f(component.getX(), component.getY()), false);
        view.setOrtho(true);
    } else {
        // moving to world
        // position HUD in x, y
        Vector3f worldLocation = component.getWorldLocation();
        view.setOffset(new Vector2f(worldLocation.x, worldLocation.y));
        view.applyDeltaTranslationUser(worldLocation);
        view.setOrtho(false);
    }
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:25,代码来源:WonderlandHUDComponentManager.java

示例4: mouseButton

import com.jme.math.Vector2f; //导入依赖的package包/类
public boolean mouseButton(int button, boolean pressed, int x, int y) {
	if(button == 0 && pressed)
	{
		
		PhysicsComponent comp = interactionManager.pickDynamicPhysics(new Vector2f(x,y));
		if(comp!=null)
		{
			spring.setTarget(comp.getParent());
		}else
		{
			spring.setTarget(null);
			return  StateManager.getToolPool().getCameraTool().mouseButton(button, pressed, x, y);
		}
	}else if(button ==0 &! pressed)
	{
		spring.setTarget(null);
		return StateManager.getToolPool().getCameraTool().mouseButton(button, pressed, x, y);
	}
	return true;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:21,代码来源:PhysicsTool.java

示例5: App2D

import com.jme.math.Vector2f; //导入依赖的package包/类
/**
 * Create a new instance of App2D with the given name.
 *
 * @param name The name of the app.
 * @param controlArb The control arbiter to use. Must be non-null.
 * @param pixelScale The size of the window pixels in world coordinates.
 */
public App2D(String name, ControlArb controlArb, Vector2f pixelScale) {
    this.name = name;
    if (controlArb == null) {
        throw new RuntimeException("controlArb argument must be non-null.");
    }
    this.controlArb = controlArb;
    this.pixelScale = pixelScale;
    focusEntity = new Entity("App focus entity for app " + getName());

    synchronized(apps) {
        apps.add(this);
    }

    viewSet = new View2DSet(this);
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:23,代码来源:App2D.java

示例6: buildSpatial

import com.jme.math.Vector2f; //导入依赖的package包/类
@Override
protected Spatial buildSpatial() {
	Vector3f[] vertices = new Vector3f[2];
	vertices[0] = new Vector3f(0,0,0);
	vertices[1] = new Vector3f(1,0,0);
	
	Vector3f[] normals = new Vector3f[]{Vector3f.UNIT_Y,Vector3f.UNIT_Y};

	Vector2f[] textureCoords = new Vector2f[2];
	textureCoords[0] = new Vector2f(0,0);
	textureCoords[1] = new Vector2f(1,1);
	
	ColorRGBA[] colors = null;// new ColorRGBA[]{startColor,endColor};
	line = new Line("Grapple Beam",vertices,normals, colors,textureCoords);
	line.setLineWidth(4f);
	line.setCullMode(SceneElement.CULL_NEVER);
	line.updateRenderState();
	
	line.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
	line.setLightCombineMode(LightState.OFF);
	line.setTextureCombineMode(TextureState.REPLACE);
	line.setModelBound(new BoundingBox());
	return line;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:25,代码来源:LineModel.java

示例7: setBounds

import com.jme.math.Vector2f; //导入依赖的package包/类
public void setBounds(Vector2f start, Vector2f end)
{
	
	Vector2f topLeft = new Vector2f( (start.x < end.x)? start.x:end.x,(start.y > end.y)? start.y:end.y);
	Vector2f bottomRight = new Vector2f( (start.x > end.x)? start.x:end.x,(start.y < end.y)? start.y:end.y);
	if ((bottomRight.x - topLeft.x) <= FastMath.FLT_EPSILON ||(topLeft.y - bottomRight.y) <= FastMath.FLT_EPSILON )
	{
		model.setVisible(false);
		
	}else
		model.setVisible(engaged && true);
	model.getLocalScale().set(400,100,1);
	model.getLocalScale().set(FastMath.abs( topLeft.x - bottomRight.x),FastMath.abs( topLeft.y - bottomRight.y),1f);
	model.getLocalTranslation().setX(topLeft.x + model.getLocalScale().x/2f);
	model.getLocalTranslation().setY(topLeft.y- model.getLocalScale().y/2f);
	model.refreshLockedData();
	model.updateWorldData();
	//System.out.println(model.getSpatial().getParent() + "\t"+  engaged + "\t" + model.getWorldTranslation() + "\t" + model.getWorldScale()) ;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:20,代码来源:BoxSelectionEffect.java

示例8: WindowXrw

import com.jme.math.Vector2f; //导入依赖的package包/类
/**
 * Create a new WindowXrw instance and its "World" view.
 *
 * @param app The application to which this window belongs.
 * @param x The X11 x coordinate of the top-left corner window.
 * @param y The X11 y coordinate of the top-left corner window.
 * @param borderWidth The X11 border width.
 * @param decorated Whether the window is decorated with a frame.
 * @param pixelScale The size of the window pixels.
 * @param wid The X11 window ID.
 * @throws Instantiation if the window cannot be created.
 */
WindowXrw(App2D app, int x, int y, int width, int height, int borderWidth,
        boolean decorated, Vector2f pixelScale, int wid)
        throws InstantiationException {

    super(app, width, height, decorated, borderWidth, pixelScale,
            "WindowXrw " + wid + " for app " + app.getName());

    this.wid = wid;

    // Determine whether this window is transient for another
    // TODO: not yet implemented
    int transientForWid = ((AppXrw)app).getTransientForWid(wid);
    if (transientForWid != 0) {
        winTransientFor = ((AppXrw)app).getWindowForWid(transientForWid);
    }

    setScreenPosition(x, y);

    // TODO: disable resize corner until bugs are fixed
    setUserResizable(true);
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:34,代码来源:WindowXrw.java

示例9: HUDWindow

import com.jme.math.Vector2f; //导入依赖的package包/类
public HUDWindow(HUD hud, HUDApp2D app, Type type, Window2D parent,
                 int width, int height, boolean decorated,
                 Vector2f pixelScale, String name)
{
    super (app, type, parent, width, height, decorated, pixelScale, name);
    this.hud = hud;
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:8,代码来源:HUDWindow.java

示例10: getLocation

import com.jme.math.Vector2f; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public Vector2f getLocation(HUDComponent component) {
    Vector2f location = new Vector2f();

    if ((component != null) && (hudViewMap.containsKey(component))) {
        location.set((float) component.getLocation().getX(),
                (float) component.getLocation().getY());
    }

    return location;
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:14,代码来源:HUDAbsoluteLayoutManager.java

示例11: HUDApp2D

import com.jme.math.Vector2f; //导入依赖的package包/类
/**
 * Create a new instance of HUDApp2D with a default name.
 *
 * @param controlArb The control arbiter to use. null means that all users can control at the same time.
 * @param pixelScale The size of the window pixels in world coordinates.
 */
public HUDApp2D(HUD hud, ControlArb controlArb, Vector2f pixelScale) {
    super(controlArb, pixelScale);

    this.hud = hud;

    controlArb.setApp(this);
    controlArb.takeControl();
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:15,代码来源:HUDApp2D.java

示例12: relayout

import com.jme.math.Vector2f; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void relayout(HUDComponent component) {
    int hudWidth = hud.getWidth();
    int hudHeight = hud.getHeight();

    HUDComponent2D component2D = (HUDComponent2D) component;
    Vector2f positionPercent = positionMap.get(component2D);
    if (positionPercent == null) {
        logger.warning("no position for component: " + component2D);
        return;
    }
    float compX = hud.getX() + positionPercent.x * hudWidth;
    float compY = hud.getY() + positionPercent.y * hudHeight;

    HUDView2D view = (HUDView2D) hudViewMap.get(component2D);
    float viewWidth = view.getDisplayerLocalWidth();
    float viewHeight = view.getDisplayerLocalHeight();

    if (hud.getX() + hudWidth - (compX + viewWidth) < MIN_RIGHT_MARGIN) {
        // component bumped right edge of HUD, move it to be visible
        compX = hud.getX() + hudWidth - viewWidth - MIN_RIGHT_MARGIN;
    }
    if (compX < hud.getX() + MIN_LEFT_MARGIN) {
        // component bumped left edge of HUD
        compX = hud.getX() + MIN_LEFT_MARGIN;
    }
    if (compY < hud.getY() + MIN_BOTTOM_MARGIN) {
        // component bumped bottom edge of HUD
        compY = hud.getY() + MIN_BOTTOM_MARGIN;
    }
    if (hud.getY() + hudHeight - (compY + viewHeight) < MIN_TOP_MARGIN) {
        // component bumped top edge of HUD
        compY = hud.getY() + hudHeight - viewHeight - MIN_TOP_MARGIN;
    }

    component2D.setLocation((int) compX, (int) compY);
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:41,代码来源:HUDCompassLayoutManager.java

示例13: setPosition

import com.jme.math.Vector2f; //导入依赖的package包/类
public void setPosition(float x, float y) {
	if(target == null)
		return;
		//System.out.println(dist);
	//setPosition(new Vector3f(5,5,0));
//	setPosition(new Vector3f(x,y,dist));
	setPosition( DisplaySystem.getDisplaySystem().getWorldCoordinates(new Vector2f(x,y), dist));
	
}
 
开发者ID:sambayless,项目名称:golems,代码行数:10,代码来源:OdeSpringController.java

示例14: Window2D

import com.jme.math.Vector2f; //导入依赖的package包/类
/**
 * Create an instance of Window2D with the given name. The first such window
 * created for an app becomes the primary window. Subsequent windows are
 * secondary windows.
 * @param app The application to which this window belongs.
 * @param width The window width (in pixels).
 * @param height The window height (in pixels).
 * @param decorated Whether the window is top-level (e.g. is decorated) with
 * a frame.
 * @param pixelScale The size of the window pixels.
 * @param name The name of the window.
 * @param surface The drawing surface on which the creator will draw
 */
public Window2D(App2D app, int width, int height, boolean decorated,
        Vector2f pixelScale, String name, DrawingSurface surface) {

    if (width <= 0 || height <= 0) {
        throw new RuntimeException("Invalid window size");
    }

    this.app = app;
    this.size = new Dimension(width, height);
    this.decorated = decorated;
    if (pixelScale != null) {
        this.pixelScale = new Vector2f(pixelScale);
    }
    this.name = name;

    this.surface = surface;
    surface.setWindow(this);
   
    // Must occur before adding window to the app
    updateTexture();

    app.addWindow(this);

    changeMask = CHANGED_ALL;
    updateViews();
    updateFrames();
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:41,代码来源:Window2D.java

示例15: setOffset

import com.jme.math.Vector2f; //导入依赖的package包/类
/** 
 * Specify the first part the window's offset translation in local
 * coordinates from the center of the parent to the center of this window.
 * Note: setPixelOffset is the other part of the offset translation.The two
 * offsets are added to produce the effective offset. If the window has no
 * parent the offset is ignored. Any decoration is ignored.
 */
public void setOffset(Vector2f offset) {
    synchronized (this) {
        if (this.offset.x == offset.x && this.offset.y == offset.y) {
            return;
        }
        this.offset = (Vector2f) offset.clone();
        changeMask |= CHANGED_OFFSET;
        updateViews();
    }

    updateFrames();
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:20,代码来源:Window2D.java


注:本文中的com.jme.math.Vector2f类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。