Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (603) Games in Android Showcase (171) games submitted by our members Games in WIP (652) 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 1812 times) 0 Members and 1 Guest are viewing this topic.

Junior Devvie

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/
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

Junior Devvie

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!
gangrel-br

Junior Devvie

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
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

Junior Devvie

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/
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

Junior Devvie

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.

 SHC (21 views) 2015-08-01 03:58:20 Jesse (19 views) 2015-07-29 04:35:27 Riven (39 views) 2015-07-27 16:38:00 Riven (21 views) 2015-07-27 15:35:20 Riven (24 views) 2015-07-27 12:26:13 Riven (14 views) 2015-07-27 12:23:39 BurntPizza (35 views) 2015-07-25 00:14:37 BurntPizza (46 views) 2015-07-24 22:06:39 BurntPizza (28 views) 2015-07-24 06:06:53 NoxInc (35 views) 2015-07-22 22:16:53
 theagentd 51x wessles 45x basil_ 35x KaiHH 26x orangepascal 26x ags1 21x Riven 19x mooman219 17x bornander 14x KudoDEV 13x CelestialCreator 11x princec 11x klaus 11x Jesse 11x Zaneris 9x pquiring 9x
 List of Learning Resourcesby gouessej2015-07-09 11:29:36How Do I Expand My Game?by bashfrog2015-06-14 11:34:43List of Learning Resources2015-05-31 05:37:30Intersection Methodsby Roquen2015-05-29 08:19:33List of Learning Resources2015-05-05 10:20:32How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21
 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