Пример #1
0
 public DrawService(IServiceProvider WObj, Game game)
 {
     if ((RenderSubsystem)game.Services.GetService(typeof(RenderSubsystem)) != null)
     {
         RenderSubsystem rs         = (RenderSubsystem)game.Services.GetService(typeof(RenderSubsystem));
         NameService     objectName = (NameService)WObj.GetService(typeof(NameService));
         // Check if the World Object have a position in space, if not do not add it to render
         if (WObj.GetService(typeof(PositionService)) != null)
         {
             pos = (PositionService)WObj.GetService(typeof(PositionService));
         }
         // Check if the World Object is a Camera, if yes add it to render as a Camera
         if (WObj.GetService(typeof(CameraService)) != null)
         {
             cam = (CameraService)WObj.GetService(typeof(CameraService));
             rs.AddDrawService("Camera", this);
         }
         // Check if the World Object has a Model, if yes add it to render
         if (WObj.GetService(typeof(Model)) != null)
         {
             model = (Model)WObj.GetService(typeof(Model));
             rs.AddDrawService(objectName.ObjectName(), this);
         }
     }
 }
Пример #2
0
 /* Subscribe a World Object to be the Camera */
 public CameraService(IServiceProvider wo, Game game, float fieldOfView, float aspectRatio, float nearPlane, float farPlane)
 {
     obj = wo;
     pos = (PositionService)obj.GetService(typeof(PositionService));
     this.fieldOfView = fieldOfView;
     this.aspectRatio = aspectRatio;
     this.farPlane    = farPlane;
     this.nearPlane   = nearPlane;
     IsPerspective    = true;
 }
Пример #3
0
 public CameraService(IServiceProvider wo, Game game, float left, float right, float bottom, float top, float nearPlane, float farPlane)
 {
     obj            = wo;
     pos            = (PositionService)obj.GetService(typeof(PositionService));
     this.left      = left;
     this.right     = right;
     this.bottom    = bottom;
     this.top       = top;
     this.farPlane  = farPlane;
     this.nearPlane = nearPlane;
     IsPerspective  = false;
 }