libsphere - how do I get a sphere into an object?

Kurt Akeley kurt at cashew.asd.sgi.com
Tue Nov 6 03:36:39 AEST 1990


In article <10445 at milton.u.washington.edu>,
merritt at milton.u.washington.edu (Ethan Merritt) writes:
|> I have been playing with libsphere on a PI under 3.3.1.  I like it,
|> but I haven't been able to figure out how to get spheres into a graphics
|> object.  The example in 4Dgifts/src/sphere doesn't use objects, so that
|> hasn't helped.
|> 
|> The simple-minded approach:
|> 		makeobj( sphere_object );
|> 		sphdraw( &params[i] );
|> 		closeobj();
|> produces nothing when the corresponding callobj( sphere_object ) is done.
|> 
|> The library routine sphobj() looks relevent, but the documentation is,
|> shall we say, terse.  Calling sphobj( sphereobj ) seems to draw a sphere
|> into sphereobj all right, but always at the origin (I think).  Anyway
|> preceding the call with a move( x,y,z ) call seems to have no effect.
|> I.e.:
|> 	sphobj( sphere_object );
|> 	makeobj( spheres );
|> 	for (i = 0; i < nspheres; i++ )
|> 		{
|> 		move( &xyz[i] );
|> 		callobj( sphere_object );
|> 		}
|> 	closeobj();
|> 	callobj( spheres );
|> doesn't seem to do anything other than pile up spheres on top of each other.
|> 
|> Can anyone enlighten me?

You're almost there, but you dropped the ball by calling move() to reposition
the spheres.  The way to reposition any GL object, including the sphere
objects, is to redefine the object-to-eye coordinate transformation by calling
translate().  Just replace your move() call with a translate() call and things
should work well.

Sorry for the terse documentation.  Just another case of something that seemed
obvious to us, but is not to others.

-- kurt



More information about the Comp.sys.sgi mailing list