RpAName.c:
const char * RpAtomicNameSetName(RpAtomic *atom, const char *name) { RwInt32 len = rwstrlen(name); if ((rpExtensionOffset > 0) & (len > 0)) { char **extData = RPEXTFROMATOMIC(atom); /* blow away any old name */ if (*extData) { RwFree(*extData); } *extData = RwMalloc(len + 1, rwID_NAOBJECT); rwstrcpy(*extData, name); return name; } /* plugin not initialized or no name provided */ return NULL;
}
const char * RpAtomicNameGetName(RpAtomic *atom) { if (rpExtensionOffset > 0) { char **extData = RPEXTFROMATOMIC(atom); return *extData; } /* plugin not initialized */ return NULL;
}
RpAName.h:
extern const char *RpAtomicNameSetName(RpAtomic *atom, const char *name);
extern const char *RpAtomicNameGetName(RpAtomic *atom);
main.c to make use of the RpAtomicNameGetName() API call. Change the DisplayOnScreenInfo() function to extract the name of the atomic, and to prefix the atomic's translation. If no name is assigned to the atomic, then we will display "NoName" instead.
if (PickedAtomic) { RwFrame *f = RpAtomicGetFrame(PickedAtomic); RwMatrix *m = RwFrameGetLTM(f); const RwChar *s; s = RpAtomicNameGetName(PickedAtomic); RsSprintf(caption, RWSTRING("<%s>:%4.2f %4.2f %4.2f"), s?s:"NoName", m->pos.x, m->pos.y, m->pos.z); RsCharsetPrint( Charset, caption, 0, 2, rsPRINTPOSTOPRIGHT ); }
PickedAtomic = NULL assignment at the bottom of the main.c source file:
case MMPickAndZTranslateObject : PickAtomic(MMZTranslateObject); break; case MMZTranslateObject : ZTranslateAtomic(); break; default: //PickedAtomic = NULL; break; } Render();
/* InitializeMenu function */ static RwBool InitializeMenu(void) { static RwChar fpsLabel[] = RWSTRING("FPS_F"); static RwChar nearLabel[] = RWSTRING("Near Clip"); static RwChar farLabel[] = RWSTRING("Far Clip"); static RwChar showPosLabel[] = RWSTRING("Show Position"); static RwChar namesLabel[] = RWSTRING("Name Choice");
if( MenuOpen(TRUE, &ForegroundColor, &BackgroundColor) )
{
MenuAddEntryBool(fpsLabel, &FPSOn, NULL);
MenuAddEntryReal(nearLabel, &NearClip, NULL, 0.1f, 10.0f, 0.1f);
MenuAddEntryReal( farLabel, & FarClip, NULL, 10.0f, 100.0f, 1.0f);
MenuAddEntryBool(showPosLabel, &ShowPos, NULL);
MenuAddEntryInt(namesLabel, &SelectedName, NULL, 0, NUMNAMES-1, 1, AtomicNames);
return TRUE;
}
return FALSE;
}
assignNameTrigger().
/* InitializeMenu function */ static RwBool InitializeMenu(void) { static RwChar fpsLabel[] = RWSTRING("FPS_F"); static RwChar nearLabel[] = RWSTRING("Near Clip"); static RwChar farLabel[] = RWSTRING("Far Clip"); static RwChar showPosLabel[] = RWSTRING("Show Position"); static RwChar namesLabel[] = RWSTRING("Name Choice"); static RwChar assignLabel[] = RWSTRING("Assign Name");
if( MenuOpen(TRUE, &ForegroundColor, &BackgroundColor) )
{
MenuAddEntryBool(fpsLabel, &FPSOn, NULL);
MenuAddEntryReal(nearLabel, &NearClip, NULL, 0.1f, 10.0f, 0.1f);
MenuAddEntryReal( farLabel, & FarClip, NULL, 10.0f, 100.0f, 1.0f);
MenuAddEntryBool(showPosLabel, &ShowPos, NULL);
MenuAddEntryInt(namesLabel, &SelectedName, NULL, 0, NUMNAMES-1, 1, AtomicNames);
MenuAddEntryTrigger(assignLabel, assignNameTrigger);
return TRUE;
}
return FALSE;
}
assignNameTrigger() callback function. If there is an atomic selected, then the code will call the RpAtomicNameSetName() API.
assignNameTrigger(RwBool check) { if (PickedAtomic && !check) { RpAtomicNameSetName(PickedAtomic, AtomicNames[SelectedName]); }
return TRUE;
}

© 1993-2004 Criterion Software Limited. All rights reserved. Built Thu Feb 12 13:46:59 2004.
Send Feedback