Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (593) Games in Android Showcase (168) games submitted by our members Games in WIP (646) 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 1778 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.

 Riven (16 views) 2015-07-03 11:22:16 deepthought (44 views) 2015-06-30 15:39:44 deepthought (48 views) 2015-06-30 15:39:09 deepthought (60 views) 2015-06-30 15:36:52 Za\'Anzabar (28 views) 2015-06-29 05:44:54 TritonDreyja (44 views) 2015-06-24 17:10:40 CopyableCougar4 (43 views) 2015-06-23 00:34:45 BurntPizza (46 views) 2015-06-21 20:36:46 cookiecompiler (88 views) 2015-06-11 15:42:53 cookiecompiler (51 views) 2015-06-11 15:41:14
 princec 31x wessles 23x BurntPizza 19x CopyableCougar4 19x opiop65 18x Riven 15x nsigma 15x EgonOlsen 14x KaiHH 12x KevinWorkman 11x sunburn 11x ags1 11x SauronWatchesYou 11x theagentd 11x Archive 10x NegativeZero 10x
 How 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:21Resources for WIP gamesby kpars2014-12-18 10:26:14
 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