CelestiaStar.mm
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:2k
源码类别:

OpenGL

开发平台:

Visual C++

  1. //
  2. //  CelestiaStar.mm
  3. //  celestia
  4. //
  5. //  Created by Bob Ippolito on Sat Jun 08 2002.
  6. //  Copyright (c) 2002 Chris Laurel. All rights reserved.
  7. //
  8. #import "CelestiaStar.h"
  9. #import "CelestiaStar_PrivateAPI.h"
  10. #import "CelestiaVector_PrivateAPI.h"
  11. #import "CelestiaAppCore.h"
  12. #import "CelestiaAppCore_PrivateAPI.h"
  13. #import "NSString_ObjCPlusPlus.h"
  14. @implementation CelestiaStar(PrivateAPI)
  15. -(CelestiaStar*)initWithStar:(const Star*)s
  16. {
  17.     self = [super init];
  18.     _data = [[NSValue alloc] initWithBytes:reinterpret_cast<void*>(&s) objCType:@encode(Star*)];
  19.     return self;
  20. }
  21. -(Star*)star
  22. {
  23.     return reinterpret_cast<Star*>([_data pointerValue]);
  24. }
  25. @end
  26. /* 
  27.     inline StellarClass getStellarClass() const;
  28.     void setStellarClass(StellarClass);
  29. */
  30. @implementation CelestiaStar
  31. -(void)setCatalogNumber:(NSNumber*)cat
  32. {
  33.     [self star]->setCatalogNumber([cat unsignedIntValue]);
  34. }
  35. -(void)setCatalogNumber:(NSNumber*)cat atIndex:(NSNumber*)index
  36. {
  37. //    [self star]->setCatalogNumber([index unsignedIntValue], [cat unsignedIntValue]);
  38. }
  39. -(NSNumber*)catalogNumber
  40. {
  41.     return [NSNumber numberWithUnsignedInt:[self star]->getCatalogNumber()];
  42. }
  43. -(NSNumber*)catalogNumberAtIndex:(NSNumber*)cat
  44. {
  45. //    return [NSNumber numberWithUnsignedInt:[self star]->getCatalogNumber([cat unsignedIntValue])];
  46. }
  47. -(void)dealloc
  48. {
  49.     if (_data != nil) {
  50.         [_data release];
  51.         _data = nil;
  52.     }
  53.     [super dealloc];
  54. }
  55. -(NSNumber *)radius
  56. {
  57.     return [NSNumber numberWithFloat:[self star]->getRadius()];
  58. }
  59. -(CelestiaVector*)position
  60. {
  61.     return [CelestiaVector vectorWithPoint3f:[self star]->getPosition()];
  62. }
  63. -(void)setPosition:(CelestiaVector*)p
  64. {
  65.     [self star]->setPosition([p point3f]);
  66. }
  67. -(NSNumber*)apparentMagnitude:(NSNumber*)m
  68. {
  69.     return [NSNumber numberWithFloat:[self star]->getApparentMagnitude([m floatValue])];
  70. }
  71. -(NSNumber*)luminosity
  72. {
  73.     return [NSNumber numberWithFloat:[self star]->getLuminosity()];
  74. }
  75. -(NSNumber*)temperature
  76. {
  77.     return [NSNumber numberWithFloat:[self star]->getTemperature()];
  78. }
  79. -(NSNumber*)rotationPeriod
  80. {
  81. //    return [NSNumber numberWithFloat:[self star]->getRotationPeriod()];
  82. }
  83. -(void)setAbsoluteMagnitude:(NSNumber*)m
  84. {
  85.     [self star]->setAbsoluteMagnitude([m floatValue]);
  86. }
  87. -(void)setLuminosity:(NSNumber*)m
  88. {
  89.     [self star]->setLuminosity([m floatValue]);
  90. }
  91. -(NSString *)name
  92. {
  93.     return [NSString stringWithStdString:[[CelestiaAppCore sharedAppCore] appCore]->getSimulation()->getUniverse()->getStarCatalog()->getStarName(*[self star])];
  94. }
  95. @end