Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (602)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (650)
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  
  Rotating a quad that isn't at the center of the grid..  (Read 1264 times)
0 Members and 1 Guest are viewing this topic.
Offline SkyAphid
« Posted 2012-06-18 17:11:50 »

First of all, sorry to make another post here so soon, I'm still new to this and I couldn't figure this out after at least 20 minutes of Googling.

So, I'm trying to rotate a quad that isn't at the center of a coordinate grid, like the title said.

This is what I initially tried:

public void render(){
      int renderX = ot.getValue("fieldX") + (BattleRoom.FIELD_WIDTH * fieldX);
      int renderY = ot.getValue("fieldY") + (BattleRoom.FIELD_HEIGHT * fieldY);
      FloatBuffer matrix = BufferUtils.createFloatBuffer(16);
      glGetFloat(GL_MODELVIEW_MATRIX, matrix);
      //glRotatef(5, 0, 1, 0);
      glTranslatef(matrix.get(15), matrix.get(14), 0);
      currentAnim.render(renderX, renderY - 40);

Basically I was getting the matrix values and placing them in a float buffer, and then pushing the matrix. I would then translate the grid so that the center was at the player, and then rotate, and move it back to its original position,draw him, and pop the matrix to ensure the rotation doesn't stick around. Unfortunately, the player is still nowhere to be found. In my debugging I noticed that if the commands that are noted out aren't there, the player draws correctly. So at least my matrix to float buffer idea worked Azn

Anyway, what should I do?

it just werks
Offline CyanPrime
« Reply #1 - Posted 2012-06-18 17:29:35 »

glRotate(your angle, your axis);
Offline SkyAphid
« Reply #2 - Posted 2012-06-18 19:10:56 »

glRotate(your angle, your axis);

That didn't solve my problem, unfortunately. Thanks anyway, though!

it just werks
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel

Medals: 389
Projects: 3
Exp: 5 years

I'm the King!

« Reply #3 - Posted 2012-06-18 19:13:57 »

You don't need the matrix at all. What CyanPrime said was correct and should be the only code in that method.

Offline SkyAphid
« Reply #4 - Posted 2012-06-18 19:55:01 »

You don't the matrix at all. What CyanPrime said was correct and should be the only code in that method.
I can see where translating to a negative of where he was, and then rotating would work, but centering the translation back at where he is isn't, because it was never centered around him to begin with.

I only reference the old matrix so that I can recenter it at where it once was, so I can draw the player correctly in his place.

I mean, if this were built differently, I could see it working, but mine is really weird..

it just werks
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Jesse (16 views)
2015-07-29 04:35:27

Riven (37 views)
2015-07-27 16:38:00

Riven (18 views)
2015-07-27 15:35:20

Riven (21 views)
2015-07-27 12:26:13

Riven (12 views)
2015-07-27 12:23:39

BurntPizza (30 views)
2015-07-25 00:14:37

BurntPizza (42 views)
2015-07-24 22:06:39

BurntPizza (24 views)
2015-07-24 06:06:53

NoxInc (31 views)
2015-07-22 22:16:53

NoxInc (18 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!