Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (753) Games in Android Showcase (228) games submitted by our members Games in WIP (842) 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 2647 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

 nelsongames (17 views) 2018-04-24 18:15:36 nelsongames (13 views) 2018-04-24 18:14:32 ivj94 (587 views) 2018-03-24 14:47:39 ivj94 (50 views) 2018-03-24 14:46:31 ivj94 (400 views) 2018-03-24 14:43:53 Solater (65 views) 2018-03-17 05:04:08 nelsongames (110 views) 2018-03-05 17:56:34 Gornova (175 views) 2018-03-02 22:15:33 buddyBro (729 views) 2018-02-28 16:59:18 buddyBro (93 views) 2018-02-28 16:45:17
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 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