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); } }
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(); }
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(); }
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)); } }
/** * 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"); } }
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(); }
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(); }
@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; }
@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; }
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; }
@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); } }
/** * 相机包含测试 * @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; }
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; } }
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(); }
/** * 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(); }
/** * Converts a Vector2 to node (local) space coordinates. The result is in Points. * <br>返回栈对象 * <b>pool object</b> */ public Vector2 convertToNodeSpace( Vector2 worldPoint) { Matrix4 tmp = getWorldToNodeTransform(); // System.out.println("temp = " + tmp); final Vector3 ret = poolVector3_1.set(worldPoint.x, worldPoint.y, 0); ret.mul(tmp); return poolVector2_1.set(ret.x, ret.y); }
/** convert the specified point in 3D world-space coordinates into the screen-space coordinates. * Origin point at left top corner in screen-space. * @param src The world-space position. * @return The screen-space position. <b>(pool object)</b/ */ public final Vector2 project(final Vector3 src) { Vector2 screenPos = pool_vec2; Size viewport = Director.getInstance().getWinSize(); Vector3 clipPos = pool_vec3; clipPos.set(src).mul(getViewProjectionMatrix()); float ndcX = clipPos.x; float ndcY = clipPos.y; screenPos.x = (ndcX + 1.0f) * 0.5f * viewport.width; screenPos.y = (1.0f - (ndcY + 1.0f) * 0.5f) * viewport.height; return screenPos; }
@Override public void draw(Batch batch) { dead = true; // assume we're death final Vector3 translation = batch.getTransformMatrix().getTranslation(new Vector3()); for (int i = shards.length; i-- != 0; ) { shards[i].draw(batch, Gdx.graphics.getDeltaTime()); dead &= translation.y + shards[i].pos.y + shards[i].size < 0; // all must be dead } }
public boolean touchDown (float x, float y, int pointer, int button) { Gdx.app.debug(ID, "GL: touchDown:\t" + x + ", " + y); touchPosition = new Vector3(x, y, 0); touchPosition = DS.camera.unproject(touchPosition); // game.movePony(touchPosition.x, touchPosition.y); if(game.CURRENT_STATE == GAME.STATE.PLAY) { game.fireBullet(touchPosition.x, touchPosition.y); game.debugNumBullets(); } return false; }
public Entity(Matrix4 transform, int hp, int health, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionShape shape, btCollisionWorld world, IntMap<Entity> entities, Map<String, Sound> sounds){ this.instance = instance; this.transform = transform; this.hp = hp; this.types = types; this.health = health; this.effects = effects; this.sounds = sounds; animation = new AnimationController(instance); this.instance.transform.set(transform); this.shape = shape; body = new btCollisionObject(); body.setCollisionShape(shape); body.setWorldTransform(this.instance.transform); this.world = world; tempVector = new Vector3(); tempVector2 = new Vector3(); this.entities = entities; tempQuaternion = new Quaternion(); quaternion = new Quaternion(); if(this instanceof Enemy || this instanceof Projectile) body.setCollisionFlags(body.getCollisionFlags()); int index = getNextIndex(); entities.put(index, this); body.setUserValue(index); world.addCollisionObject(body); boundingBox = instance.calculateBoundingBox(new BoundingBox()); //for(Node node: instance.nodes) //System.out.println(); }
/** init camera */ final boolean initDefault() { Size size = Director.getInstance().getWinSize(); //create default camera Director.Projection projection = Director.getInstance().getProjection(); // System.out.println("projection = " + projection); switch (projection) { case _2D: { // System.out.println("size = " + size); initOrthographic(size.width, size.height, -1024, 1024); setPosition3D(new Vector3(0.0f, 0.0f, 0.0f)); setRotation3D(new Vector3(0.f, 0.f, 0.f)); break; } case _3D: { float zeye = Director.getInstance().getZEye(); initPerspective(60, (float)size.width / size.height, 10, zeye + size.height / 2.0f); Vector3 eye = new Vector3(size.width/2, size.height/2.0f, zeye); Vector3 center = new Vector3(size.width/2, size.height/2, 0.0f); Vector3 up = new Vector3(0.0f, 1.0f, 0.0f); setPosition3D(eye); lookAt(center, up); break; } default: CCLog.engine(TAG, "unrecognized projection"); break; } return true; }
@Override public boolean mouseMoved(int screenX, int screenY) { if (_isPlacementMode) { mouseOverTintTiles(); ImmutableArray<Entity> towerEntitys = getAshleyEngine().getEntitiesFor(_towerFamily); Entity first = towerEntitys.first(); Vector3 mousePos = _gameCamera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0)); PositionComponent component = first.getComponent(PositionComponent.class); component.position.x = mousePos.x; component.position.y = mousePos.y; } return false; }
public BlockReference setFromVector3(Vector3 vector3) { this.blockX = CoordinateConverter.block(vector3.x); this.blockY = CoordinateConverter.block(vector3.y); this.blockZ = CoordinateConverter.block(vector3.z); this.hashCode = 0; return this; }
public Chapa(int x, int y) { position = new Vector3(x, y, 0); velocity = new Vector3(0, 0, 0); texture = new Texture("chapaanimation.png"); birdAnimation = new Animation(new TextureRegion(texture), 3, 0.5f); bounds = new Rectangle(x, y, texture.getWidth() / 3, texture.getHeight()); initSounds(); }
public static void setWorldTransform(Renderable renderable, boolean isMoon) { Vector3 pos = Cubes.getClient().player.position; int r = 512; float f = (float) (Cubes.getClient().world.getTime() - (World.MAX_TIME / 4)) / (float) World.MAX_TIME; if (isMoon) f += 0.5f; f %= 1; float x = (float) (pos.x + (r * Math.cos(f * 2 * Math.PI))); float y = (float) (pos.y + (r * Math.sin(f * 2 * Math.PI))); float z = pos.z; renderable.worldTransform.setToTranslation(x, y, z); renderable.worldTransform.scl(75f); renderable.worldTransform.rotate(Vector3.Z, (f - 0.25f % 1) * 360); }
public Farmer(int x, int y){ farmer = new Texture("FarmeronaTractor.png"); farmerAnimation = new Animation(new TextureRegion(farmer),8,0.5f); posFarmer = new Vector2(0,45); velocity = new Vector3(0,0,0); position = new Vector3(posFarmer.x,posFarmer.y,0); boundsFarmer = new Rectangle(posFarmer.x,posFarmer.y,110,410); }
public static Vector3 closestRayTest(btCollisionWorld world, ClosestRayResultCallback callback) { callback.getRayFromWorld(rayFrom); callback.getRayToWorld(rayTo); callback.setCollisionObject(null); callback.setClosestHitFraction(1f); world.rayTest(rayFrom, rayTo, callback); if (callback.hasHit()) { callback.getHitPointWorld(tmp); return tmp; } return null; }
/** when player has pressed a tower icon this method is called **/ public static boolean beginTowerPlacing(TowerType towerType) { EntityMapper mapper = new EntityMapper(); EntityInformation info = mapper.getTowerInformation(towerType); //_factory.getPlayer().getComponent(MoneyComponent.class).money; if(info.getCost() <= _factory.getPlayer().getComponent(MoneyComponent.class).money){ InputHandler.setTowerInfoForPlacement(true, towerType); Vector3 mousePos = _gameCamera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0)); _factory.createTowerEntity(towerType, mousePos.x, mousePos.y); return true; } return false; }
/** Called when the user dragged a finger over the screen and lifted it. Reports the last known velocity of the finger in * pixels per second. * @param velocityX velocity on x in seconds * @param velocityY velocity on y in seconds */ public boolean fling (float velocityX, float velocityY, int button) { // Gdx.app.debug(ID, "GL: fling (velocity):\t" + velocityX + ", " + velocityY); Vector3 flingVector = new Vector3(velocityX, velocityY, 0); flingVector = DS.camera.unproject(flingVector); Gdx.app.debug(ID, "GL: fling (velocity):\t" + flingVector.x + ", " + flingVector.y); // if(flingVector.x > FLING_THRESHOLD || flingVector.y > FLING_THRESHOLD) { // game.movePony2(flingVector.x, flingVector.y); // } return false; }
public CameraHandler(Camera cam, TDGalaxy game, CameraType cameraType) { this.game = game; this.cam = cam; tmp = new Vector3(0, 0,0 ); pivotPoint = new Vector3(0, 0, 0); this.cameraType = cameraType; }
public MainScreen(GftGame game) { this.game = game; this.guiCam = new OrthographicCamera(800, 480); this.guiCam.position.set(800 / 2, 480 / 2, 0); this.trainingBounds = new Rectangle(304, 155, 200, 39); this.helpBounds = new Rectangle(304, 113, 200, 39); this.creditsBounds = new Rectangle(304, 71, 200, 39); this.touchPoint = new Vector3(); }
@Override public int render(float[] vertices, int vertexOffset, Vector3 areaOffset, Block block, int meta, BlockTextureHandler textureHandler, Area area, int x, int y, int z, int i, boolean ao, Area minX, Area maxZ, Area minZ, Area maxX) { vertexOffset = CrossFaceVertices.createMinXMaxZ(areaOffset, textureHandler.getSide(null), x, y, z, area.light[i + MIN_Z_OFFSET] & 0xFF, vertices, vertexOffset, ao); vertexOffset = CrossFaceVertices.createMaxZMinX(areaOffset, textureHandler.getSide(null), x, y, z, area.light[i + MIN_Z_OFFSET] & 0xFF, vertices, vertexOffset, ao); vertexOffset = CrossFaceVertices.createMaxXMinZ(areaOffset, textureHandler.getSide(null), x, y, z, area.light[i + MIN_Z_OFFSET] & 0xFF, vertices, vertexOffset, ao); vertexOffset = CrossFaceVertices.createMinZMaxX(areaOffset, textureHandler.getSide(null), x, y, z, area.light[i + MIN_Z_OFFSET] & 0xFF, vertices, vertexOffset, ao); return vertexOffset; }
public FreeCamera(float fieldOfView, float viewportWidth, float viewportHeight,Vector3 position, float leftrightRot, float updownRot) { super(fieldOfView, viewportWidth, viewportHeight); this.position.set(position); this.leftrightRot = leftrightRot; this.updownRot =updownRot; UpdateViewMatrix(); }
@Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { lastMousePos.set(screenX, screenY); Ray ray = camera.getPickRay(screenX, screenY); Vector3 worldcoor = new Vector3(); Intersector.intersectRayPlane(ray, arcadeWorld.getMapHitbox(), worldcoor); log.debug("Clicked: " + worldcoor.toString()); Vector2 mapCoord = new Vector2(Math.round(worldcoor.x), Math.round(worldcoor.y)); switch (button) { case Input.Buttons.LEFT: CharacterComponent input = arcadeWorld.getEntityWorld().getComponentOf(playerEnt, CharacterComponent.class); input.move.set((int) mapCoord.x, (int) mapCoord.y); break; case Input.Buttons.RIGHT: Tile t = arcadeWorld.getTile(mapCoord); try { int id = t.getEntities().first(); input = arcadeWorld.getEntityWorld().getMapper(CharacterComponent.class).get(playerEnt); input.targetId = id; log.debug("{}", id); } catch (IllegalStateException ex) { } break; } return false; }
@Override public void write(Kryo kryo, Output output, Sphere sphere) { Vector3 center = sphere.center; output.writeFloat(center.x); output.writeFloat(center.y); output.writeFloat(center.z); output.writeFloat(sphere.radius); }
@Override public Vector2 getPositionOnWorld(float x, float y) { Vector3 vec = new Vector3(x, y, 0); y = Gdx.graphics.getHeight() - y - 1; vec.x = (2 * x) / Gdx.graphics.getWidth() - 1; vec.y = (2 * y) / Gdx.graphics.getHeight() - 1; vec.z = 2 * vec.z - 1; vec.prj(camera.invProjectionView); return new Vector2(vec.x, vec.y); }
public Projectile(Matrix4 transform, Vector3 velocity, int hp, int health, float speed, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance model, btCollisionShape shape, boolean isTower, btCollisionWorld world, IntMap<Entity> entities, float lifetime, Map<String, Sound> sounds) { super(transform, hp, health, types, effects, model, shape, world, entities, sounds); this.isTower = isTower; this.velocity = velocity; this.velocity.scl(speed); this.lifetime = lifetime; }
public Entity(UUID uuid, String id, Vector3 position, Vector3 angle) { this.uuid = uuid; this.id = id; this.position = position; this.motion = new Vector3(); this.angle = angle; this.tmpVector = new Vector3(); }
/** Sets the rotation to look at the give position, relative to the current position. * @param up The direction the top of the quad should be pointing. * @return This object for chaining. */ public Quad3D lookAt (Vector3 position, Vector3 up) { TMP3.set(position).sub(x, y, z).nor(); TMP1.set(up).crs(TMP3).nor(); TMP2.set(TMP3).crs(TMP1).nor(); rotation.setFromAxes(TMP1.x, TMP2.x, TMP3.x, TMP1.y, TMP2.y, TMP3.y, TMP1.z, TMP2.z, TMP3.z); return this; }
private void dirIf1(Vector3 vector3, int length, BlockFace blockFace){ if (vector3.x > 0) { if (vector3.x > length) { length = vector3.x; blockFace = BlockFace.posX; } } else if (vector3.x < 0) { if (-vector3.x > length) { length = -vector3.x; blockFace = BlockFace.negX; } } }