Hi,
does anyone know how to simply generate a 3D Line with 2 3d points?
Regards,
Franck
Hi,
does anyone know how to simply generate a 3D Line with 2 3d points?
Regards,
Franck
Indeed. It’s actually quite easy.
int scrx1 = x1/z1;
int scry1 = y1/z1;
int scrx2 = x2/z2;
int scry2 = y2/z2;
int translatex = screenWidth/2;
int translatey = screenWidth/2;
scrx1 += translatex;
scry1 += translatey;
scrx2 += translatex;
scry2 += translatey;
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.
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?
[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?
[/quote]
You can probably use the Mobile 3D API, but very few devices support it yet.
[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.
[/quote]
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?
[/quote]
Erm… Like a drawLine3D() method? Not likely.
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
[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
[/quote]
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.
yup,
I think that’s what i’ll do.
thanks all,
Franck