Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  Understanding the Transform3d  (Read 952 times)
0 Members and 1 Guest are viewing this topic.
Offline Usul

Senior Newbie




I hunt bugs


« Posted 2005-08-06 22:08:25 »

hi,

do you guys know good tutorials for understanding the matrix used by Transform3D?

I know how to move or rotate an object, but I dont know how to turn an object so that it looks at the direction of another object.  There I want to understand the math now.

thanx,

Usul

p.s.
and I DID google for hours, I swear.  But either the sites only talk about very basic stuff or they are very complicated.  I didnt find anything in between.

It's times like this that I wish I'd listened to what my dad used to tell me.
Yeah? What was that?
I don't know. I never listened. 
- Dr. Venkman and Mr. Zeddemore
Offline Usul

Senior Newbie




I hunt bugs


« Reply #1 - Posted 2005-08-06 22:38:49 »

OK, I drawed the matrix on my HUD and now Im starting to understand.  Its obvious where the position is stored and I guess I can figur that rotation thing out by myself.

But what is the last colum of that Matrix4d used for?  Its always (0,0,0,1).


Still I would appreciate any good tutorials on that subject.

Edit:  The big question is:  How can I determine from that Matrix4d in which direction (in angles to the axis) I am facing?

Edit:  A maybe simpler answer would suffice:  How can I get the direction (represented as a quaternion or a matrix) between to points/vectors?

It's times like this that I wish I'd listened to what my dad used to tell me.
Yeah? What was that?
I don't know. I never listened. 
- Dr. Venkman and Mr. Zeddemore
Offline Jeff

JGO Coder




Got any cats?


« Reply #2 - Posted 2005-08-07 06:37:04 »

See Transform3D.lookAt()

The matrix is  a standard 4x4 vector transform matrix.  Look at your favorite Vector Algebra book or any basic 3D graphics book (eg Foley and Van Damme)

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Usul

Senior Newbie




I hunt bugs


« Reply #3 - Posted 2005-08-07 10:24:36 »

See Transform3D.lookAt()

I tried it.  I wanted my modol to look at the origin (without changing its position) every time I press a button.  But it just jumps around (at least the up-vector seems to work).  Here's my code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
        //GET CURRENT POSITION
       tg.getTransform(transform3D);
        Vector3d pos = new Vector3d();
        transform3D.get(pos);
        System.out.println(pos.x +" " + pos.y+" "+pos.z);
        //LOOK AT THE ORIGIN
       transform3D = new Transform3D();
        transform3D.lookAt(new Point3d(pos.x,pos.y,pos.z),new Point3d(0,0,0), new Vector3d(0,1,0));
        tg.setTransform(transform3D);



Edit: Oh wait, it DOES work.  I just forgot that I didnt place my cube3d in the origin (in other words: stupid mistake).  OK, thanx.

It's times like this that I wish I'd listened to what my dad used to tell me.
Yeah? What was that?
I don't know. I never listened. 
- Dr. Venkman and Mr. Zeddemore
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.

xsi3rr4x (57 views)
2014-04-15 18:08:23

BurntPizza (55 views)
2014-04-15 03:46:01

UprightPath (68 views)
2014-04-14 17:39:50

UprightPath (51 views)
2014-04-14 17:35:47

Porlus (68 views)
2014-04-14 15:48:38

tom_mai78101 (92 views)
2014-04-10 04:04:31

BurntPizza (153 views)
2014-04-08 23:06:04

tom_mai78101 (249 views)
2014-04-05 13:34:39

trollwarrior1 (205 views)
2014-04-04 12:06:45

CJLetsGame (212 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!