Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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  
  basic rotating and moving problem  (Read 1107 times)
0 Members and 1 Guest are viewing this topic.
Offline zulo

Junior Member




Java games rock!


« Posted 2004-06-04 17:50:53 »

maybe someone here could help me?

http://puppygames.net/forums/viewtopic.php?t=591&sid=deca9f44332c3fd813e1f47f2b4f0d0f

Offline Chman

Junior Member




Nothing more that... Java games are cool !


« Reply #1 - Posted 2004-06-04 19:32:15 »

Hi there !

You should use glPushMatrix() and glPopMatrix() like that :

1  
2  
3  
4  
5  
6  
7  
public static void movefirkant()
{
   GL11.glPushMatrix();
   GL11.glRotatef(firkantz,0.0f,0.0f,0.2f);
   GL11.glTranslatef(400.0f,400.0f,0.0f);
   GL11.glPopMatrix();
}


This should work...

Chman
Offline zulo

Junior Member




Java games rock!


« Reply #2 - Posted 2004-06-05 10:26:40 »

Hi thank you

It now works almost, with this code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
public static void firkant(){       
       movefirkant();      
 }
 public static void movefirkant(){
       
       GL11.glPushMatrix();
       GL11.glTranslatef(200.0f,400.0f,0.0f);
       GL11.glRotatef(firkantz,0.0f,0.0f,1.0f);
renderfirkant();
       GL11.glPopMatrix();
  }
 public static void renderfirkant(){
       
       GL11.glBegin(GL11.GL_QUADS);
       GL11.glVertex3f(0.0f, 0.0f, 0.0f);
       GL11.glVertex3f(40.0f, 0.0f, 0.0f);
       GL11.glVertex3f(40.0f, 40.0f, 0.0f);
       GL11.glVertex3f(0.0f, 40.0f, 0.0f);
       GL11.glEnd();
 }


It rotates the quad around the first vertex wherever
i put it on the screen but still not around the center of the quad. Maybe its because the quad isnt placed around 0.0? its to the right of 0.0

When moving a model should you change the drawing coordinates in renderfirkant() or move it with
the glTranslatef method?

I also tried to place the renderfirkant() call after the
movefirkant call in firkant() but that didnt work.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Chman

Junior Member




Nothing more that... Java games are cool !


« Reply #3 - Posted 2004-06-05 10:46:26 »

Quote

It now works almost, with this code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
...
 public static void movefirkant(){
       
       GL11.glPushMatrix();
       GL11.glTranslatef(200.0f,400.0f,0.0f);
       GL11.glRotatef(firkantz,0.0f,0.0f,1.0f);
renderfirkant();
       GL11.glPopMatrix();
  }
...



You should place the glRotatef() before the glTranslatef() and it should work...

Chman
Offline zulo

Junior Member




Java games rock!


« Reply #4 - Posted 2004-06-05 11:32:20 »

then it rotates around the bottom left side of the screen..

I dont understand this
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #5 - Posted 2004-06-05 13:20:36 »

Build the quad around 0/0... that makes it easier. In general - you should build everything around that total zero, because rotations are always relative to that (in addition you won't need to remember the width and height, because they just don't matter).

弾幕 ☆ @mahonnaiseblog
Offline zulo

Junior Member




Java games rock!


« Reply #6 - Posted 2004-06-05 14:39:10 »

thank you both for answering, think i got it now.

How will this work when you load models created in f.ex. in milkshape?
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #7 - Posted 2004-06-05 16:30:36 »

Well, locate em (in your favorite 3d application) around the origin (0/0/0) or let 'em stand on it. Eg for a human "stand on" would be nicer (usually) and for let's say a space ship you would use "around". This way roations and the like are a no brainer. So either relative to the surface or relative to the center. Just pick the one wich makes more sense and you'll avoid confusion.

弾幕 ☆ @mahonnaiseblog
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (20 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (31 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (28 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (60 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!