本文整理汇总了Java中com.badlogic.gdx.math.Intersector.intersectRayBoundsFast方法的典型用法代码示例。如果您正苦于以下问题:Java Intersector.intersectRayBoundsFast方法的具体用法?Java Intersector.intersectRayBoundsFast怎么用?Java Intersector.intersectRayBoundsFast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.Intersector
的用法示例。
在下文中一共展示了Intersector.intersectRayBoundsFast方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: touchEnklave
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
public boolean touchEnklave(PerspectiveCamera camera,int screenX,int screenY){
coordonate = null;
instanceModel.calculateBoundingBox(box).mul(instanceModel.transform);
box.getCenter(position);
box.getDimensions(dimensions);
Ray ray = camera.getPickRay(screenX,screenY);
// instanceModel.transform.getTranslation(position);
// position.add(box.getCenter(new Vector3()));
// Gdx.app.log("res"+ray.toString(),"position"+position);
if(Intersector.intersectRayBoundsFast(ray,box)){ // position, box.getDimensions(new Vector3()).len(), null)) {
coordonate = new SpaceCoordonate();
coordonate.x = Math.abs(Math.abs(position.x) - Math.abs(camera.position.x)) / (Gdx.graphics.getHeight() * 0.026f);
coordonate.y = Math.abs(Math.abs(position.y) - Math.abs(camera.position.y)) / (Gdx.graphics.getHeight() * 0.026f);
coordonate.z = -(Math.abs((Gdx.graphics.getHeight() * 0.033f) - Math.abs(camera.position.z)) / (Gdx.graphics.getHeight() * 0.026f));
if (box.getCenterX() < camera.position.x) {
coordonate.x = -coordonate.x;
}
if (box.getCenterY() < camera.position.y) {
coordonate.y = -coordonate.y;
}
return true;
}
return false;
}
示例2: getObject
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
public GameObject getObject (int screenX, int screenY) {
Ray ray = camera.getPickRay(screenX, screenY);
GameObject result = null;
float distance = -1;
for (ModelInstance item : instances) {
if(item instanceof GameObject){
GameObject gameObject = (GameObject) item;
if(gameObject.enabled){
Vector3 position = gameObject.transform.getTranslation(new Vector3());
gameObject.updateBox();
position.add(gameObject.center);
float dist2 = ray.origin.dst2(position);
if (distance >= 0f && dist2 > distance) continue;
if (Intersector.intersectRayBoundsFast(ray, gameObject.bounds)) {
result = gameObject;
distance = dist2;
}
}
}
}
return result;
}
示例3: touchDown
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
collisionRay = cam.getPickRay(x, y);
if(numPlayers >0 && Intersector.intersectRayBoundsFast(collisionRay, touchAreaP1) && GameInstance.getInstance().factorys.size>0) {
((FactoryProduction) GameInstance.getInstance().factorys.get(0)).button_held = true;
pointerP1 = pointer;
touchedP1 = true;
}
if(numPlayers >1 && Intersector.intersectRayBoundsFast(collisionRay, touchAreaP2) && GameInstance.getInstance().factorys.size>1) {
((FactoryProduction) GameInstance.getInstance().factorys.get(1)).button_held = true;
pointerP2 = pointer;
touchedP2 = true;
}
if(numPlayers >2 && Intersector.intersectRayBoundsFast(collisionRay, touchAreaP3) && GameInstance.getInstance().factorys.size>2) {
((FactoryProduction) GameInstance.getInstance().factorys.get(2)).button_held = true;
pointerP3 = pointer;
touchedP3 = true;
}
if(numPlayers >3 && Intersector.intersectRayBoundsFast(collisionRay, touchAreaP4) && GameInstance.getInstance().factorys.size>3) {
((FactoryProduction) GameInstance.getInstance().factorys.get(3)).button_held = true;
pointerP4 = pointer;
touchedP4 = true;
}
return false;
}
示例4: fillIntersectedBoxList
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
/**
* Checks for a intersections between chess piece bounding boxes and the
* pick ray. Stores the ones that intersect in a list.
*
* @param pieceGridPairs
* list of grid locations
* @param ray
* a ray from the camera position to the destination of the mouse
* click
*/
private void fillIntersectedBoxList(Array<GridLocation> pieceGridPairs, Ray ray) {
for (GridLocation pair : pieceGridPairs) {
if (pair.chessPiece != null) {
if (Intersector.intersectRayBoundsFast(ray, pair.chessPiece.getBoundingBox())) {
mIntersectedBoxList.add(pair);
}
}
}
}
示例5: touchDown
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
collisionRay = cam.getPickRay(x, y);
if (Intersector.intersectRayBoundsFast(collisionRay, collisionBack)) {
finished = true;
}
return false;
}
示例6: collidesWith
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
@Override
public Grid collidesWith(Ray ray, Vector3 intersection, float maxDistance) {
if (!visible || !inRange || !inLargeRange || !ableToCollide)
return null;
tmpRay.set(ray);
tmpRay.mul(inverseTransform);
Grid foundGrid = null;
if (!Intersector.intersectRayBoundsFast(tmpRay, boundingBox)) {
return null;
}
float diff = (float)Config.GRID_SIZE / 2f * 1.73f;
for (int i = 0; i < gridArray.size; i++) {
final Grid grid = gridArray.items[i];
if (!grid.checkBounds)
continue;
tmp.set(grid.x, grid.y, grid.z);
tmp.add(0.5f);
tmp.scl(Config.GRID_SIZE);
float myDist = tmpRay.origin.dst(tmp) - diff;
if (myDist * myDist > maxDistance) {
continue;
}
if (grid.collidesWith(tmpRay, intersection, maxDistance)) {
maxDistance = tmpRay.origin.dst2(intersection);
intersection.mul(transform);
foundGrid = grid;
}
}
return foundGrid;
}
示例7: collidesWith
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
@Override
public Grid collidesWith(Ray ray, Vector3 intersection, float maxDistance) {
if (!visible || !inRange || !inLargeRange || !ableToCollide)
return null;
tmpRay.set(ray);
tmpRay.mul(inverseTransform);
Grid foundGrid = null;
if (!Intersector.intersectRayBoundsFast(tmpRay, boundingBox)) {
return null;
}
float diff = (float)Config.GRID_SIZE / 2f * 1.73f;
if (singleGrid != null) {
if (!singleGrid.checkBounds)
return null;
tmp.set(singleGrid.x, singleGrid.y, singleGrid.z);
tmp.add(0.5f);
tmp.scl(Config.GRID_SIZE);
float myDist = tmpRay.origin.dst(tmp) - diff;
if (myDist * myDist > maxDistance) {
return null;
}
if (singleGrid.collidesWith(tmpRay, intersection, maxDistance)) {
maxDistance = tmpRay.origin.dst2(intersection);
intersection.mul(transform);
foundGrid = singleGrid;
}
}
return foundGrid;
}
示例8: display
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
updateControls(0);
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glClearColor(1f, 1f, 1f, 1);
//Transform by Aim
g.aimCamera(view.getAim());
//Draw Scene
g.setColor(Color.BLACK);
g.drawGrid(1, 150, 150);
gl.glTranslatef(position.x, position.y, position.z);
drawAxis(gl);
if (selected == X || collisionAxis == xAxis) {
gl.glColor3d(1.0, 1.0, 0.0);
} else {
gl.glColor3d(1.0, 0.0, 0.0);
}
g.drawBoundingBox(xAxis);
if (selected == Y || collisionAxis == yAxis) {
gl.glColor3d(1.0, 1.0, 0.0);
} else {
gl.glColor3d(0.0, 1.0, 0.0);
}
g.drawBoundingBox(yAxis);
if (selected == Z || collisionAxis == zAxis) {
gl.glColor3d(1.0, 1.0, 0.0);
} else {
gl.glColor3d(0.0, 0.0, 1.0);
}
g.drawBoundingBox(zAxis);
Ray ray = g.getCameraRay(mx, my);
if(drawRay) {
drawRay(gl, ray);
}
if (Intersector.intersectRayBoundsFast(ray, xAxis)) {
collisionAxis = xAxis;
} else if (Intersector.intersectRayBoundsFast(ray, yAxis)) {
collisionAxis = yAxis;
} else if (Intersector.intersectRayBoundsFast(ray, zAxis)) {
collisionAxis = zAxis;
} else if(selected == NONE) {
collisionAxis = NO_AXIS;
}
gl.glFlush();
}
示例9: display
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
updateControls(0);
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL().getGL2();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glClearColor(1f, 1f, 1f, 1);
//Transform by Aim
g.aimCamera(view.getAim());
//Draw Scene
g.setColor(Color.BLACK);
g.drawGrid(1, 150, 150);
gl.glPushMatrix();
gl.glMultMatrixf(transform.val, 0);
drawOriginalAxis(gl);
drawAxis(gl);
if (selected == AXIS_H || collisionAxis == vAxis) {
gl.glColor3d(1.0, 1.0, 0.0);
} else {
gl.glColor3d(1.0, 0.0, 0.0);
}
g.drawBoundingBox(vAxis);
if (selected == AXIS_V || collisionAxis == hAxis) {
gl.glColor3d(1.0, 1.0, 0.0);
} else {
gl.glColor3d(0.0, 1.0, 0.0);
}
g.drawBoundingBox(hAxis);
gl.glPopMatrix();
Ray ray = g.getCameraRay(mx, my);
if(drawRay) {
drawRay(gl, ray);
}
if (Intersector.intersectRayBoundsFast(ray, vAxis, transform)) {
collisionAxis = vAxis;
} else if (Intersector.intersectRayBoundsFast(ray, hAxis, transform)) {
collisionAxis = hAxis;
} else if(selected == NONE) {
collisionAxis = NO_AXIS;
}
gl.glFlush();
}
示例10: touchDown
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
collisionRay = cam.getPickRay(x, y);
if (cnt > 4 || countdown.finished)
return false;
// check if ship is activated
if (Intersector.intersectRayBoundsFast(collisionRay, p1.collision) && !p1.picked) {
p1.picked = true;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p2.collision) && !p2.picked) {
p2.picked = true;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p3.collision) && !p3.picked) {
p3.picked = true;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p4.collision) && !p4.picked) {
p4.picked = true;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p1.collisionPlayerSelect) && p1.picked && !p1.cpuSelect) {
p1.playerSelect = true;
p1.cpuSelect = false;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p2.collisionPlayerSelect) && p2.picked && !p2.cpuSelect) {
p2.playerSelect = true;
p2.cpuSelect = false;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p3.collisionPlayerSelect) && p3.picked && !p3.cpuSelect) {
p3.playerSelect = true;
p3.cpuSelect = false;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p4.collisionPlayerSelect) && p4.picked && !p4.cpuSelect) {
p4.playerSelect = true;
p4.cpuSelect = false;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p1.collisionCPUSelect) && p1.picked && !p1.playerSelect) {
p1.cpuSelect = true;
p1.playerSelect = false;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p2.collisionCPUSelect) && p2.picked && !p2.playerSelect) {
p2.cpuSelect = true;
p2.playerSelect = false;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p3.collisionCPUSelect) && p3.picked && !p3.playerSelect) {
p3.cpuSelect = true;
p3.playerSelect = false;
} else if (Intersector.intersectRayBoundsFast(collisionRay, p4.collisionCPUSelect) && p4.picked && !p4.playerSelect) {
p4.cpuSelect = true;
p4.playerSelect = false;
}
if (Intersector.intersectRayBoundsFast(collisionRay, collisionMusic)) {
if (cnt >= 1)
return false;
Preferences prefs = Gdx.app.getPreferences("paxbritannica");
prefs.putBoolean("music", !prefs.getBoolean("music"));
prefs.flush();
if(prefs.getBoolean("music")) {
if(Resources.getInstance().music == null) Resources.getInstance().reInit();
if(!Resources.getInstance().music.isPlaying()) {
Resources.getInstance().music.play();
Resources.getInstance().music.setLooping(true);
}
musicOnOff.setColor(1,1,1,0.5f);
} else {
Resources.getInstance().music.stop();
musicOnOff.setColor(1,1,1,0.1f);
}
}
if (Intersector.intersectRayBoundsFast(collisionRay, collisionHelp)) {
if (cnt >= 1)
return false;
countdown.finished = true;
changeToScreen = 0;
}
if (Intersector.intersectRayBoundsFast(collisionRay, collisionSettings)) {
if (cnt >= 1)
return false;
countdown.finished = true;
changeToScreen = 1;
}
return false;
}
示例11: process
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
@Override
protected void process(Entity e) {
if (!mouseMoved()) {
return;
}
Entity highlight = tagManager.getEntity("tileHighlight");
Tile[][] tiles = tilesMapper.get(e).get();
Ray ray = camera.getPickRay(Gdx.input.getX(), Gdx.input.getY());
boolean hovering = false;
for (int y = 0; y < tiles.length; y++) {
for (int x = 0; x < tiles[y].length; x++) {
BoundingBox boundingBox = new BoundingBox(new Vector3(0, 0, 0),
new Vector3(1, 1, 0));
Matrix4 transformation = new Matrix4();
transformation.translate(new Vector3(x, y, 0));
boundingBox.mul(transformation);
if (Intersector.intersectRayBoundsFast(ray, boundingBox)) {
if (tiles[y][x] != highlightedTile) {
// FIXME
// ModelDisplayable highlightDisplayable
// = (ModelDisplayable) displayableMapper.get(highlight).get();
// highlightDisplayable.updateTranslation(new Vector3(x, y, 0));
// highlight.edit().create(VisibilityComponent.class);
highlightedTile = tiles[y][x];
}
hovering = true;
break;
}
}
}
if (!hovering) {
highlightedTile = null;
highlight.edit().remove(VisibilityComponent.class);
}
}