當前位置: 首頁>>代碼示例>>Java>>正文


Java Vector3類代碼示例

本文整理匯總了Java中com.badlogic.gdx.math.Vector3的典型用法代碼示例。如果您正苦於以下問題:Java Vector3類的具體用法?Java Vector3怎麽用?Java Vector3使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Vector3類屬於com.badlogic.gdx.math包,在下文中一共展示了Vector3類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: BlockIf

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
private void BlockIf(int x1, int i1, Area area1, Block block1, float[] vertexOffset1, Vector3 areaOffset1,
		BlockTextureHandler textureHandler1, boolean ao1, int y1, int z1, float[] vertices1, Object maxX1,
		int MIN_AREA) {
	if (x1 < SIZE_BLOCKS - 1) {
		if (block1.renderFace(BlockFace.posX, area1.blocks[i1 + MAX_X_OFFSET])) {
			// light: byte is signed (-128 to 127) so & 0xFF to convert
			// to 0-255

			vertexOffset1 = createMaxX(areaOffset1, textureHandler1.getSide(BlockFace.posX),
					AmbientOcclusion.posX(area1, x1, y1, z1, ao1), x1, y1, z1,
					area1.light[i1 + MAX_X_OFFSET] & 0xFF, vertices1, vertexOffset1);
		}
	} else if (maxX1 == null || y1 > maxX1.maxY) {
		vertexOffset1 = createMaxX(areaOffset1, textureHandler1.getSide(BlockFace.posX),
				AmbientOcclusion.posX(area1, x1, y1, z1, ao1), x1, y1, z1, MAX_SUNLIGHT, vertices1, vertexOffset1);
	} else if (block1.renderFace(BlockFace.posX, maxX1.blocks[getRef(MIN_AREA, y1, z1)])) {
		vertexOffset1 = createMaxX(areaOffset1, textureHandler1.getSide(BlockFace.posX),
				AmbientOcclusion.posX(area1, x1, y1, z1, ao1), x1, y1, z1,
				maxX1.light[getRef(MIN_AREA, y1, z1)] & 0xFF, vertices1, vertexOffset1);
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:22,代碼來源:BlockRenderType.java

示例2: getDebugString

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
public static String getDebugString() {
  Vector3 p = Cubes.getClient().player.position;
  ms.addValue(Gdx.graphics.getRawDeltaTime() * 1000f);

  builder.setLength(brandingDebugLength);
  builder.append("FPS:").append(Gdx.graphics.getFramesPerSecond()).append(" MS:").append(twoDP.format(ms.getMean())).append(" MEM:").append(Compatibility.get().getFreeMemory()).append("MB").append(lineSeparator);
  builder.append("TPS C:").append(Cubes.getClient().ticksPerSecond.last()).append(" A:").append(oneDP.format(Cubes.getClient().ticksPerSecond.average()));
  if (Cubes.getServer() != null) builder.append(" S:").append(Cubes.getServer().ticksPerSecond.last()).append(" A:").append(oneDP.format(Cubes.getServer().ticksPerSecond.average()));
  builder.append(lineSeparator);
  builder.append("POS X:").append(twoDP.format(p.x)).append("(").append(CoordinateConverter.area(p.x)).append(")").append(" Y:").append(twoDP.format(p.y)).append("(").append(CoordinateConverter.area(p.y)).append(")").append(" Z:").append(twoDP.format(p.z)).append("(").append(CoordinateConverter.area(p.z)).append(")").append(lineSeparator);
  builder.append("DIR X:").append(twoDP.format(Cubes.getClient().player.angle.x)).append(" Y:").append(twoDP.format(Cubes.getClient().player.angle.y)).append(" Z:").append(twoDP.format(Cubes.getClient().player.angle.z)).append(lineSeparator);
  builder.append("R A:").append(AreaRenderer.renderedThisFrame).append(" M:").append(AreaRenderer.renderedMeshesThisFrame).append(" D:").append(Settings.getIntegerSetting(Settings.GRAPHICS_VIEW_DISTANCE));
  if (Settings.getBooleanSettingValue(Settings.GRAPHICS_FOG)) builder.append(" FOG");
  if (AmbientOcclusion.isEnabled()) builder.append(" AO");
  builder.append(lineSeparator);
  if (glProfiler) {
    builder.append("TC:").append(LastFrame.totalCalls).append(" DG:").append(LastFrame.drawCalls).append(" TB:").append(LastFrame.textureBindings).append(" SS:").append(LastFrame.shaderSwitches).append(" VC:").append(LastFrame.vertexCount()).append(lineSeparator);
  }
  builder.append("W B:").append(getBlockLight()).append(" S:").append(getSunlight()).append(" T:").append(Cubes.getClient().world.getTime());
  BlockIntersection blockIntersection = BlockIntersection.getBlockIntersection(Cubes.getClient().player.position, Cubes.getClient().player.angle, Cubes.getClient().world);
  if (blockIntersection != null && blockIntersection.getBlock() != null) {
    builder.append(lineSeparator).append("B ID:").append(blockIntersection.getBlock().id).append(" M:").append(blockIntersection.getBlockMeta());
  }
  return builder.toString();
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:26,代碼來源:ClientDebug.java

示例3: setCameraBoundary

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
private void setCameraBoundary( float startX, float startY, float width, float height) {
    Vector3 position = _camera.position;
    if (position.x < startX) {
        position.x = startX;
    }
    if (position.y < startY) {
        position.y = startY;
    }
    if (position.x > startX + width) {
        position.x = startX + width;
    }
    if (position.y > startY + height) {
        position.y = startY + height;
    }
    _camera.position.set(position);
    _camera.update();
}
 
開發者ID:JoakimRW,項目名稱:ExamensArbeteTD,代碼行數:18,代碼來源:CameraMovementSystem.java

示例4: Game3DService

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
public Game3DService(
			SpriteBatch batch,
			IGameAsset asset,
			BaseGameSetting baseGameSetting,
			ISceneManager sceneManager,
			CameraManager cameraManager,
			ShaderManager shaderManager,
			LightManager lightManager)
{
	super(batch, asset, baseGameSetting, null, sceneManager);

	this.cameraManager = cameraManager;
	this.shaderManager = shaderManager;
	this.lightManager = lightManager;
	
	if(this.cameraManager == null){
		this.cameraManager = new CameraManager();
	}
	if(this.shaderManager == null){
		this.shaderManager = new ShaderManager();
	}
	if(this.lightManager == null){
		this.lightManager = new LightManager(new Vector3(0.1f, 0.1f, 0.1f));
	}
}
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:26,代碼來源:Game3DService.java

示例5: preRender

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
/**
 * Call right before starting render stage of Scene 3D
 */
protected void preRender() {
	//Create default member for managers if the managers don't have any member. 
	if(camera.count() == 0)
	{
		camera.add("default", new FreeCamera(70, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), new Vector3(0, 5, 5), 0,135));
		camera.setActiveCamera("default");
	}
	if(light.count() == 0 && Game.isSupportOpenGL20)
	{
		light.addBaseLight("default", new DirectionLight(new Vector3(1, 1, 1), new Vector3(1, 1, -1)));
	}
	if(shader.count() == 0 && Game.isSupportOpenGL20)
	{
		String vs = loadShaderFile("effect/default-vs.glsl");
		String fs = loadShaderFile("effect/default-fs.glsl");
		ShaderProgram s = new ShaderProgram(vs , fs);
		if(!s.isCompiled())
		{
			throw new GdxRuntimeException("Cannot compile default shader");
		}
		shader.add("default", s);
		shader.setActiveShader("default");
	}
}
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:28,代碼來源:BaseGameScene3D.java

示例6: LevelScreen

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
public LevelScreen(String mapName, float rot) {
    this.rot = rot;
    this.mapName = mapName;
    this.inputMapper = new InputMapper(AL.getInputConfig());

    inputMapper.registerInputHanlder(IInputConfig.InputKeys.up, new MoveEventHandler(new Vector2(0, 1)));
    inputMapper.registerInputHanlder(IInputConfig.InputKeys.down, new MoveEventHandler(new Vector2(0, -1)));
    inputMapper.registerInputHanlder(IInputConfig.InputKeys.right, new MoveEventHandler(new Vector2(1, 0)));
    inputMapper.registerInputHanlder(IInputConfig.InputKeys.left, new MoveEventHandler(new Vector2(-1, 0)));

    inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability1, new AbillityEventHandler(Character.ABILITY_1));
    inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability2, new AbillityEventHandler(Character.ABILITY_2));
    inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability3, new AbillityEventHandler(Character.ABILITY_3));
    inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability4, new AbillityEventHandler(Character.ABILITY_4));
    inputMapper.registerInputHanlder(IInputConfig.InputKeys.trait, new AbillityEventHandler(Character.TRAIT));

    rotationMatrix = new Matrix4().rotate(Vector3.X, rot);
    cameraVector = new Vector3(0, 1, 1);
    cameraVector.mul(rotationMatrix);
    invRotationMatrix = rotationMatrix.cpy().inv();
    lastMousePos = new Vector2(Gdx.input.getX(), Gdx.input.getY());
    tempVec = new Vector3();
}
 
開發者ID:EtherWorks,項目名稱:arcadelegends-gg,代碼行數:24,代碼來源:LevelScreen.java

示例7: GameCenter

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
public GameCenter(Chat game){
  this.game = game;

  /*Camera Settings*/
  camera = new OrthographicCamera();
  camera.setToOrtho(false,480,800);
  camera.position.set(480/2,800/2,0);

  /*Button Areas*/
  wordTiles = new Rectangle(480/2-250/2,800/2,250,55);
  Arkanoid = new Rectangle(480/2-250/2,800/2-60,250,55);
  WordCrush = new Rectangle(480/2-250/2,800/2-120,250,55);
  EndlessRoad = new Rectangle(480/2-250/2,800/2-180,250,55);
  bottone4 = new Rectangle(480/2-250/2,800/2-240,250,55);
  buttonTexture = new Texture("green_button00.png");
  touch = new Vector3();
}
 
開發者ID:curiosone-bot,項目名稱:curiosone-app,代碼行數:18,代碼來源:GameCenter.java

示例8: read

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
@Override
public OrthographicCamera read(Kryo kryo, Input input, Class<OrthographicCamera> type) {
    OrthographicCamera camera = new OrthographicCamera();
    Vector3 position = kryo.readObject(input, Vector3.class);
    Vector3 direction = kryo.readObject(input, Vector3.class);
    Vector3 up = kryo.readObject(input, Vector3.class);
    camera.position.set(position);
    camera.direction.set(direction);
    camera.up.set(up);
    camera.near = input.readFloat();
    camera.far = input.readFloat();
    camera.viewportWidth = input.readFloat();
    camera.viewportHeight = input.readFloat();
    camera.zoom = input.readFloat();
    camera.update();
    return camera;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:18,代碼來源:OrthographicCameraSerializer.java

示例9: draw

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
@Override
public void draw(Batch batch) {
    final float dt = Gdx.graphics.getDeltaTime();
    fallSpeed += fallAcceleration * dt;
    pos.y -= fallSpeed * dt;

    cellColor.set(
            cellColor.r, cellColor.g, cellColor.b,
            Math.max(cellColor.a - COLOR_SPEED * dt, 0.0f)
    );
    dropColor.set(
            cellColor.r, cellColor.g, cellColor.b,
            Math.min(dropColor.a + COLOR_SPEED * dt, 1.0f)
    );

    Cell.draw(cellColor, batch, pos.x, pos.y, cellSize);
    Cell.draw(dropTexture, dropColor, batch, pos.x, pos.y, cellSize);

    final Vector3 translation = batch.getTransformMatrix().getTranslation(new Vector3());
    dead = translation.y + pos.y + dropTexture.getHeight() < 0;
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:22,代碼來源:WaterdropEffect.java

示例10: VRCamera

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
public VRCamera(int width, int height, int viewportWidth, int viewportHeight) {
    leftCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
    rightCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
    leftBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
    rightBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
    leftTexture = new TextureRegion();
    rightTexture = new TextureRegion();
    batch = new SpriteBatch();
    this.width = width;
    this.height = height;
    this.viewportWidth = viewportWidth;
    this.viewportHeight = viewportHeight;
    tmpVector3 = new Vector3();
    position = new Vector3(250, 20, 250);
    positionLeft = new Vector3(249.5f, 20, 250);
    positionRight = new Vector3(250.5f, 20, 250);
    direction = new Vector3();
    up = new Vector3(0, 1, 0);
    eyeDistance = 0.5f;
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:21,代碼來源:VRCamera.java

示例11: preventNoclip

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
@EventHandler
public void preventNoclip(PlayerMovementEvent event) {
	Player player = event.getPlayer();
	Vector3 pos = event.newPosition;
	if (world.getArea(CoordinateConverter.area(pos.x), CoordinateConverter.area(pos.z)) != null
			&& !event.isCanceled()) {
		int blockX = CoordinateConverter.block(pos.x);
		int blockZ = CoordinateConverter.block(pos.z);
		int minBlockY = CoordinateConverter.block(pos.y - player.height);
		int maxBlockY = CoordinateConverter.block(pos.y + 0.2f);
		for (int y = minBlockY; y <= maxBlockY; y++) {
			if (world.getBlock(blockX, y, blockZ) != null) {
				event.setCanceled(true);
				return;
			}
		}

		limit(pos, +r, 0, player.height);
		limit(pos, -r, 0, player.height);
		limit(pos, 0, +r, player.height);
		limit(pos, 0, -r, player.height);
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:24,代碼來源:PlayerCollision.java

示例12: checkVisibility

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
/**
	 * 相機包含測試
	 * @param transform 變換
	 * @param size 尺寸
	 * @param anchorPointInPoints 錨dian偏移
	 * @return
	 */
	public final boolean checkVisibility(final Matrix4 transform, final Size size, final Vector2 anchorPointInPoints) {
		final Director director = Director.getInstance();
	    //If draw to Rendertexture, return true directly.
	    // only cull the default camera. The culling algorithm is valid for default camera.
	    if (director.getRunningScene() == null) {// || (scene.getDefaultCamera() != Camera.getVisitingCamera())) {
	        return true;
	    }
	    
	    Vector2 temporigin = director.getVisibleOrigin();
	    Size tempsize = director.getVisibleSize();
	    Rect visiableRect = stackRect;
	    visiableRect.set(temporigin.x, temporigin.y, tempsize.width, tempsize.height);
	    
	    // transform center point to screen space
	    float hSizeX = size.width/2;
	    float hSizeY = size.height/2;
	    Vector3 v3p = stackVec3.set(hSizeX - anchorPointInPoints.x, hSizeY - anchorPointInPoints.y, 0);
	    v3p.mul(transform);
//	    transform.transformPoint(v3p);
	    Vector2 v2p = Camera.getVisitingCamera().projectGL(v3p);

	    // convert content size to world coordinates
	    final float[] val = transform.val;
	    float wshw = Math.max(Math.abs(hSizeX * val[Matrix4.M00] + hSizeY * val[Matrix4.M10]), 
	    		Math.abs(hSizeX * val[Matrix4.M00] - hSizeY * val[Matrix4.M10]));
//	    		std::max(fabsf(hSizeX * transform.m[0] + hSizeY * transform.m[4]), fabsf(hSizeX * transform.m[0] - hSizeY * transform.m[4]));
	    float wshh = Math.max(Math.abs(hSizeX * val[Matrix4.M01] + hSizeY * val[Matrix4.M11]), 
	    		Math.abs(hSizeX * val[Matrix4.M01] - hSizeY * val[Matrix4.M11])); 
//	    		std::max(fabsf(hSizeX * transform.m[1] + hSizeY * transform.m[5]), fabsf(hSizeX * transform.m[1] - hSizeY * transform.m[5]));
	    
	    // enlarge visible rect half size in screen coord
	    visiableRect.x -= wshw;
	    visiableRect.y -= wshh;
	    visiableRect.width += wshw * 2;
	    visiableRect.height += wshh * 2;
	    boolean ret = visiableRect.containsPoint(v2p);
//	    System.out.println("visiableRect = " + visiableRect + " pos = " + v2p);
	    return ret;
	}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:47,代碼來源:Renderer.java

示例13: intersectionIf

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
private void intersectionIf(Vector3 direction, int stepX, float tDeltaX, Vector3 origin, float tMaxX, int stepY, float tDeltaY, float tMaxY){
	if (direction.x > 0) {
		stepX = 1;
		tDeltaX = 1 / direction.x;
		tMaxX = (blockReference.blockX + 1 - origin.x) * tDeltaX;
	} else if (direction.x < 0) {
		stepX = -1;
		tDeltaX = 1 / -direction.x;
		tMaxX = (origin.x - blockReference.blockX) * tDeltaX;
	} else {
		stepX = 0;
		tDeltaX = 0;
		tMaxX = Float.MAX_VALUE;
	}

	if (direction.y > 0) {
		stepY = 1;
		tDeltaY = 1 / direction.y;
		tMaxY = (blockReference.blockY + 1 - origin.y) * tDeltaY;
	} else if (direction.y < 0) {
		stepY = -1;
		tDeltaY = 1 / -direction.y;
		tMaxY = (origin.y - blockReference.blockY) * tDeltaY;
	} else {
		stepY = 0;
		tDeltaY = 0;
		tMaxY = Float.MAX_VALUE;
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:30,代碼來源:BlockIntersection.java

示例14: drawRay

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
public static void drawRay(GL2 gl, Ray ray, FlyView view, float size) {
	Vector3 v = new Vector3(ray.direction);
	v.scl(size);

	gl.glBegin(GL.GL_LINES);
	gl.glVertex3d(view.getX(), view.getY()-0.1, view.getZ());
	gl.glVertex3d(view.getX()+v.x, view.getY()+v.y, view.getZ()+v.z);
	gl.glEnd();
}
 
開發者ID:Harium,項目名稱:propan-jogl-examples,代碼行數:10,代碼來源:StandardExample.java

示例15: setRotation3D

import com.badlogic.gdx.math.Vector3; //導入依賴的package包/類
/**
 * Sets the rotation (X,Y,Z) in degrees.
 * Useful for 3d rotations
 *
 * @warning The physics body doesn't support this.
 */
public void setRotation3D(Vector3 rotation) {
	if (_rotationX == rotation.x && _rotationY == rotation.y && _rotationZ == rotation.z)
	        return;
	    
	    _transformUpdated = _transformDirty = _inverseDirty = true;

	    _rotationX = rotation.x;
	    _rotationY = rotation.y;
	    _rotationZ = rotation.z;
	    
	    updateRotationQuat();
}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:19,代碼來源:Node.java


注:本文中的com.badlogic.gdx.math.Vector3類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。