FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 123 : strokeWeight() does not work properly or is disabled in P3D and OPENGL
Last modified: 2008-10-17 07:47
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
FIXED -
Pr
i
ority:
P3
Severity:
enhancement
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
fry
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2005-08-13 08:53
for now, the simplest solution is to disable strokeWeight(). because there
is no concept of stroke in 3D, we're out on a limb here.
and it's for a good reason that there's no notion of stroke in 3D
renderers, because a stroke has to do with a line that borders and is on
top of (or subtracts from) the interior shape. so we could do a bunch of
geometry math to subtract things out...
opengl allows you to set the stroke of lines, but offers no sort of caps
and joins. lines are treated somewhat differently from other shapes in
opengl but i've never heard a complete or up-to-date explanation on this.
in some cases i've heard they're just tiny polygons, in others that they're
simply drawn directly into the buffer by a separate mechanism. if anyone
knows better, please opine.
Additional Comment
#1 From fry 2006-09-04 07:31
something like this will draw a thick line:
<PRE>
/**
* Thick lines for P3D or OPENGL.
* The x1/y1/z1 and x2/y2/z2 are the start/end points of the line.
* The r1/g1/b1 and r2/g2/b2 are the colors at start and end.
*/
void thickLine(float x1, float y1, float z1,
float r1, float g1, float b1,
float x2, float y2, float z2,
float r2, float g2, float b2) {
float ox1 = x1; float oy1 = y1; float oz1 = z1;
float ox2 = x2; float oy2 = y2; float oz2 = z2;
float dX = ox2-ox1 + 0.0001f;
float dY = oy2-oy1 + 0.0001f;
float len = sqrt(dX*dX + dY*dY);
float rh = g.strokeWeight / len;
float dx0 = rh * dY;
float dy0 = rh * dX;
float dx1 = rh * dY;
float dy1 = rh * dX;
beginShape(QUADS);
noStroke();
fill(r1, g1, b1);
vertex(ox1+dx0, oy1-dy0, oz1);
vertex(ox1-dx0, oy1+dy0, oz1);
fill(r2, g2, b2);
vertex(ox2-dx1, oy2+dy1, oz2);
vertex(ox2+dx1, oy2-dy1, oz2);
endShape();
}
</PRE>
Additional Comment
#2 From fry 2007-03-11 11:36
***
Bug 533
has been marked as a duplicate of this bug. ***
Additional Comment
#3 From Brad 2007-03-11 13:58
(In reply to
comment #2
)
> ***
Bug 533
has been marked as a duplicate of this bug. ***
i just noticed that the gaps in the joins are there even at the default stroke weight (1) - and
i think even when smooth() is not called (its hard to see exactly). it makes animations of
curves look "sparkly" which is distracting.
Additional Comment
#4 From fry 2007-03-11 14:02
right. strokeCap, strokeJoin, strokeWeight.. as documented, none of them
work in 3D. this is the same issue.
Additional Comment
#5 From fjen 2007-04-02 02:42
so if it's disabled why is it sort-of(*) working? i totally see why the concept of a stroke in
3D would not make too much sense, but i'm mostly using OPENGL mode in 2D because it's
the fastest renderer .. maybe there could be a OPENGL_2D mode?
(*) a problem (and i know since it's not supported this is not considered a bug) i found is
that the strokeWeight is inconsistant with OPENGL. it has different weights for different
angles:
import processing.opengl.*;
size(300,300, OPENGL);
strokeWeight( 10 );
stroke( 0xFF000000 );
translate(width/2, height/2); // center
line( 0,0,-width/2,0); // left
line( 0,0,-width/2,-height/2); // top-left
line( 0,0,0,-height/2); // top-middle
line( 0,0,width/2,-height/2); // top-right
line( 0,0,width/2,0); // right
F
Additional Comment
#6 From fry 2007-04-02 05:27
i've edited the description. basically strokeWeight() doesn't work as it
should in OPENGL, and doesn't work at all in P3D. i think that's how it was
left.
Additional Comment
#7 From fry 2008-10-17 07:47
fixed for 0151.