Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (565) Games in Android Showcase (151) games submitted by our members Games in WIP (606) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Creating a single 3D Line  (Read 1711 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/
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.

 ags1 (19 views) 2015-03-31 10:55:12 theagentd (13 views) 2015-03-27 23:08:20 wxwsk8er (54 views) 2015-03-20 15:39:46 Fairy Tailz (47 views) 2015-03-15 21:52:20 Olo (29 views) 2015-03-13 17:51:59 Olo (32 views) 2015-03-13 17:50:51 Olo (39 views) 2015-03-13 17:50:16 Olo (44 views) 2015-03-13 17:47:07 ClaasJG (58 views) 2015-03-10 11:36:42 ClaasJG (42 views) 2015-03-10 11:33:01
 BurntPizza 21x LiquidNitrogen 21x basil_ 19x KevinWorkman 18x EgonOlsen 17x theagentd 16x Roquen 16x wessles 11x Varkas 11x 65K 11x Riven 11x princec 9x phu004 8x SHC 8x Ashedragon 8x Rayvolution 8x
 How 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:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27
 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