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

Mike Gigante mg at
Wed Nov 7 12:51:43 AEST 1990


kurt at cashew.asd.sgi.com (Kurt Akeley) writes:

]In article <10445 at milton.u.washington.edu>,
]merritt at milton.u.washington.edu (Ethan Merritt) writes:
]|> 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.
]|> 

]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.

]-- kurt

You probably want
	{
	pushmatrix();
	translate(x, y, z);
	callobj( .. );
	popmatrix();
	}

i.e. wrap a push/pop matrix pair around the translate/callobj,
otherwise each transform will be accumulated with the previous
transforms..  (that is asuming that the x,x,z correspond to the "world
coordinate" position of the spheres)

Mike Gigante, RMIT Australia



More information about the Comp.sys.sgi mailing list