Java如何读取rbinfo文件_Java RigidBodyConstructionInfo類代碼示例

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

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

示例1: localCreateRigidBody

​點讚 3

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

private RigidBody localCreateRigidBody(float mass, Transform startTransform, CollisionShape shape) {

boolean isDynamic = (mass != 0f);

Vector3f localInertia = new Vector3f();

localInertia.set(0f, 0f, 0f);

if (isDynamic) {

shape.calculateLocalInertia(mass, localInertia);

}

DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);

rbInfo.additionalDamping = true;

RigidBody body = new RigidBody(rbInfo);

ownerWorld.addRigidBody(body);

return body;

}

開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:19,

示例2: localCreateRigidBody

​點讚 3

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

private RigidBody localCreateRigidBody(float mass, Transform startTransform, CollisionShape shape) {

boolean isDynamic = (mass != 0f);

Vector3f localInertia = new Vector3f();

localInertia.set(0f, 0f, 0f);

if (isDynamic) {

shape.calculateLocalInertia(mass, localInertia);

}

DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);

RigidBody body = new RigidBody(rbInfo);

ownerWorld.addRigidBody(body);

return body;

}

開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:18,

示例3: addCollisionObject

​點讚 3

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public RigidBody addCollisionObject(CollisionShape shape, float mass, Vector3f position, Vector3f velocity){

Transform startTransform = new Transform();

startTransform.setIdentity();

startTransform.origin.set(position);

boolean isDynamic = (mass != 0f);

Vector3f localInertia = new Vector3f(0, 0, 0);

if (isDynamic) {

shape.calculateLocalInertia(mass, localInertia);

}

// using motionstate is recommended, it provides

// interpolation capabilities, and only synchronizes

// 'active' objects

DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(

mass, myMotionState, shape, localInertia);

RigidBody body = new RigidBody(rbInfo);

//System.out.println(velocity);

//body.applyCentralForce(velocity);

body.setLinearVelocity(velocity);

dynamicsWorld.addRigidBody(body);

return body;

}

開發者ID:gama-platform,項目名稱:gama,代碼行數:27,

示例4: mkStaticGroundPlane

​點讚 3

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

protected void mkStaticGroundPlane(DynamicsWorld world) {

// floor

float mass = 0;

CollisionShape shape = new BoxShape(new Vector3f(L, 10, W));

Transform t = new Transform();

t.setIdentity();

t.origin.set(new Vector3f(p.x,p.y-10,p.z));

MotionState motionState = new DefaultMotionState(t);

RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(mass, motionState, shape);

RigidBody body = new RigidBody(info);

body.setFriction(1f);

body.setRestitution(.5f);

world.addRigidBody(body);

}

開發者ID:seemywingz,項目名稱:Kengine,代碼行數:17,

示例5: initializePhysics

​點讚 3

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

protected void initializePhysics(DynamicsWorld world){

t = new Transform();

t.setIdentity();

t.origin.set(new Vector3f(p.x,p.y,p.z));

Vector3f inertia = new Vector3f(0,0,0);

shape.calculateLocalInertia(p.mass,inertia);

shape.setLocalScaling(new Vector3f(p.size, p.size, p.size));

MotionState motionState = new DefaultMotionState(t);

RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(p.mass,motionState,shape,inertia);

body = new RigidBody(info);

body.setFriction(friction);

body.setDamping(linDamping, angDamping);

body.setAngularFactor(angularFactor);

body.setRestitution(restitution);

Scene.world.addRigidBody(body);

}

開發者ID:seemywingz,項目名稱:Kengine,代碼行數:18,

示例6: p3dRuler

​點讚 3

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public void p3dRuler(){

float length = 10/2f;

float width = 10/2f;

List vertices = new ArrayList();

vertices.add(new Vector3f(-length,0,-width));

vertices.add(new Vector3f(-length,0,width));

vertices.add(new Vector3f(length,0,width));

vertices.add(new Vector3f(length,0,-width));

Transform startTransform = new Transform();

startTransform.setIdentity();

Vector3f translate = new Vector3f();

startTransform.origin.set(translate);

CollisionShape shape = new ConvexHullShape(vertices);

Vector3f localInertia = new Vector3f(0f, 0f, 0f);

DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

RigidBodyConstructionInfo cInfo = new RigidBodyConstructionInfo(0f, myMotionState, shape, localInertia);

RigidBody body = new RigidBody(cInfo);

body.setGravity(new Vector3f(0,0,0));

pInterfaceWorld.addRigidBody(body);

//adding this to another dynamic world*interfaceworld*

}

開發者ID:Sivx,項目名稱:Sivx-3DDesktop,代碼行數:22,

示例7: createRigidBody

​點讚 3

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

private void createRigidBody(EntityRef entity) {

LocationComponent location = entity.getComponent(LocationComponent.class);

RigidBodyComponent rigidBody = entity.getComponent(RigidBodyComponent.class);

ConvexShape shape = getShapeFor(entity);

if (shape != null) {

float scale = location.getWorldScale();

shape.setLocalScaling(new Vector3f(scale, scale, scale));

Vector3f fallInertia = new Vector3f();

shape.calculateLocalInertia(rigidBody.mass, fallInertia);

RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(rigidBody.mass, new EntityMotionState(entity), shape, fallInertia);

RigidBody collider = new RigidBody(info);

collider.setUserPointer(entity);

updateKinematicSettings(rigidBody, collider);

RigidBody oldBody = entityRigidBodies.put(entity, collider);

physics.addRigidBody(collider, Lists.newArrayList(rigidBody.collisionGroup), rigidBody.collidesWith);

if (oldBody != null) {

physics.removeRigidBody(oldBody);

}

}

}

開發者ID:zoneXcoding,項目名稱:Mineworld,代碼行數:22,

示例8: BulletPhysics

​點讚 3

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public BulletPhysics(WorldProvider world) {

collisionGroupManager = CoreRegistry.get(CollisionGroupManager.class);

_broadphase = new DbvtBroadphase();

_broadphase.getOverlappingPairCache().setInternalGhostPairCallback(new GhostPairCallback());

_defaultCollisionConfiguration = new DefaultCollisionConfiguration();

_dispatcher = new CollisionDispatcher(_defaultCollisionConfiguration);

_sequentialImpulseConstraintSolver = new SequentialImpulseConstraintSolver();

_discreteDynamicsWorld = new DiscreteDynamicsWorld(_dispatcher, _broadphase, _sequentialImpulseConstraintSolver, _defaultCollisionConfiguration);

_discreteDynamicsWorld.setGravity(new Vector3f(0f, -15f, 0f));

blockEntityRegistry = CoreRegistry.get(BlockEntityRegistry.class);

CoreRegistry.get(EventSystem.class).registerEventReceiver(this, BlockChangedEvent.class, BlockComponent.class);

PhysicsWorldWrapper wrapper = new PhysicsWorldWrapper(world);

VoxelWorldShape worldShape = new VoxelWorldShape(wrapper);

Matrix3f rot = new Matrix3f();

rot.setIdentity();

DefaultMotionState blockMotionState = new DefaultMotionState(new Transform(new Matrix4f(rot, new Vector3f(0, 0, 0), 1.0f)));

RigidBodyConstructionInfo blockConsInf = new RigidBodyConstructionInfo(0, blockMotionState, worldShape, new Vector3f());

RigidBody rigidBody = new RigidBody(blockConsInf);

rigidBody.setCollisionFlags(CollisionFlags.STATIC_OBJECT | rigidBody.getCollisionFlags());

_discreteDynamicsWorld.addRigidBody(rigidBody, combineGroups(StandardCollisionGroup.WORLD), (short)(CollisionFilterGroups.ALL_FILTER ^ CollisionFilterGroups.STATIC_FILTER));

}

開發者ID:zoneXcoding,項目名稱:Mineworld,代碼行數:25,

示例9: setCollisionShape

​點讚 3

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

/**

* Creates a {@link com.bulletphysics.dynamics.RigidBody} with the specified shape and mass.

*

* @param colShape Collision shape for physics simulation

* @param mass Mass of the body

*/

protected void setCollisionShape(CollisionShape colShape, float mass) {

// compute inertia (only for non static bodies)

Vector3f localInertia = new Vector3f(0, 0, 0);

if (mass != 0) {

colShape.calculateLocalInertia(mass, localInertia);

}

// create rigid body for physics simulation

synchronized (mPhysicsTransform) {

DefaultMotionState motionState = new DefaultMotionState(mPhysicsTransform);

RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, motionState,

colShape, localInertia);

mPhysicsBody = new RigidBody(rbInfo);

mPhysicsBody.setFriction(1.0f);

}

}

開發者ID:fabmax,項目名稱:LightGL,代碼行數:23,

示例10: initPhysics

​點讚 2

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

/**

*

*/

@Override

public void initPhysics() {

DefaultMotionState groundMotionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, -1, 0), 1.0f)));

//TODO: Un uglify this code.

TriangleIndexVertexArray vertArray = new TriangleIndexVertexArray();

for (Mesh mesh : this.getMeshes()) {

// Construct collision shape based on the mesh vertices in the Mesh.

float[] positions = mesh.getPositions();

int[] indices = mesh.getIndices();

IndexedMesh indexedMesh = new IndexedMesh();

indexedMesh.numTriangles = indices.length / 3;

indexedMesh.triangleIndexBase = ByteBuffer.allocateDirect(indices.length*4).order(ByteOrder.nativeOrder());

indexedMesh.triangleIndexBase.asIntBuffer().put(indices);

indexedMesh.triangleIndexStride = 3 * 4;

indexedMesh.numVertices = positions.length / 3;

indexedMesh.vertexBase = ByteBuffer.allocateDirect(positions.length*4).order(ByteOrder.nativeOrder());

indexedMesh.vertexBase.asFloatBuffer().put(positions);

indexedMesh.vertexStride = 3 * 4;

vertArray.addIndexedMesh(indexedMesh);

}

BvhTriangleMeshShape collShape = new BvhTriangleMeshShape(vertArray, false);

System.out.println("SCALE: " + this.getScale());

//collisionShape = new ScaledBvhTriangleMeshShape(collShape, new Vector3f(this.getcale(), this.getScale(), this.getScale()));

collisionShape = collShape;

collisionShape.setLocalScaling(new Vector3f(this.getScale(), this.getScale(), this.getScale()));

RigidBodyConstructionInfo groundRigidBodyCI = new RigidBodyConstructionInfo(0, groundMotionState, collisionShape, new Vector3f(0,0,0));

rigidBody = new RigidBody(groundRigidBodyCI);

this.rigidBody.activate();

}

開發者ID:brokenprogrammer,項目名稱:Mass,代碼行數:39,

示例11: initPhysics

​點讚 2

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

/**

* Method to initialize all physics related

* values.

*/

@Override

public void initPhysics() {

motionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(-2, -400, 0), 1.0f)));

// Construct collision shape based on the mesh vertices in the Mesh.

fallInertia = new Vector3f(0,0,0);

collisionShape = new BoxShape(new Vector3f(1, 1, 1));

collisionShape.calculateLocalInertia(mass,fallInertia);

// Construct the RigidBody.

RigidBodyConstructionInfo rigidBodyCI = new RigidBodyConstructionInfo(mass, motionState, collisionShape, fallInertia);

rigidBody = new RigidBody(rigidBodyCI);

}

開發者ID:brokenprogrammer,項目名稱:Mass,代碼行數:18,

示例12: localCreateRigidBody

​點讚 2

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public RigidBody localCreateRigidBody(float mass, Transform startTransform, CollisionShape shape) {

// rigidbody is dynamic if and only if mass is non zero, otherwise static

boolean isDynamic = (mass != 0f);

Vector3f localInertia = new Vector3f(0f, 0f, 0f);

if (isDynamic) {

shape.calculateLocalInertia(mass, localInertia);

}

// using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects

//#define USE_MOTIONSTATE 1

//#ifdef USE_MOTIONSTATE

DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

RigidBodyConstructionInfo cInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);

RigidBody body = new RigidBody(cInfo);

//#else

//btRigidBody* body = new btRigidBody(mass,0,shape,localInertia);

//body->setWorldTransform(startTransform);

//#endif//

dynamicsWorld.addRigidBody(body);

return body;

}

開發者ID:unktomi,項目名稱:form-follows-function,代碼行數:28,

示例13: createRigidBody

​點讚 2

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public static RigidBody createRigidBody(RigidBodyConstructionInfo rbci) {

RigidBody rb = new RigidBody(rbci);

if (rbci.mass <= EMath.FLOAT_EPSILON) {

rb.setCollisionFlags(CollisionFlags.STATIC_OBJECT);

}

bodies.add(rb);

world.addRigidBody(rb);

return rb;

}

開發者ID:Axodoss,項目名稱:Wicken,代碼行數:12,

示例14: onAddToScene

​點讚 2

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public void onAddToScene()

{

Transform startTrans = PhysicsEngine.toBullet(getParent().getTransform());

CollisionShape shape = physShape.toCollisionShape();

RigidBodyConstructionInfo constructionInfo = new RigidBodyConstructionInfo((float)mass, new DefaultMotionState(startTrans), shape);

constructionInfo.restitution = 0.01f;

shape.calculateLocalInertia((float)mass, constructionInfo.localInertia);

body = new RigidBody(constructionInfo);

physicsEngine.addPhysObject(this);

}

開發者ID:jglrxavpok,項目名稱:jglrEngine,代碼行數:11,

示例15: Ground

​點讚 2

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public Ground(Screen screen) {

float size = 100000;

ObjLoader loader = new ObjLoader();

//loader.load("res/snow/snow_terrain.obj");

Model groundModel = new Model();

groundModel.useShader(ShaderProgram.textureShader);

Mesh groundMesh = new Mesh();

groundMesh.setTexture(new Texture("res/snow/CanadianArctic.jpg",GL11.GL_REPEAT));

groundMesh.create(

new float[]{

-size, 0, -size, // down left

-size, 0, size, // up left

size, 0, -size, // down right

size, 0, -size, // down right

size, 0, size, // up right

-size, 0, size // up left

},

null, null,

new float[]{

0, 0,// down left

0, size/50,// up left

size/50, 0,// down right

size/50, 0,// down right

size/50, size/50,// up right

0, size/50,// up left

},

null

);

groundModel.addMesh(groundMesh);

MotionState state2 = new DefaultMotionState(new Transform(MatrixConverter.convert(groundModel.getModel())));

CollisionShape shape2 = new StaticPlaneShape(new Vector3f(0, 1, 0),1f);

RigidBodyConstructionInfo info2 = new RigidBodyConstructionInfo(0f, state2, shape2);

RigidBody body2 = new RigidBody(info2);

body2.setFriction(0.3f);

groundModel.body = body2;

screen.addEntity(groundModel);

}

開發者ID:StavrosSkourtis,項目名稱:SuperHornet,代碼行數:44,

示例16: createDefaultRBCI

​點讚 2

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public static RigidBodyConstructionInfo createDefaultRBCI(CollisionShape shape, float mass, Vector3f position, Quaternion rotation) {

javax.vecmath.Vector3f inertia = new javax.vecmath.Vector3f(0,0,0);

shape.calculateLocalInertia(mass, inertia);

MotionState motionState = createMotionState(position,rotation);

return new RigidBodyConstructionInfo(mass, motionState, shape, inertia);

}

開發者ID:Axodoss,項目名稱:Wicken,代碼行數:7,

示例17: RigidBodyComponent

​點讚 2

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public RigidBodyComponent(RigidBodyConstructionInfo rbci) {

body = PhysicsSystem.createRigidBody(rbci);

}

開發者ID:Axodoss,項目名稱:Wicken,代碼行數:4,

示例18: createBox

​點讚 2

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public synchronized RigidBody createBox(float x, float y, float z) {

// create a few dynamic rigidbodies

// Re-using the same collision is better for memory usage and

// performance

CollisionShape colShape = new BoxShape(new Vector3f(1, 1, 1));

// CollisionShape colShape = new SphereShape(1f);

collisionShapes.add(colShape);

// Create Dynamic Objects

Transform startTransform = new Transform();

startTransform.setIdentity();

float mass = 1f;

// rigidbody is dynamic if and only if mass is non zero, otherwise

// static

boolean isDynamic = (mass != 0f);

Vector3f localInertia = new Vector3f(0, 0, 0);

if (isDynamic) {

colShape.calculateLocalInertia(mass, localInertia);

}

float start_x = START_POS_X + (x/10) - ARRAY_SIZE_X / 2;

float start_y = START_POS_Y + (y/10);

float start_z = START_POS_Z + (z/10)- ARRAY_SIZE_Z / 2;

startTransform.origin.set(start_x, 10f+start_y, start_z);

// using motionstate is recommended, it provides

// interpolation capabilities, and only synchronizes

// 'active' objects

DefaultMotionState myMotionState = new DefaultMotionState(

startTransform);

RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(

mass, myMotionState, colShape, localInertia);

RigidBody body = new RigidBody(rbInfo);

body.setActivationState(RigidBody.ACTIVE_TAG);

body.setDamping(LINEAR_DAMPING, ANGULAR_DAMPING);

dynamicsWorld.addRigidBody(body);

body.setActivationState(RigidBody.ACTIVE_TAG);

return body;

}

開發者ID:ryancheu,項目名稱:yhackathon2013,代碼行數:46,

示例19: SpaceShip

​點讚 1

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public SpaceShip(Screen screen) {

ObjLoader loader = new ObjLoader();

jet = loader.load("res/jets/spaceship/dark_fighter_6.obj");

exhaustFlamesRight = new Mesh();

exhaustFlamesLeft = new Mesh();

//jet.rotate(-1.53f, new Vec3(1, 0, 0));

jet.translate(

new Vec3(0, 100, 0));

Vector3f intertia = new Vector3f();

BoxShape shape = new BoxShape(new Vector3f(5, 9f, 1));

shape.calculateLocalInertia(

3000f, intertia);

MotionState defaultState = new DefaultMotionState(new Transform(MatrixConverter.convert(jet.getModel())));

RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(3000f, defaultState, shape, intertia);

RigidBody body = new RigidBody(info);

jet.body = body;

jet.body.setFriction(

0.3f);

jet.body.setDamping(

0.4f, 0.5f);

jet.body.setActivationState(RigidBody.DISABLE_DEACTIVATION);

screen.addEntity(jet);

frontLookPoint = new Vec3(0, 20, -10);

this.flamesLeftI = new int[100];

this.flamesLeftV = new float[100];

this.flamesRightI = new int[100];

this.flamesRightV = new float[100];

this.color = new float[100];

System.out.println("Here");

}

開發者ID:StavrosSkourtis,項目名稱:SuperHornet,代碼行數:50,

示例20: p3dRuler

​點讚 1

import com.bulletphysics.dynamics.RigidBodyConstructionInfo; //導入依賴的package包/類

public void p3dRuler(){float length = 10/2f;float width = 10/2f;List vertices = new ArrayList();vertices.add(new Vector3f(-length,0,-width));vertices.add(new Vector3f(-length,0,width));vertices.add(new Vector3f(length,0,width));vertices.add(new Vector3f(length,0,-width));Transform startTransform = new Transform();startTransform.setIdentity();Vector3f translate = new Vector3f();startTransform.origin.set(translate);CollisionShape shape = new ConvexHullShape(vertices);Vector3f localInertia = new Vector3f(0f, 0f, 0f);DefaultMotionState myMotionState = new DefaultMotionState(startTransform);RigidBodyConstructionInfo cInfo = new RigidBodyConstructionInfo(0f, myMotionState, shape, localInertia);RigidBody body = new RigidBody(cInfo);body.setGravity(new Vector3f(0,0,0));pInterfaceWorld.addRigidBody(body);}

開發者ID:Sivx,項目名稱:Sivx-3DDesktop,代碼行數:2,

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值