Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (764)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (852)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [jbox2d] Rotation is killing me...  (Read 1851 times)
0 Members and 1 Guest are viewing this topic.
Offline Ecumene

JGO Kernel


Medals: 197
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Posted 2014-10-01 22:56:20 »

You really don't need much context for this, here's what's happening:

Click to Play

Much easier to see in the MP4 format, here:
http://gyazo.com/8e16e750ac629e6109c14daca3226593

Here's the transform code:
1  
2  
3  
4  
5  
6  
7  
8  
if(bounding.getType() == BodyType.DYNAMIC){
    //"Position iterations" is the 3rd parameter in the World step(), but multiplied by 10.
    //So in my world step I have, world.step(1 / 60f, 8, getPositionIterations / 10); and
    //getPositionIterations returns 30
   Vec2 bodyPosition = bounding.getPosition().mul(Game.getWorldContext().getPositionIterations());
   modelMatrix.translate(new Vector3f(bodyPosition.x, bodyPosition.y, 0));
   modelMatrix.rotate((float) Math.toDegrees(bounding.getAngle()), new Vector3f(0, 0, 1));
}


And if this is of any importance
1  
if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) bounding.applyAngularImpulse(+0.1f);


I'll add more code by request, I also appologize for the crappy structure. I didn't think this "physic system implementation" out very well. I'm still super new on Jbox2D.

Offline KevinWorkman

« JGO Plugged Duke »


Medals: 283
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #1 - Posted 2014-10-02 13:29:30 »

I watched the video and I still have no idea what your question is...?

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline trollwarrior1
« Reply #2 - Posted 2014-10-02 15:19:34 »

Are you sure the body you created is a polygon/square and not a circle?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ecumene

JGO Kernel


Medals: 197
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #3 - Posted 2014-10-03 02:13:41 »

Are you sure the body you created is a polygon/square and not a circle?

Yeah, I'm pretty sure;
1  
boxShape.setAsBox(64f / Game.getWorldContext().getPositionIterations(), 64f / Game.getWorldContext().getPositionIterations());

Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #4 - Posted 2014-10-03 06:23:51 »

Friction. Add some.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (591 views)
2018-06-10 19:43:48

EgonOlsen (695 views)
2018-06-10 19:43:44

EgonOlsen (478 views)
2018-06-10 19:43:20

DesertCoockie (831 views)
2018-05-13 18:23:11

nelsongames (1026 views)
2018-04-24 18:15:36

nelsongames (1083 views)
2018-04-24 18:14:32

ivj94 (1664 views)
2018-03-24 14:47:39

ivj94 (622 views)
2018-03-24 14:46:31

ivj94 (1501 views)
2018-03-24 14:43:53

Solater (569 views)
2018-03-17 05:04:08
Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46

Deployment and Packaging
by philfrei
2018-08-19 23:53:08

Deployment and Packaging
by philfrei
2018-08-19 23:50:04

Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!