skylight.h

Engine/source/T3D/lighting/skylight.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef SKYLIGHT_H
 25#define SKYLIGHT_H
 26
 27#ifndef REFLECTIONPROBE_H
 28#include "T3D/lighting/reflectionProbe.h"
 29#endif
 30#ifndef _GFXVERTEXBUFFER_H_
 31#include "gfx/gfxVertexBuffer.h"
 32#endif
 33#ifndef _GFXPRIMITIVEBUFFER_H_
 34#include "gfx/gfxPrimitiveBuffer.h"
 35#endif
 36#ifndef _TSSHAPEINSTANCE_H_
 37#include "ts/tsShapeInstance.h"
 38#endif
 39#include "lighting/lightInfo.h"
 40
 41#ifndef _RENDERPASSMANAGER_H_
 42#include "renderInstance/renderPassManager.h"
 43#endif
 44
 45class BaseMatInstance;
 46
 47//-----------------------------------------------------------------------------
 48// This class implements a basic SceneObject that can exist in the world at a
 49// 3D position and render itself. There are several valid ways to render an
 50// object in Torque. This class implements the preferred rendering method which
 51// is to submit a MeshRenderInst along with a Material, vertex buffer,
 52// primitive buffer, and transform and allow the RenderMeshMgr handle the
 53// actual setup and rendering for you.
 54//-----------------------------------------------------------------------------
 55
 56class Skylight : public ReflectionProbe
 57{
 58   typedef ReflectionProbe Parent;
 59
 60private:
 61
 62    //Debug rendering
 63   static bool smRenderSkylights;
 64
 65public:
 66   Skylight();
 67   virtual ~Skylight();
 68
 69   // Declare this object as a ConsoleObject so that we can
 70   // instantiate it into the world and network it
 71   DECLARE_CONOBJECT(Skylight);
 72
 73   //--------------------------------------------------------------------------
 74   // Object Editing
 75   // Since there is always a server and a client object in Torque and we
 76   // actually edit the server object we need to implement some basic
 77   // networking functions
 78   //--------------------------------------------------------------------------
 79   // Set up any fields that we want to be editable (like position)
 80   static void initPersistFields();
 81
 82   // Allows the object to update its editable settings
 83   // from the server object to the client
 84   virtual void inspectPostApply();
 85
 86   // Handle when we are added to the scene and removed from the scene
 87   bool onAdd();
 88   void onRemove();
 89
 90   // This function handles sending the relevant data from the server
 91   // object to the client object
 92   U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
 93   // This function handles receiving relevant data from the server
 94   // object and applying it to the client object
 95   void unpackUpdate(NetConnection *conn, BitStream *stream);
 96
 97   //--------------------------------------------------------------------------
 98   // Object Rendering
 99   // Torque utilizes a "batch" rendering system. This means that it builds a
100   // list of objects that need to render (via RenderInst's) and then renders
101   // them all in one batch. This allows it to optimized on things like
102   // minimizing texture, state, and shader switching by grouping objects that
103   // use the same Materials.
104   //--------------------------------------------------------------------------
105   virtual void updateProbeParams();
106
107   // This is the function that allows this object to submit itself for rendering
108   void prepRenderImage(SceneRenderState *state);
109
110   void setPreviewMatParameters(SceneRenderState* renderState, BaseMatInstance* mat);
111};
112
113#endif // _Skylight_H_
114