如何配置子弹引擎的速度,而不是物理精度?例如,是否可以增加摩擦力,使物体更快地静止?
目前,我只能跟踪速度优化:
btContactSolverInfo& info = dynamicsWorld->getSolverInfo();
info.m_numIterations = 4;
Run Code Online (Sandbox Code Playgroud) 我有空间模拟,所以很明显我不需要重力或空气阻力.重力是直接关闭,但我找不到空气阻力的等效物.我认为它将是逐个身体而不是像引力这样的世界范围.
事实上,我看到btSoftBody有中等密度的值,air_density但我正在使用btRigidBody.
我正在使用子弹制作游泳池模拟器,需要准确模拟人类可能的镜头.为了找到应用于母球的冲动,我使用了物体球,口袋中心和母球的位置.
常见拍摄场景http://www.poolplayers.com/wp-content/uploads/2013/03/372-TangentLine-2.jpg
在母球的运动路径类似于物体球(180度附近的击打角度)的情况下,一切正常并且物体球落入口袋中.但似乎镜头路径的角度越大,我产生的脉冲的误差范围就越大.我已经尝试了很多东西来解决这个问题:调整球的碰撞余量,扩大世界范围,关闭摩擦力和恢复原状以及许多其他因素似乎没有改变这种行为.
以下是我的代码的相关部分:
//assume p = pocket center, b = object ball center, c = cue ball center
//first find the position of the ghost ball, ie the target point of collision for the cue ball
btVector3 ghostPos = b+(b-p).normalize()*(2.0f*BALL_RADIUS);
//then use the normal between the ghostball and cue ball as the impulse, scaled by the shots total distance
btVector3 cueImpulse = (ghostPos-c).normalize()*((p.distance(b)+ghostPos.distance(c))*HIT_RATIO);
//finally apply the impulse to the cueball's center of mass (using general form of applyImpulse to …Run Code Online (Sandbox Code Playgroud) 1)有没有证据表明混合刚体phisix和流体(比如SPH)的模拟可以为现实世界提供建模?
2)这种混合的框架如何工作?
假设我们在一个箱子里面有一个woden秋千,里面有两种不同的液体(油和水)和一个柔软的身体球.开始条件如下:

我们怎么能模拟这种情况呢?用什么工具?
我现在如何看待它(如果我错了请高高在上)
*)*在RB\SB phisix引擎中加载()并制作框架.*在流体发动机的tate()中表示我们的rb/sb,作为来自力场的脉冲的粒子*)使用RB和SB作为粒子,其密度对应于它们制作的材料,并且脉冲对应于先前计算的矢量场**)这至少在理论上可以近乎实时地用gpu上的当前流体3 +子弹3来计算......对于简单的情况......但是我想知道这使得系统不真实多少?
我正在使用BulletSharp,它是子弹库的C#发行版.我已经在一个据称有0.0f的恢复原状的物体中得到了一些弹跳.
我有一个动态气缸(不久将是一个网状物)落在两个静态气缸上.像这样:

顶部的气缸通常会疯狂地弹跳,通常会弹到一边.
这是我用来设置场景的代码:
//now figure out bulletsharp stuff...
CollisionConfiguration collConfig = new DefaultCollisionConfiguration();
Dispatcher collDispatch = new CollisionDispatcher(collConfig);
BroadphaseInterface broadphase = new DbvtBroadphase();
ConstraintSolver sol = new SequentialImpulseConstraintSolver();
world = new DiscreteDynamicsWorld(collDispatch, broadphase, sol, collConfig);
world.Gravity = new Vector3(0.0f, -10.0f, 0.0f);
//log (moving object)
MotionState still = new DefaultMotionState();
CylinderShape shape = new CylinderShapeZ(0.5f, 1.0f, 1.0f);
still.WorldTransform = Matrix.Translation(0.0f, 0.4f, 0.0f);
RigidBodyConstructionInfo constructInfo = new RigidBodyConstructionInfo(1.0f, still, shape);
logBody = new RigidBody(constructInfo);
logBody.SetDamping(0.04f, 0.1f);
world.AddRigidBody(logBody);
//rollers (static objects)
CylinderShape …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Bullet Physics进行碰撞检测.我不需要它为我移动任何对象或使用回调处理渲染.我只想每帧更新对象位置,并用它来告诉我何时发生碰撞.为了得到最简单的例子,我试图找到以btBoxShape为形状的对象之间的碰撞.一切运行良好,没有崩溃或明显的内存泄漏,但我没有碰撞,所以我必须在某处犯错.我会尽量保持这个尽可能简短而不留下任何重要的东西.
这是我的世界设置功能:
collisionConfig = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfig);
overlappingPairCache = new btDbvtBroadphase();
solver = new btSequentialImpulseConstraintSolver;
dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,
overlappingPairCache, solver, collisionConfig);
dynamicsWorld->setGravity(btVector3(0.0f, -9.8f, 0.0f));
Run Code Online (Sandbox Code Playgroud)
现在我有btCollisionObject*类型的玩家和敌人对象.我把它们设置成这样:
mPlayerBox = new btBoxShape(btVector3(1,3,1));
mPlayerObject = new btCollisionObject();
mPlayerObject->setCollisionShape(mPlayerBox);
btTransform playerWorld;
playerWorld.setIdentity();
//playerPos is a D3DXVECTOR3 that holds the camera position.
playerWorld.setOrigin(btVector3(playerPos.x, playerPos.y, playerPos.z));
mPlayerObject->setWorldTransform(playerWorld);
mPlayerObject->forceActivationState(DISABLE_DEACTIVATION);//maybe not needed
dynamicsWorld->addCollisionObject(mPlayerObject);
Run Code Online (Sandbox Code Playgroud)
我对敌人的物体基本上做同样的事情.
然后每一帧我用这样的东西更新我的所有对象:
btTransform updatedWorld;
updatedWorld.setIdentity();
updatedWorld.setOrigin(btVector3(position.x, position.y, position.z));
mPlayerObject->setWorldTransform(updatedWorld);
//do the same for my enemies, and then...
dynamicsWorld->performDiscreteCollisionDetection();
//Also tried doing …Run Code Online (Sandbox Code Playgroud) 我最近开始使用jMonkey引擎,非常好.但是我试图实现相对引力.
我想制造围绕彼此旋转的行星(不一定是完美的圆形轨道,取决于速度).所以每个对象都应该影响其他对象.
我现在拥有的:
关闭全球引力
bulletAppState.getPhysicsSpace().setGravity(Vector3f.ZERO);
Run Code Online (Sandbox Code Playgroud)
初始化球体并添加到物理空间
Sphere sphere = new Sphere(50, 50, 5);
Geometry sun = new Geometry("Sun", sphere);
sun.setMaterial(stone_mat);
rootNode.attachChild(sun);
sun.setLocalTranslation(0, 0, 0);
sunPhysics = new RigidBodyControl((float) (50*Math.pow(10, 5)));
sun.addControl(sunPhysics);
bulletAppState.getPhysicsSpace().add(sunPhysics);
Geometry mercury = new Geometry("Mercury", sphere);
mercury.setMaterial(stone_mat);
rootNode.attachChild(mercury);
mercury.setLocalTranslation(15f, 0, 0);
mercuryPhysics = new RigidBodyControl((float) (5));
mercury.addControl(mercuryPhysics);
bulletAppState.getPhysicsSpace().add(mercuryPhysics);
Run Code Online (Sandbox Code Playgroud)
我注意到RigidBodyControl类中有方法setGravity,但它只是设置方向.所以对象就这样消失了.
我真的很期待找到答案.
我正在编写一个模拟,我们需要一些盒子,当它们在一组传送带上移动时,可以相当准确地建模.目前,我们检测箱子是否与静态输送机表面碰撞,并根据输送机速度应该对每个箱子施加冲动.有没有办法让实际的输送机表面移动并使其环绕或在出料端溶解并从进料端生长?只是使用子弹类和方法的名称才能真正起作用.
我想检测一个(球)何时接触另一个物体(目标),我想知道那个接触的冲动.
我知道有三种方法来检测联系人
gContactAddedCallback
Run Code Online (Sandbox Code Playgroud)
要么
int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;i++)
{
btRigidBody* obA = static_cast<btRigidBody*>(contactManifold->getBody0());
btRigidBody* obB = static_cast<btRigidBody*>(contactManifold->getBody1());
// May be there is contact obA and obB
btPersistentManifold* contactManifold = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
int numContacts = contactManifold->getNumContacts();
for (int j=0;j<numContacts;j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
if (pt.getDistance()<0.f)
{
// One contact point is inside of another object
// But some contacts are ignored
}
}
}
Run Code Online (Sandbox Code Playgroud)
要么
检查线性和角速度变化.(不清楚是否有接触和什么物体使速度发生变化,是物体还是阻尼,重力或某些力场.
我希望有联系信息,包括联系人冲动.我注意到在1帧模拟中解决了一些接触,其他需要2帧,脉冲则低两倍.(我得到了它调试代码.)我会很乐意得到一个总冲动的联系通知.
我列出的所有方法都没有为我提供联系方式的完整信息.有一段时间它会在球飞近目标时发射,甚至不会碰到目标.
什么是预期的方法呢?
如果接触能量很高,这些信息可用于播放冲击声或开始一些动画.
总结问题:
到目前为止,我的世界里有两具尸体,一枚是地面,另一枚是一个叫做"坠落之星"的坠落盒子.
1)我不明白为什么我的子弹世界与我绘制的世界不一致,除非我设置btVector3(2,2,2)了(btDefault)MotionState 的偏移量.在代码中的任何地方都没有花哨的魔法可以解释偏移.或者至少我找不到任何理由,不是在着色器中,而是在任何地方.
2)我希望能够使用多个实例btDefaultMotionState,确切地说,我想将一个实例用于下降的实体并将其放置在地面上的某个位置,然后为地面创建另一个应该与我的图形对齐的实例 - 地面,永远不动.
我在2)方面遇到的问题是,无论出于什么原因btDefaultMotionState,坠落实体的实例总是也影响地面实例,没有任何参考.
现在到代码:
创建fallBox:
btCollisionShape *fallingBoxShape = new btBoxShape(btVector3(1,1,1));
btScalar fallingBoxMass = 1;
btVector3 fallingBoxInertia(0,0,0);
fallingBoxShape->calculateLocalInertia(fallingBoxMass, fallingBoxInertia);
// TODO this state somehow defines where exactly _ALL_ of the physicsWorld is...
btDefaultMotionState *fallMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), btVector3(2,2,2)));
//btDefaultMotionState *fallMotionState = new btDefaultMotionState();
btRigidBody::btRigidBodyConstructionInfo fallingBoxBodyCI(fallingBoxMass, fallMotionState, fallingBoxShape, fallingBoxInertia);
/*btTransform initialTransform;
initialTransform.setOrigin(btVector3(0,5,0));*/
this->fallingBoxBody = new btRigidBody(fallingBoxBodyCI);
/*fallMotionState->setWorldTransform(initialTransform);
this->fallingBoxBody->setWorldTransform(initialTransform);*/
this->physicsWorld->addBody(*fallingBoxBody);
Run Code Online (Sandbox Code Playgroud)
现在对我来说有趣的部分是btVector3(2,2,2)将它与我绘制的世界对齐的必要偏移量:
btTransform initialTransform;
initialTransform.setOrigin(btVector3(0,5,0));
this->fallingStarBody = new btRigidBody(fallingStarBodyCI); …Run Code Online (Sandbox Code Playgroud) bulletphysics ×10
c++ ×4
bullet ×3
game-physics ×3
physics ×3
algorithm ×1
billiards ×1
c# ×1
contact ×1
game-engine ×1
java ×1
math ×1
modeling ×1
performance ×1
rigid-bodies ×1