Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (515)
Games in Android Showcase (122)
games submitted by our members
Games in WIP (577)
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  
  Creating a single 3D Line  (Read 1588 times)
0 Members and 1 Guest are viewing this topic.
Offline calzada

Junior Duke




m3g is the truth


« Posted 2005-01-19 13:19:35 »

Hi,

does anyone know how to simply generate a 3D Line with 2 3d points?

Regards,
Franck

Mobile Entertainment Studio: M-E-S
http://sourceforge.net/projects/cazapool3d/
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #1 - Posted 2005-01-19 13:34:54 »

Indeed. It's actually quite easy.

1. Take two points of (x1, y1, z1) and (x2, y2, z2)
2. Translate each point to the 2D screen by dividing by the Z component. i.e.:

1  
2  
3  
4  
int scrx1 = x1/z1;
int scry1 = y1/z1;
int scrx2 = x2/z2;
int scry2 = y2/z2;


3. Decide where the zero point is in the universe. Usually 0,0,0 is the center of the screen, so you need to translate by half the screenWidth. i.e.:

1  
2  
3  
4  
5  
6  
7  
int translatex = screenWidth/2;
int translatey = screenWidth/2;

scrx1 += translatex;
scry1 += translatey;
scrx2 += translatex;
scry2 += translatey;


4. Draw the line from scrx1,scry1 to scrx2,scry2 using the standard drawLine() method.

Note that this technique produces weird results when one of the coordinates falls behind you. In those cases you need to clip on 3D bounds. :-)

Java Game Console Project
Last Journal Entry: 12/17/04
Offline calzada

Junior Duke




m3g is the truth


« Reply #2 - Posted 2005-01-19 14:04:28 »

i understand your point but this solution (simulating 3d line by doing the projection myself) is not very nice and not accurate i guess.

any one have an easier idea?

Mobile Entertainment Studio: M-E-S
http://sourceforge.net/projects/cazapool3d/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gangrel-br

Junior Duke




Java and Scala! Thats the game =)


« Reply #3 - Posted 2005-01-19 14:21:51 »

Quote
i understand your point but this solution (simulating 3d line by doing the projection myself) is not very nice and not accurate i guess.

any one have an easier idea?


You can probably use the Mobile 3D API, but very few devices support it yet.

Paulo "JCranky" Siqueira
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #4 - Posted 2005-01-19 14:34:33 »

Quote
i understand your point but this solution (simulating 3d line by doing the projection myself) is not very nice and not accurate i guess.


It is as accurate as any other renderer. As for not being very nice, can you tell us what you're trying to do? If we knew that, we could probably give you good suggestions. Even then, the options are limited. As another poster pointed out, your options are limited to the Mobile 3D API (not well supported yet), the Mascot Capsule API (again, support might be a problem), and performing the render yourself.

Quote
any one have an easier idea?


Erm... Like a drawLine3D() method? Not likely.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline calzada

Junior Duke




m3g is the truth


« Reply #5 - Posted 2005-01-20 07:28:15 »

I'm using Mobile 3D API, I built a 3D world unsing m3g loader etc... everything works fine.
I just want to add a Line in my World based on 2 Points (x, y, z)
I don't want to create a Mesh for that. I mean I would like to avoid doing such things

Mobile Entertainment Studio: M-E-S
http://sourceforge.net/projects/cazapool3d/
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #6 - Posted 2005-01-21 13:48:49 »

Quote
I'm using Mobile 3D API, I built a 3D world unsing m3g loader etc... everything works fine.
I just want to add a Line in my World based on 2 Points (x, y, z)
I don't want to create a Mesh for that. I mean I would like to avoid doing such things


Sorry. AFAIK, you need a VertexArray for that sort of thing. (The MobileAPI is a scenegraph not a 3D renderer.) Actually, in a 3D world you're almost better doing a thin polygon. That will prevent it from becoming invisible due to scaling, and it will properly interact with other polygons.

JSR 239 is working on OpenGL ES support that would make things like simple line drawing more feasible.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline calzada

Junior Duke




m3g is the truth


« Reply #7 - Posted 2005-02-01 09:07:33 »

yup,

I think that's what i'll do.

thanks all,
Franck

Mobile Entertainment Studio: M-E-S
http://sourceforge.net/projects/cazapool3d/
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.

TehJavaDev (30 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (39 views)
2014-10-26 19:37:11

Luminem (21 views)
2014-10-26 10:17:50

Luminem (25 views)
2014-10-26 10:14:04

theagentd (31 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (57 views)
2014-10-16 15:22:06

Norakomi (46 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!