Hi, all.
I'm facing the trouble of creating the Real Hockey Player: there is simple game scene:
floor: it's the ice;
player: it's the hockey player.
I need to control this player via keyboard.
Before I worked on PhysX Ageia and I solved this task in the following way:
mFloor->setFriction(0.2);
mFloor->setRestitution(0.2);
mPlayer->setFriction(0.0);
mPlayer->setRestitution(0.0);
Control using mPlayer->addForce(x, y, z);
Now I have to implement it using the Bullet, I'm trying to set these parameters:
mFloor->setFriction(0.2);
mFloor->setRollingFriction(0.2);
mFloor->setRestitution(0.2);
mPlayer->setFriction(0.0);
mPlayer->setRollingFriction(0.0);
mFloor->setRestitution(0.2);
Control using applyCentralForce(x, y, z);
But it's terrible. Please, advise me how it must be implemented. Thanks.
Ice, hockey player
- drleviathan
- Posts: 849
- Joined: Tue Sep 30, 2014 6:03 pm
- Location: San Francisco
Re: Ice, hockey player
Not enough info.
Are you writing a Bullet application in C++ directly or are you using some framework on top of Bullet? If you supply a link to your code, or provide snippets of exactly what you're doing, then it will be more likely that we can answer your questions.
Are you writing a Bullet application in C++ directly or are you using some framework on top of Bullet? If you supply a link to your code, or provide snippets of exactly what you're doing, then it will be more likely that we can answer your questions.
Re: Ice, hockey player
Thanks for your answer.
I'm using Bullet as Physics Engine and Ogre3D as Render Engine.
I've putted necessary fragments of code:
Static plane object:
Dynamic player:
After the object has been created
Move this object I was trying using: applyCentralForce., but it doesn't look like hockey.
Please, have a look the result here: https://www.dropbox.com/s/3e2nqc33yco3k ... y.mov?dl=0
Thanks.
I'm using Bullet as Physics Engine and Ogre3D as Render Engine.
I've putted necessary fragments of code:
Code: Select all
_broadPhase = new btDbvtBroadphase();
btDefaultCollisionConfiguration *collisionConfiguration = new btDefaultCollisionConfiguration();
_dispatcher = new btCollisionDispatcher(collisionConfiguration);
btSequentialImpulseConstraintSolver *solver = new btSequentialImpulseConstraintSolver();
_world = new btDiscreteDynamicsWorld(_dispatcher, _broadPhase, solver, collisionConfiguration);
debug = bPause = NO; bodies = [NSMutableDictionary new];
debugDrawer = new GLDebugDrawer([[iOgreManager manager] SceneManager].mSceneMgr);
debugDrawer->setDebugMode(GLDebugDrawer::DBG_DrawWireframe | GLDebugDrawer::DBG_DrawConstraints);
_world->setDebugDrawer(debugDrawer);
btOverlapFilterCallback *filterCallback = new YourOwnFilterCallback(self);
_world->getPairCache()->setOverlapFilterCallback(filterCallback);
Code: Select all
btCollisionShape *shape; world = _world;
_attachedNode = _node;
Ogre::Vector3 BB = _ent.ent->getBoundingBox().getSize();
Ogre::Vector3 scale = _node.node->getScale();
BB *= scale;
Ogre::Vector3 size = BB;
btVector3 HalfExtents(size.x*0.5f,size.y*0.5f,size.z*0.5f);
shape = new btBoxShape(HalfExtents);
_mass = 0.0;
btVector3 inertia = btVector3(0.0f, 0.0f, 0.0f);
shape->calculateLocalInertia(_mass, inertia);
tempNode = _node;
MyMotionState *motionState = new MyMotionState(_node.node);
_body = new btRigidBody(0.0, NULL, shape, btVector3(0.0f, 0.0f, 0.0f));
_node.btObjName = name;
_body->setUserPointer((__bridge void *)_node);
if (_default) {
btTransform tr = _body->getWorldTransform();
tr.setOrigin(btVector3([_node getPosition].x, [_node getPosition].y, [_node getPosition].z));
tr.setRotation(btQuaternion([_node getOrientation].x, [_node getOrientation].y, [_node getOrientation].z, [_node getOrientation].w));
_body->setWorldTransform(tr);
}
_body->setActivationState(DISABLE_DEACTIVATION);
_body->forceActivationState(ISLAND_SLEEPING);
Code: Select all
btCollisionShape *shape; world = _world;
_attachedNode = _node;
Ogre::Vector3 BB = _ent.ent->getBoundingBox().getSize();
Ogre::Vector3 scale = _node.node->getScale();
BB *= scale;
float radius = BB.x / 2.0;
float height = BB.y / 2.0;
shape = new btCapsuleShape(radius, height);
_mass = 80.0;
btVector3 inertia = btVector3(0.0f, 0.0f, 0.0f);
shape->calculateLocalInertia(_mass, inertia);
tempNode = _node;
MyMotionState *motionState = new MyMotionState(_node.node);
_body = new btRigidBody(_mass, motionState, shape, inertia);
_node.btObjName = name;
if (type != bDynamic) _body->setUserPointer((__bridge void *)_node);
else _body->setUserPointer((__bridge void *)name);
if (_default) {
btTransform tr = _body->getWorldTransform();
tr.setOrigin(btVector3([_node getPosition].x, [_node getPosition].y, [_node getPosition].z));
tr.setRotation(btQuaternion([_node getOrientation].x, [_node getOrientation].y, [_node getOrientation].z, [_node getOrientation].w));
_body->setWorldTransform(tr);
}
state = AS_DISABLE_DEACTIVATION;
Code: Select all
mBody->setAngularFactor(btVector3(0, 0, 0));
// I was playing with the following params:
mBody->setFriction(2.0);
mBody->setRollingFriction(0.f);
mBody->setRestitution(0.0);
mBody->setDamping(btVec2(0.5,0.0));
Please, have a look the result here: https://www.dropbox.com/s/3e2nqc33yco3k ... y.mov?dl=0
Thanks.
Re: Ice, hockey player
For controlling the Player I use the applyCentralForce, thus when the joystick was touched, the method is working:
force that I apply to then object, when I'm calling joystickManagerDidUpdate, summarize/is added to previously. And the object becomes unmanageable:
a) it moves too fast
b) I turned the joystick,for example to right, but the object is still directly moving.
I can't control this player...
Code: Select all
- (void) joystickManagerDidUpdate:(CGPoint)position Angle:(iDegree)angle Right:(BOOL)bRight Sharp:(BOOL)bSharp {
[mBody applyCentralForce:iVector3(position.x * 1000000.0, 0.0, position.y * 1000000.0)];
}
a) it moves too fast
b) I turned the joystick,for example to right, but the object is still directly moving.
I can't control this player...
Re: Ice, hockey player
Please,
Have a look at this image: https://www.dropbox.com/s/2ei0x4v73vi47 ... e.png?dl=0
Point A is start point.
Point B is my target
Line segment AB, it's the model controlling of my player that I need.
But when I'm trying to move my object to point B, my object starts moving by the line segment AC. It seems to me that there is big the skidding force.
Need a piece of advise. Thanks.
Have a look at this image: https://www.dropbox.com/s/2ei0x4v73vi47 ... e.png?dl=0
Point A is start point.
Point B is my target
Line segment AB, it's the model controlling of my player that I need.
But when I'm trying to move my object to point B, my object starts moving by the line segment AC. It seems to me that there is big the skidding force.
Need a piece of advise. Thanks.