libgdx - Box2d Arrow Transformation - Java -


i'm making archer game libgdx supported box2d. many of box2d tutorials in c++ methods different java.

i want stick arrow when collide box.i found tutorial in c++ , couldn't find way solve issue. it's math question. here c++ code

//start standard positions normal arrow creation   b2vec2 vertices[4];   vertices[0].set( -1.4f,     0 );   vertices[1].set(     0, -0.1f );   vertices[2].set(  0.6f,     0 );   vertices[3].set(     0,  0.1f );    //now multiply difference between arrow , target transforms   b2transform difftransform = b2mult( si.targetbody->gettransform(), si.arrowbody->gettransform() );   (int = 0; < 4; i++)       vertices[i] = b2mul(difftransform, vertices[i]);    b2polygonshape polygonshape;   polygonshape.set(vertices, 4);    //create new fixture in target body   b2fixturedef fixturedef;   fixturedef.shape = &polygonshape;   fixturedef.density = 1;   si.targetbody->createfixture( &fixturedef );    //discard original arrow body   m_world->destroybody( si.arrowbody ); 

the aim when arrow collide box, create new arrow fixture add box's body remove old arrow body. done except transformation of arrow.

the problem there no b2mult or b2mul functions in java. want transform arrow position , angle of old arrow's values when collision occurs.

i not conversant box2d given program logic , little bit of search appears b2mult(x,y) matrix multiplication of matrix x transpose matrix y.

xt * y

if java not offer exact implementation of box2d, search efficient java implementation of matrix class matrix transpose multiplication.

that should trick.

btw did check java port of box2d - http://www.jbox2d.org/ think should have matrix class implemented- matrix multiplication basis of transformations.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -