本文整理汇总了Java中com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback类的典型用法代码示例。如果您正苦于以下问题:Java ClosestRayResultCallback类的具体用法?Java ClosestRayResultCallback怎么用?Java ClosestRayResultCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClosestRayResultCallback类属于com.badlogic.gdx.physics.bullet.collision包,在下文中一共展示了ClosestRayResultCallback类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: draw
import com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback; //导入依赖的package包/类
@Override
public void draw(Batch batch, float parentAlpha) {
batch.draw(texture, getX(), getY(), getWidth(), getHeight());
for(int i = 0; i < xCells; i++)
for(int j = 0; j < yCells; j++)
if(cells[i][j] != null) {
batch.draw(cells[i][j].texture, getX() + i * getWidth() / xCells, getY() + j * getHeight() / yCells, getWidth() / xCells, getHeight() / yCells);
if(cells[i][j].price > money.$)
batch.draw(cellX, getX() + i * getWidth() / xCells, getY() + j * getHeight() / yCells, getWidth() / xCells, getHeight() / yCells);
}
if (paused)
return;
if(Gdx.input.isTouched() && lastCell != null) {
Ray ray = camera.getPickRay(Gdx.input.getX(), Gdx.input.getY());
Vector3 pos = Tools.closestRayTest(btcollisionWorld, new ClosestRayResultCallback(ray.origin, new Vector3(ray.direction).setLength(9999).add(ray.origin)));
if(pos != null && Tools.closestRayTestObject(btcollisionWorld, new ClosestRayResultCallback(ray.origin, new Vector3(ray.direction).setLength(9999).add(ray.origin))).getUserValue() == 0) {
Vector3 vector = world.getVector(pos);
if(vector != null && ghost != null) {
ghost.transform.setToTranslation(pos);
ghost.transform.rotate(vector, 30);
}
if(ghost != null)
modelBatch.render(ghost, environment);
}
}
}
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:27,代码来源:PlacementWindow.java
示例2: create
import com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback; //导入依赖的package包/类
@Override
public void create () {
super.create();
instructions = "Tap a box to ray cast\nLong press to toggle debug mode\nSwipe for next test\nCtrl+drag to rotate\nScroll to zoom";
// Create the entities
world.add("ground", -7f, 0f, -7f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 1f);
for (int x = 0; x < BOXCOUNT_X; x++) {
for (int y = 0; y < BOXCOUNT_Y; y++) {
for (int z = 0; z < BOXCOUNT_Z; z++) {
world.add("box", BOXOFFSET_X + x, BOXOFFSET_Y + y, BOXOFFSET_Z + z).setColor(0.5f + 0.5f * (float)Math.random(),
0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
}
}
}
rayTestCB = new ClosestRayResultCallback(Vector3.Zero, Vector3.Z);
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:21,代码来源:RayCastTest.java
示例3: closestRayTestObject
import com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback; //导入依赖的package包/类
public static btCollisionObject closestRayTestObject(btCollisionWorld world, ClosestRayResultCallback callback) {
callback.getRayFromWorld(rayFrom);
callback.getRayToWorld(rayTo);
callback.setCollisionObject(null);
callback.setClosestHitFraction(1f);
world.rayTest(rayFrom, rayTo, callback);
if (callback.hasHit())
return callback.getCollisionObject();
return null;
}
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:11,代码来源:Tools.java
示例4: closestRayTest
import com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback; //导入依赖的package包/类
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;
}
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:13,代码来源:Tools.java
示例5: touchDown
import com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback; //导入依赖的package包/类
@Override
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
boolean result = false;
if (button == Buttons.LEFT) {
Ray ray = camera.getPickRay(screenX, screenY);
tmpV1.set(ray.direction).scl(10f).add(ray.origin);
ClosestRayResultCallback cb = new ClosestRayResultCallback(ray.origin, tmpV1);
world.collisionWorld.rayTest(ray.origin, tmpV1, cb);
if (cb.hasHit()) {
btRigidBody body = (btRigidBody)(cb.getCollisionObject());
if (body != null && !body.isStaticObject() && !body.isKinematicObject()) {
pickedBody = body;
body.setActivationState(Collision.DISABLE_DEACTIVATION);
cb.getHitPointWorld(tmpV);
tmpV.mul(body.getCenterOfMassTransform().inv());
pickConstraint = new btPoint2PointConstraint(body, tmpV);
btConstraintSetting setting = pickConstraint.getSetting();
setting.setImpulseClamp(30f);
setting.setTau(0.001f);
pickConstraint.setSetting(setting);
((btDynamicsWorld)world.collisionWorld).addConstraint(pickConstraint);
pickDistance = tmpV1.sub(camera.position).len();
result = true;
}
}
cb.dispose();
}
return result ? result : super.touchDown(screenX, screenY, pointer, button);
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:34,代码来源:RayPickRagdollTest.java
示例6: executeRayCast
import com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback; //导入依赖的package包/类
private void executeRayCast(Vector3 position, Vector3 end, RayResultCallback callback) {
raycastReport.reset();
world.rayTest(position, end, callback);
raycastReport.hit = callback.hasHit();
if (raycastReport.hit) {
float length = position.dst(end);
raycastReport.hitDistance = length * callback.getClosestHitFraction();
if (callback instanceof ClosestRayResultCallback) {
ClosestRayResultCallback cb = (ClosestRayResultCallback) callback;
Vector3 normal = tmp;
cb.getHitNormalWorld(tmp);
raycastReport.hitNormal.set(normal.x, normal.y, normal.z);
}
}
}
开发者ID:jrenner,项目名称:gdx-proto,代码行数:16,代码来源:Physics.java
示例7: clearResult
import com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback; //导入依赖的package包/类
private void clearResult(ClosestRayResultCallback result) {
result.setCollisionObject(null);
result.setClosestHitFraction(1f);
}
开发者ID:WarpOrganization,项目名称:warp,代码行数:5,代码来源:RayTestSolver.java
示例8: create
import com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback; //导入依赖的package包/类
@Override
public void create() {
logger.info("Setting up camera");
camera = new PerspectiveCamera(40, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
// camera.position.set(40f, 30f, 40f);
camera.position.set(45f, 29f, 73f);
// camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
// camera.position.set(4f, 3f, 4f);
camera.lookAt(0, 2f, 0);
camera.near = 1f;
camera.far = 500f;
camera.update();
cameraInputController = new CameraInputController(camera);
Gdx.input.setInputProcessor(cameraInputController);
// Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this)));
logger.info("Loading models");
models = new HashMap<>();
ModelBuilder builder = new ModelBuilder();
models.put("box", builder.createBox(5f, 5f, 5f,
new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));
G3dModelLoader loader = new G3dModelLoader(new JsonReader());
models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj")));
models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj")));
models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj")));
logger.info("Let there be light");
batch = new ModelBatch();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.6f, 0.6f, 0.6f, 1f));
environment.add(new DirectionalLight().set(0.3f, 0.3f, 0.3f, -5f, -3f, -1f));
environment.add(new DirectionalLight().set(0.2f, 0.2f, 0.2f, 5f, 8f, 0f));
environment.add(new DirectionalLight().set(0.7f, 0.7f, 0.7f, -3f, -2f, -5f));
logger.info("Initializing Bullet");
Bullet.init();
logger.info("Creating simulation");
// create world & stuff?
spokeAngles = new SpokeAngles();
// spokeAngles.create2l2t();
// spokeAngles.createCrowFoot();
// spokeAngles.createNx(3);
// spokeAngles.createPer3mutation(new int[]{3, 14, 5, 0, 7, 2, 9, 4, 11, 6, 13, 8, 15, 10, 1, 12}); // 3x as well!
// spokeAngles.createPermutation(new int[]{14, 2, 3, 15, 7, 5, 6, 10, 4, 9, 8, 11, 12, 0, 1, 13});
// spokeAngles.createPermutation(new int[]{2, 0, 1, 5, 3, 8, 10, 4, 12, 6, 11, 7, 9, 15, 13, 14});
// spokeAngles.createPermutation(new int[]{0, 15, 3, 2, 4, 9, 6, 7, 8, 5, 10, 11, 12, 13, 14, 1});
spokeAngles.createRandom();
// spokeAngles.createBack();
// spokeAngles.createSingel();
simulation = new Simulation("sim1", models, spokeAngles, true);
rayResultCallback = new ClosestRayResultCallback(new Vector3(), new Vector3());
rayResultCallback.setCollisionFilterGroup(SimulationConstants.RAY_GROUP);
logger.info("Setup complete");
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:69,代码来源:WheelRenderer.java
示例9: setCallbackRayPositions
import com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback; //导入依赖的package包/类
private static void setCallbackRayPositions(ClosestRayResultCallback cb, Vector3 from, Vector3 to) {
cb.setRayFromWorld(from);
cb.setRayToWorld(to);
}
开发者ID:jrenner,项目名称:gdx-proto,代码行数:5,代码来源:Physics.java
注:本文中的com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论