This is BBAtomShape.m in view mode; [Download] [Up]
/* BBAtomShape.m
*
* This generates a RenderMan shape that represents an Atom. Normally we only
* show up as a sphere in a certain color which is determind by the region
* we are painted for. To speed up the drawing we store the useful data.
*
* For more interface-info see the header file. More in depth information
* can be found in the source-code.
*
* Written by: Thomas Engel
* Created: 25.12.1993 (Copyleft)
* Last modified: 25.05.1994
*/
#import "BBAtomShape.h"
#import "BBAtom.h"
#import "BBMolecule.h"
#import "BBRegionShape.h"
@implementation BBAtomShape
- initFrom:anAtom asPartOf:aRegionShape;
{
self = [super init];
if( !self ) return self;
// OK. We really are an object...here we go with our init.
ourAtom = anAtom;
ourRegionShape = aRegionShape;
[self update];
return self;
}
- renderSelf:(N3DCamera *)theCamera
{
// Very simple. Just take what we have.
RiColor( color );
RiTranslate( x, y, z );
RiSphere( radius, -radius, radius, 360.0, RI_NULL );
return self;
}
- renderSelfAsBox:(N3DCamera *)theCamera
{
// Just set the right color for the box !
RiColor( color );
return [super renderSelfAsBox:theCamera];
}
- update
{
// We just update (or init) everything we need for drawing.
x = (float)[ourAtom xPos];
y = (float)[ourAtom yPos];
z = (float)[ourAtom zPos];
// Now let's ask for all the other style settings.
// What color should we take ? The regions color or the atoms color.
radius = (RtFloat)[ourRegionShape atomRadius:self];
if( [[ourRegionShape region] shapesInRegionColor] )
NXConvertColorToRGB( [[ourRegionShape region] color],
&color[0], &color[1], &color[2] );
else NXConvertColorToRGB( [ourAtom color],
&color[0], &color[1], &color[2] );
// If we are selected be will use another color anyway;
/*
if( [ourAtom isSelected] )
NXConvertColorToRGB( [ourRegionShape selectionColor],
&color[0], &color[1], &color[2] );
*/
// To be able to draw boundings we have to set our bounding box here.
boundingBox[0] = x - radius;
boundingBox[1] = x + radius;
boundingBox[2] = y - radius;
boundingBox[3] = y + radius;
boundingBox[4] = z - radius;
boundingBox[5] = z + radius;
return self;
}
- atom
{
return ourAtom;
}
@end
/*
* History: 23.05.94 Small changes to work with the new shape stuff.
* Sets its bounding box correctly.
*
* 07.05.94 Changed the name:BBAtomShape and the init method.
*
* 03.01.94 Added NXColor support to this object
*
*
* Bugs: Hmmm
*/These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.