📄 interiorinstance.h
字号:
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
#ifndef _INTERIORINSTANCE_H_
#define _INTERIORINSTANCE_H_
//Includes
#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
#ifndef _SCENEOBJECT_H_
#include "sim/sceneObject.h"
#endif
#ifndef _RESMANAGER_H_
#include "core/resManager.h"
#endif
#ifndef _INTERIORRES_H_
#include "interior/interiorRes.h"
#endif
#ifndef _INTERIORLMMANAGER_H_
#include "interior/interiorLMManager.h"
#endif
#ifndef _BITVECTOR_H_
#include "core/bitVector.h"
#endif
#ifndef _COLOR_H_
#include "core/color.h"
#endif
class AbstractPolyList;
class LightUpdateGrouper;
class InteriorSubObject;
class InteriorResTrigger;
class MaterialList;
class TextureObject;
class FloorPlan;
class Convex;
class AudioProfile;
class AudioEnvironment;
//--------------------------------------------------------------------------
class InteriorInstance : public SceneObject
{
typedef SceneObject Parent;
friend class SceneLighting;
friend class FloorPlan;
public:
InteriorInstance();
~InteriorInstance();
static void init();
static void destroy();
// Collision
public:
bool buildPolyList(AbstractPolyList *polyList, const Box3F &box, const SphereF &sphere);
bool castRay(const Point3F &start, const Point3F &end, RayInfo *info);
virtual void setTransform(const MatrixF &mat);
void buildConvex(const Box3F& box,Convex* convex);
private:
Convex* mConvexList;
public:
/// @name Lighting control
/// @{
/// This returns true if the interior is in an alarm state. Alarm state
/// will put different lighting into the interior and also possibly
/// have an audio element also.
bool inAlarmState() {return(mAlarmState);}
/// This sets the alarm mode of the interior.
/// @param alarm If true the interior will be in an alarm state next frame
void setAlarmMode(const bool alarm);
/// Activates a light with the given name on all detail levels of the interior
/// @param pLightName Name of the light
void activateLight(const char* pLightName);
/// Deactivates a light with the given name on all detail levels of the interior
/// @param pLightName Name of the light
void deactivateLight(const char* pLightName);
/// Echos out all the lights in the interior, starting with triggerable then
/// animated lights
void echoTriggerableLights();
/// @}
public:
/// @name Subobject access interface
/// @{
/// Returns the number of detail levels for an object
U32 getNumDetailLevels();
/// Gets the interior associated with a particular detail level
/// @param level Detail level
Interior* getDetailLevel(const U32 level);
/// Sets the detail level to render manually
/// @param level Detail level to force
void setDetailLevel(S32 level = -1) { mForcedDetailLevel = level; }
/// @}
// Material management for overlays
public:
/// Reloads material information if the interior skin changes
void renewOverlays();
/// Sets the interior skin to something different
/// @param newBase New base skin
void setSkinBase(const char *newBase);
public:
static bool smDontRestrictOutside;
static F32 smDetailModification;
DECLARE_CONOBJECT(InteriorInstance);
static void initPersistFields();
static void consoleInit();
void onStaticModified( const char* slotName );
/// Reads the lightmaps of the interior into the provided pointer
/// @param lightmaps Lightmaps in the interior (out)
bool readLightmaps(GBitmap ****lightmaps);
protected:
bool onAdd();
void onRemove();
void inspectPreApply();
void inspectPostApply();
static U32 smLightUpdatePeriod;
static bool smRenderDynamicLights;
U32 mLightUpdatedTime;
void setLightUpdatedTime(const U32);
U32 getLightUpdatedTime() const;
bool onSceneAdd(SceneGraph *graph);
void onSceneRemove();
U32 getPointZone(const Point3F& p);
bool getOverlappingZones(SceneObject* obj, U32* zones, U32* numZones);
bool getLightingAmbientColor(ColorF * col)
{
return false;
}
U32 calcDetailLevel(SceneState*, const Point3F&);
bool prepRenderImage(SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState);
void renderObject(SceneState *state, SceneRenderImage *image);
bool scopeObject(const Point3F& rootPosition,
const F32 rootDistance,
bool* zoneScopeState);
public:
/// This is used to store the preferred lighting method for this interior. It is networked.
bool mUseGLLighting;
/// This indicates what we're actually doing; that way we can bump things to use GL lighting when they are moved.
bool mDoSimpleDynamicRender;
/// Not yet implemented
void addChildren();
/// Returns true if the interiors are rendering dynamic lighting
static bool getRenderDynamicLights() { return(smRenderDynamicLights); }
/// Turns on or off dynamic lighting of interiors
/// @param val If true dynamic lighting is enabled
static void setRenderDynamicLights(bool val) { smRenderDynamicLights = val; }
private:
/// @name Light utility methods
/// These should not be called directly. Use the public activateLight(const char *)
/// method instead because unless the detail level is rendering and it's much
/// easier to not manage the lights on a per-detail level basis.
/// @{
/// Activates a specific light for a detail level
/// @param detail Detail level
/// @param lightIndex Index of light in light list
void activateLight(const U32 detail, const U32 lightIndex);
/// Deactivates a specific light for a detail level
/// @param detail Detail level
/// @param lightIndex Index of light in the light list
void deactivateLight(const U32 detail, const U32 lightIndex);
/// @}
U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream);
void unpackUpdate(NetConnection *conn, BitStream *stream);
enum UpdateMaskBits {
InitMask = BIT(0),
TransformMask = BIT(1),
AlarmMask = BIT(2),
// Reserved for light updates (8 bits for now)
_lightupdate0 = BIT(3),
_lightupdate1 = BIT(4),
_lightupdate2 = BIT(5),
_lightupdate3 = BIT(6),
_lightupdate4 = BIT(7),
_lightupdate5 = BIT(8),
_lightupdate6 = BIT(9),
_lightupdate7 = BIT(10),
SkinBaseMask = BIT(11),
AudioMask = BIT(12),
NextFreeMask = BIT(13)
};
enum Constants {
LightUpdateBitStart = 3,
LightUpdateBitEnd = 10
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -