android - A ball inside a sphere using Bullet -
i'm new @ bullet , 3d , phisycs stuffs, don't angry :) neen create big static rigid sphere , little dynamic 1 inside. want use big 1 bottle, little sphere can move inside, cann't leave sphere, exept 1 plase on top. have written 2 models in blender (of course i've made hole in big sphere), created world , placed objects inside. when start application, little sphere throw out of big 1 extreme speed. i'm using bullet gdx library android, if helps.
this code initializes world.
public final btcollisionconfiguration collisionconfiguration; public final btcollisiondispatcher dispatcher; public final btbroadphaseinterface broadphase; public final btconstraintsolver solver; public final btcollisionworld collisionworld; public performancecounter performancecounter; public final vector3 gravity; public int maxsubsteps = 5; public world() { vector3 gravity = new vector3(0, -10, 0); collisionconfiguration = new btdefaultcollisionconfiguration(); dispatcher = new btcollisiondispatcher(collisionconfiguration); broadphase = new btdbvtbroadphase(); solver = new btsequentialimpulseconstraintsolver(); collisionworld = new btdiscretedynamicsworld(dispatcher, broadphase, solver, collisionconfiguration); ((btdynamicsworld)collisionworld).setgravity(gravity); this.gravity = gravity; } and code creating big sphere
final stillmodel spheres = modelloaderregistry.loadstillmodel(gdx.files.internal("data/ssphere.obj")); spheres.submeshes[0].getmesh().scale(3f, 3f, 3f); final boundingbox spheresbounds = new boundingbox(); spheres.getboundingbox(spheresbounds); final constructor spheresconstructor = new constructor(spheres, 0f, new btsphereshape(spheresbounds.getdimensions().x)); spheresconstructor.bodyinfo.setm_restitution(1f); world.addconstructor("spheres", spheresconstructor); code little sphere
final stillmodel spheremodel = modelloaderregistry.loadstillmodel(gdx.files.internal("data/sphere.obj")); spheremodel.submeshes[0].getmesh().scale(0.8f, 0.8f, 0.8f); final boundingbox spherebounds = new boundingbox(); spheremodel.getboundingbox(spherebounds); final constructor sphereconstructor = new constructor(spheremodel, 0.25f, new btsphereshape(spherebounds.getdimensions().x * 0.5f)); sphereconstructor.bodyinfo.setm_restitution(1f); world.addconstructor("sphere", sphereconstructor); constructor class creates btrigidbodyconstructioninfo , btcollisionshape objects, constructs spheres , place there in world.
so, tell me how can create empty sphere ball inside?
p.s. please, don't tell me google, i've done it
p.p.s sorry english
since big sphere not convex, should not using btsphereshape it. try btbvhtrianglemeshshape, or of other non-convex shapes.
it bit more complicated construct, looking @ examples might provide ideas. anyway, there no simple way want, because not regular empty sphere (i think libgdx framework using takes spheres model rendering).
Comments
Post a Comment