[comp.graphics] SunPHIGS's pcellarray

kkt@philabs.philips.com (Kim-Kiat Tan) (05/21/91)

	I am trying to display a 2d image using cellarray, however, what I get is the outline drawn around my 2d array (i.e. you see a rectangle), and according to sun's documentation, it stated that SunPHIGS supports the minimal allowed simulation for the CELL ARRAY primitive by drawing the transformmed boundaries of the cell array, does it mean that there is no way to display image with cell array ?
	I tried to use the GDP (procedure pgdp3) to display 3d volume, but there is no input parameters for z-dim, so how on earth the procedure is going to know the dimension in z ?
	Hope someone on the net will have the answer for me.
	Thanks.

rthomson@mesa.dsd.es.com (Rich Thomson) (05/22/91)

[By the way, please try to use 80 character lines -- it really helps
all of us]

In article <1991May20.203703.24007@philabs.philips.com>
	kkt@philabs.philips.com (Kim-Kiat Tan) writes:
> I am trying to display a 2d image using cellarray, however, what
> I get is the outline drawn around my 2d array rectangle), and according
> to sun's documentation, it stated that SunPHIGS supports the minimal
> allowed simulation for the CELL ARRAY primitive by drawing the
> transformmed boundaries of the cell array [...]

The cell array primitive is somewhat of an odd beast and often I've
wondered what it was really good for.  I suspect that it was invented
as a way of getting an image that originated from a raster device to
display on a calligraphic device, however I don't know its ancestry.

It is true that the minimal support for a PHIGS compliant
implementation just has to transform the boundary of the cell array
and do nothing for the interior of the primitive.  In this respect,
SunPHIGS is compliant with PHIGS, but the cell array primitive becomes
pretty useless as you are noticing.  [Was it ever that useful to begin
with? :]

The problem with providing what you're expecting to happen -- a copy
of your "image" appearing on the screen -- is that cell arrays can be
placed on the display surface at arbitrary orientation since they are
subject to coordinate transformations.  Thus to really do this
properly for a "raster image" amounts to texture mapping, which will
be unacceptably slow for interactive applications without hardware
support for texture mapping.

There are several alternatives, though.  If you have anti-aliased
polylines, you can do quite a good job at simulating texture mapping
by using POLYLINE SET 3 WITH DATA structure elements.  Use one a
polyline per scan-line of the source image and place a vertex at each
pixel location in the image.  Choose the vertex colors from the source
image.  By using SET LINE SHADE METHOD structure elements, you should
be able to toggle interpolation of color between vertices of the polyline.

If you don't have anti-aliased polylines, it won't look as nice, but
will have the same effect (anti-aliasing helps most when the polylines
are occupying fewer pixels on the screen than the source image would,
and also in the case where the polyline isn't aligned with the raster
grid of the CRT).

You might also want to try using a quad mesh or triangle strip to
simulate the image, but it will necessarily take longer to render (you
have to scan convert the interiors).  However, with a QM/TS approach,
you don't have any inter-scan-line "gaps" at large magnifications.

						-- Rich
-- 
  ``Read my MIPS -- no new VAXes!!'' -- George Bush after sniffing freon
	    Disclaimer: I speak for myself, except as noted.
UUCP: ...!uunet!dsd.es.com!rthomson		Rich Thomson
ARPA: rthomson@dsd.es.com			PEXt Programmer

blatt@mugwort.Eng.Sun.COM (Alan Greenblatt) (05/30/91)

In article <1991May20.203703.24007@philabs.philips.com> kkt@philabs.philips.com (Kim-Kiat Tan) writes:
>	I am trying to display a 2d image using cellarray, however, what I get
>	is the outline drawn around my 2d array (i.e. you see a rectangle), 
>	and according to sun's documentation, it stated that SunPHIGS 
>	supports the minimal allowed simulation for the CELL ARRAY primitive 
>	by drawing the transformmed boundaries of the cell array, does it 
>	mean that there is no way to display image with cell array ?

Correct.

>	I tried to use the GDP (procedure pgdp3) to display 3d volume, but 
>	there is no input parameters for z-dim, so how on earth the procedure 
>	is going to know the dimension in z ?
>	Hope someone on the net will have the answer for me.
>	Thanks.

Are you trying to display a 2D image or a 3D volume?  If you are trying to
display a 3D volume, you'll have to break it up into surfaces that SunPHIGS
will recognize.  However, if you are indeed trying to render a 2D image,
use GDP -14, the image gdp.  The reason it doesn't have any input parameters
for the z dimension is because it is an image, not a volume.  The GDP does
however take as input a reference point (for the 3D GDP version this is a 
3D point) which locates the image in model coordinates. The image will be
drawn so that its lower left corner is at this point.  The image is drawn as
a raster array: each cell of the image is drawn as a pixel on the screen, and
so the image can not be rotated, scaled or skewed in way. 

If you need a to rotate or scale your image, using polylines or a quad mesh
may work better.


- Alan
--
-----
Alan Greenblatt                         "I'm not arguing that with you.
Anyware Fast, Inc.                       Did I say that?  If I said that,
alan.greenblatt@Eng.Sun.com              I'd be lying."  - Joe vs. the Volcano