mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Improved code style in ribbon files.
This commit is contained in:
parent
35f88a77b1
commit
f5fb2fdf76
4 changed files with 68 additions and 50 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Copyright (c) 2012 GarageGames, LLC
|
// Copyright (c) 2014 GarageGames, LLC
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
|
@ -47,7 +47,7 @@ IMPLEMENT_CO_NETOBJECT_V1(Ribbon);
|
||||||
//
|
//
|
||||||
RibbonData::RibbonData()
|
RibbonData::RibbonData()
|
||||||
{
|
{
|
||||||
for (U8 i = 0; i < RIBBON_NUM_FIELDS; i++) {
|
for (U8 i = 0; i < NumFields; i++) {
|
||||||
mSizes[i] = 0.0f;
|
mSizes[i] = 0.0f;
|
||||||
mColours[i].set(0.0f, 0.0f, 0.0f, 1.0f);
|
mColours[i].set(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
mTimes[i] = -1.0f;
|
mTimes[i] = -1.0f;
|
||||||
|
|
@ -70,32 +70,38 @@ void RibbonData::initPersistFields()
|
||||||
{
|
{
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
|
|
||||||
addField("size", TypeF32, Offset(mSizes, RibbonData), RIBBON_NUM_FIELDS,
|
addGroup("Ribbon");
|
||||||
|
|
||||||
|
addField("size", TypeF32, Offset(mSizes, RibbonData), NumFields,
|
||||||
"The size of the ribbon at the specified keyframe.");
|
"The size of the ribbon at the specified keyframe.");
|
||||||
addField("color", TypeColorF, Offset(mColours, RibbonData), RIBBON_NUM_FIELDS,
|
addField("color", TypeColorF, Offset(mColours, RibbonData), NumFields,
|
||||||
"The colour of the ribbon at the specified keyframe.");
|
"The colour of the ribbon at the specified keyframe.");
|
||||||
addField("position", TypeF32, Offset(mTimes, RibbonData), RIBBON_NUM_FIELDS,
|
addField("position", TypeF32, Offset(mTimes, RibbonData), NumFields,
|
||||||
"The position of the keyframe along the lifetime of the ribbon.");
|
"The position of the keyframe along the lifetime of the ribbon.");
|
||||||
addField("RibbonLength", TypeS32, Offset(mRibbonLength, RibbonData),
|
|
||||||
|
addField("ribbonLength", TypeS32, Offset(mRibbonLength, RibbonData),
|
||||||
"The amount of segments the Ribbon can maximally have in length.");
|
"The amount of segments the Ribbon can maximally have in length.");
|
||||||
addField("UseFadeOut", TypeBool, Offset(mUseFadeOut, RibbonData),
|
|
||||||
"If true, the ribbon will fade away after deletion.");
|
|
||||||
addField("RibbonMaterial", TypeString, Offset(mMatName, RibbonData),
|
|
||||||
"The material the ribbon uses for rendering.");
|
|
||||||
addField("fadeAwayStep", TypeF32, Offset(mFadeAwayStep, RibbonData),
|
|
||||||
"How much to fade the ribbon with each update, after deletion.");
|
|
||||||
addField("segmentsPerUpdate", TypeS32, Offset(segmentsPerUpdate, RibbonData),
|
addField("segmentsPerUpdate", TypeS32, Offset(segmentsPerUpdate, RibbonData),
|
||||||
"How many segments to add each update.");
|
"How many segments to add each update.");
|
||||||
addField("tileScale", TypeF32, Offset(mTileScale, RibbonData),
|
addField("skipAmount", TypeS32, Offset(mSegmentSkipAmount, RibbonData),
|
||||||
|
"The amount of segments to skip each update.");
|
||||||
|
|
||||||
|
addField("useFadeOut", TypeBool, Offset(mUseFadeOut, RibbonData),
|
||||||
|
"If true, the ribbon will fade away after deletion.");
|
||||||
|
addField("fadeAwayStep", TypeF32, Offset(mFadeAwayStep, RibbonData),
|
||||||
|
"How much to fade the ribbon with each update, after deletion.");
|
||||||
|
addField("ribbonMaterial", TypeString, Offset(mMatName, RibbonData),
|
||||||
|
"The material the ribbon uses for rendering.");
|
||||||
|
addField("tileScale", TypeF32, Offset(mTileScale, RibbonData),
|
||||||
"How much to scale each 'tile' with, where 1 means the material is stretched"
|
"How much to scale each 'tile' with, where 1 means the material is stretched"
|
||||||
"across the whole ribbon. (If TexcoordsRelativeToDistance is true, this is in meters.)");
|
"across the whole ribbon. (If TexcoordsRelativeToDistance is true, this is in meters.)");
|
||||||
addField("fixedTexcoords", TypeBool, Offset(mFixedTexcoords, RibbonData),
|
addField("fixedTexcoords", TypeBool, Offset(mFixedTexcoords, RibbonData),
|
||||||
"If true, this prevents 'floating' texture coordinates.");
|
"If true, this prevents 'floating' texture coordinates.");
|
||||||
addField("skipAmount", TypeS32, Offset(mSegmentSkipAmount, RibbonData),
|
addField("texcoordsRelativeToDistance", TypeBool, Offset(mTexcoordsRelativeToDistance, RibbonData),
|
||||||
"The amount of segments to skip each update.");
|
|
||||||
addField("TexcoordsRelativeToDistance", TypeBool, Offset(mTexcoordsRelativeToDistance, RibbonData),
|
|
||||||
"If true, texture coordinates are scaled relative to distance, this prevents"
|
"If true, texture coordinates are scaled relative to distance, this prevents"
|
||||||
"'stretched' textures.");
|
"'stretched' textures.");
|
||||||
|
|
||||||
|
endGroup("Ribbon");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -122,7 +128,7 @@ void RibbonData::packData(BitStream* stream)
|
||||||
{
|
{
|
||||||
Parent::packData(stream);
|
Parent::packData(stream);
|
||||||
|
|
||||||
for (U8 i = 0; i < RIBBON_NUM_FIELDS; i++) {
|
for (U8 i = 0; i < NumFields; i++) {
|
||||||
stream->write(mSizes[i]);
|
stream->write(mSizes[i]);
|
||||||
stream->write(mColours[i]);
|
stream->write(mColours[i]);
|
||||||
stream->write(mTimes[i]);
|
stream->write(mTimes[i]);
|
||||||
|
|
@ -142,7 +148,7 @@ void RibbonData::unpackData(BitStream* stream)
|
||||||
{
|
{
|
||||||
Parent::unpackData(stream);
|
Parent::unpackData(stream);
|
||||||
|
|
||||||
for (U8 i = 0; i < RIBBON_NUM_FIELDS; i++) {
|
for (U8 i = 0; i < NumFields; i++) {
|
||||||
stream->read(&mSizes[i]);
|
stream->read(&mSizes[i]);
|
||||||
stream->read(&mColours[i]);
|
stream->read(&mColours[i]);
|
||||||
stream->read(&mTimes[i]);
|
stream->read(&mTimes[i]);
|
||||||
|
|
@ -558,7 +564,7 @@ void Ribbon::createBuffers(SceneRenderState *state, GFXVertexBufferHandle<GFXVer
|
||||||
F32 tRadius = mDataBlock->mSizes[0];
|
F32 tRadius = mDataBlock->mSizes[0];
|
||||||
ColorF tColor = mDataBlock->mColours[0];
|
ColorF tColor = mDataBlock->mColours[0];
|
||||||
|
|
||||||
for (U8 j = 0; j < RIBBON_NUM_FIELDS-1; j++) {
|
for (U8 j = 0; j < RibbonData::NumFields-1; j++) {
|
||||||
|
|
||||||
F32 curPosition = mDataBlock->mTimes[j];
|
F32 curPosition = mDataBlock->mTimes[j];
|
||||||
F32 curRadius = mDataBlock->mSizes[j];
|
F32 curRadius = mDataBlock->mSizes[j];
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Copyright (c) 2012 GarageGames, LLC
|
// Copyright (c) 2014 GarageGames, LLC
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
|
@ -38,8 +38,6 @@
|
||||||
#include "materials/materialParameters.h"
|
#include "materials/materialParameters.h"
|
||||||
#include "math/util/matrixSet.h"
|
#include "math/util/matrixSet.h"
|
||||||
|
|
||||||
#define RIBBON_NUM_FIELDS 4
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
class RibbonData : public GameBaseData
|
class RibbonData : public GameBaseData
|
||||||
{
|
{
|
||||||
|
|
@ -50,19 +48,26 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
U32 mRibbonLength; ///< The amount of segments that will make up the ribbon.
|
enum Constants
|
||||||
F32 mSizes[RIBBON_NUM_FIELDS]; ///< The radius for each keyframe.
|
{
|
||||||
ColorF mColours[RIBBON_NUM_FIELDS]; ///< The colour of the ribbon for each keyframe.
|
NumFields = 4
|
||||||
F32 mTimes[RIBBON_NUM_FIELDS]; ///< The relative time for each keyframe.
|
};
|
||||||
StringTableEntry mMatName; ///< The material for the ribbon.
|
|
||||||
bool mUseFadeOut; ///< If true, the ribbon will fade away after deletion.
|
F32 mSizes[NumFields]; ///< The radius for each keyframe.
|
||||||
F32 mFadeAwayStep; ///< How quickly the ribbons is faded away after deletion.
|
ColorF mColours[NumFields]; ///< The colour of the ribbon for each keyframe.
|
||||||
S32 segmentsPerUpdate; ///< Amount of segments to add each update.
|
F32 mTimes[NumFields]; ///< The relative time for each keyframe.
|
||||||
F32 mTileScale; ///< A scalar to scale the texcoord.
|
|
||||||
bool mFixedTexcoords; ///< If true, texcoords will stay the same over the lifetime for each segment.
|
U32 mRibbonLength; ///< The amount of segments that will make up the ribbon.
|
||||||
bool mTexcoordsRelativeToDistance; ///< If true, texcoords will not be stretched if the distance between 2 segments are long.
|
S32 segmentsPerUpdate; ///< Amount of segments to add each update.
|
||||||
S32 mSegmentSkipAmount; ///< The amount of segments to skip each time segments are added.
|
S32 mSegmentSkipAmount; ///< The amount of segments to skip each time segments are added.
|
||||||
|
|
||||||
|
bool mUseFadeOut; ///< If true, the ribbon will fade away after deletion.
|
||||||
|
F32 mFadeAwayStep; ///< How quickly the ribbons is faded away after deletion.
|
||||||
|
StringTableEntry mMatName; ///< The material for the ribbon.
|
||||||
|
F32 mTileScale; ///< A scalar to scale the texcoord.
|
||||||
|
bool mFixedTexcoords; ///< If true, texcoords will stay the same over the lifetime for each segment.
|
||||||
|
bool mTexcoordsRelativeToDistance; ///< If true, texcoords will not be stretched if the distance between 2 segments are long.
|
||||||
|
|
||||||
RibbonData();
|
RibbonData();
|
||||||
|
|
||||||
void packData(BitStream*);
|
void packData(BitStream*);
|
||||||
|
|
@ -77,21 +82,25 @@ public:
|
||||||
class Ribbon : public GameBase
|
class Ribbon : public GameBase
|
||||||
{
|
{
|
||||||
typedef GameBase Parent;
|
typedef GameBase Parent;
|
||||||
|
|
||||||
RibbonData* mDataBlock;
|
RibbonData* mDataBlock;
|
||||||
|
|
||||||
|
bool mDeleteOnEnd; ///< If true, the ribbon should delete itself as soon as the last segment is deleted
|
||||||
|
bool mUseFadeOut; ///< If true, the ribbon will fade away upon deletion
|
||||||
|
F32 mFadeAwayStep; ///< How quickly the ribbons is faded away after deletion.
|
||||||
|
F32 mFadeOut;
|
||||||
|
F32 mTravelledDistance; ///< How far the ribbon has travelled in it's lifetime.
|
||||||
|
|
||||||
Vector<Point3F> mSegmentPoints; ///< The points in space where the ribbon has spawned segments.
|
Vector<Point3F> mSegmentPoints; ///< The points in space where the ribbon has spawned segments.
|
||||||
|
U32 mSegmentOffset;
|
||||||
|
U32 mSegmentIdx;
|
||||||
|
|
||||||
|
bool mUpdateBuffers; ///< If true, the vertex buffers need to be updated.
|
||||||
BaseMatInstance *mRibbonMat;
|
BaseMatInstance *mRibbonMat;
|
||||||
MaterialParameterHandle* mRadiusSC;
|
MaterialParameterHandle* mRadiusSC;
|
||||||
MaterialParameterHandle* mRibbonProjSC;
|
MaterialParameterHandle* mRibbonProjSC;
|
||||||
GFXPrimitiveBufferHandle primBuffer;
|
GFXPrimitiveBufferHandle primBuffer;
|
||||||
GFXVertexBufferHandle<GFXVertexPCNTT> verts;
|
GFXVertexBufferHandle<GFXVertexPCNTT> verts;
|
||||||
bool mUpdateBuffers; ///< If true, the vertex buffers need to be updated.
|
|
||||||
bool mDeleteOnEnd; ///< If true, the ribbon should delete itself as soon as the last segment is deleted
|
|
||||||
bool mUseFadeOut; ///< If true, the ribbon will fade away upon deletion
|
|
||||||
F32 mFadeAwayStep; ///< How quickly the ribbons is faded away after deletion.
|
|
||||||
F32 mFadeOut;
|
|
||||||
U32 mSegmentOffset;
|
|
||||||
U32 mSegmentIdx;
|
|
||||||
F32 mTravelledDistance; ///< How far the ribbon has travelled in it's lifetime.
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
@ -102,10 +111,11 @@ protected:
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
void prepRenderImage(SceneRenderState *state);
|
void prepRenderImage(SceneRenderState *state);
|
||||||
|
void setShaderParams();
|
||||||
|
|
||||||
///Checks to see if ribbon is too long
|
///Checks to see if ribbon is too long
|
||||||
U32 checkRibbonDistance(S32 segments);
|
U32 checkRibbonDistance(S32 segments);
|
||||||
void setShaderParams();
|
|
||||||
/// Construct the vertex and primitive buffers
|
/// Construct the vertex and primitive buffers
|
||||||
void createBuffers(SceneRenderState *state, GFXVertexBufferHandle<GFXVertexPCNTT> &verts, GFXPrimitiveBufferHandle &pb, U32 segments);
|
void createBuffers(SceneRenderState *state, GFXVertexBufferHandle<GFXVertexPCNTT> &verts, GFXPrimitiveBufferHandle &pb, U32 segments);
|
||||||
|
|
||||||
|
|
@ -116,11 +126,16 @@ public:
|
||||||
DECLARE_CONOBJECT(Ribbon);
|
DECLARE_CONOBJECT(Ribbon);
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
bool onNewDataBlock(GameBaseData*,bool);
|
bool onNewDataBlock(GameBaseData*,bool);
|
||||||
void addSegmentPoint(Point3F &point, MatrixF &mat); ///< Used to add another segment to the ribbon.
|
|
||||||
void clearSegments() { mSegmentPoints.clear(); } ///< Delete all segments.
|
|
||||||
void deleteOnEnd(); ///< Delete the ribbon when all segments have been deleted.
|
|
||||||
void onRemove();
|
void onRemove();
|
||||||
|
|
||||||
|
/// Used to add another segment to the ribbon.
|
||||||
|
void addSegmentPoint(Point3F &point, MatrixF &mat);
|
||||||
|
|
||||||
|
/// Delete all segments.
|
||||||
|
void clearSegments() { mSegmentPoints.clear(); }
|
||||||
|
|
||||||
|
/// Delete the ribbon when all segments have been deleted.
|
||||||
|
void deleteOnEnd();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _H_RIBBON
|
#endif // _H_RIBBON
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Copyright (c) 2012 GarageGames, LLC
|
// Copyright (c) 2014 GarageGames, LLC
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Copyright (c) 2012 GarageGames, LLC
|
// Copyright (c) 2014 GarageGames, LLC
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
|
@ -37,12 +37,9 @@ class RibbonNodeData : public GameBaseData
|
||||||
{
|
{
|
||||||
typedef GameBaseData Parent;
|
typedef GameBaseData Parent;
|
||||||
|
|
||||||
//-------------------------------------- Console set variables
|
|
||||||
public:
|
public:
|
||||||
F32 timeMultiple;
|
F32 timeMultiple;
|
||||||
|
|
||||||
//-------------------------------------- load set variables
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RibbonNodeData();
|
RibbonNodeData();
|
||||||
~RibbonNodeData();
|
~RibbonNodeData();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue