Creating a copy of the ParticleEmitter classes
by Lukas Joergensen · in Torque 3D Professional · 05/17/2012 (10:24 am) · 2 replies
Soo i tried to create a copy of the files:
But after playing a little with it i ended up with a bug that i simply can't get rid of.
First the error message:
I thought, ok fair the enum can't be defined both places. So first i tried renaming the enum in one of the files, and it gave me the same error.
Then i tried moving the file to an external file and including it in both files. The include file looked like this:
Any ideas?
- particleEmitter.cpp
- particleEmitter.h
- particleEmitterNode.cpp
- particleEmitterNode.h
But after playing a little with it i ended up with a bug that i simply can't get rid of.
First the error message:
Quote:Error 6 error LNK2005: "int TypeParticleBlendStyle" (?TypeParticleBlendStyle@@3HA) already defined in graphEmitter.obj C:TorqueTorque 3D 1.2My ProjectsEmptyProjectbuildFilesVisualStudio 2010projectsparticleEmitter.obj EmptyProject DLLI looked at it and it is talking about the code:
// Enum tables used for fields blendStyle, srcBlendFactor, dstBlendFactor.
// Note that the enums for srcBlendFactor and dstBlendFactor are consistent
// with the blending enums used in Torque Game Builder.
typedef ParticleRenderInst::BlendStyle ParticleBlendStyle;
DefineEnumType( ParticleBlendStyle );
ImplementEnumType( ParticleBlendStyle,
"The type of visual blending style to apply to the particles.n"
"@ingroup FXnn")
{ ParticleRenderInst::BlendNormal, "NORMAL", "No blending style.n" },
{ ParticleRenderInst::BlendAdditive, "ADDITIVE", "Adds the color of the pixel to the frame buffer with full alpha for each pixel.n" },
{ ParticleRenderInst::BlendSubtractive, "SUBTRACTIVE", "Subtractive Blending. Reverses the color model, causing dark colors to have a stronger visual effect.n" },
{ ParticleRenderInst::BlendPremultAlpha, "PREMULTALPHA", "Color blends with the colors of the imagemap rather than the alpha.n" },
EndImplementEnumType;I thought, ok fair the enum can't be defined both places. So first i tried renaming the enum in one of the files, and it gave me the same error.
Then i tried moving the file to an external file and including it in both files. The include file looked like this:
#ifndef _H_PARTICLE_TYPES
#define _H_PARTICLE_TYPES
#ifndef _PARTICLE_H_
#include "T3D/fx/particle.h"
#endif
#ifndef _RENDERPASSMANAGER_H_
#include "renderInstance/renderPassManager.h"
#endif
// Enum tables used for fields blendStyle, srcBlendFactor, dstBlendFactor.
// Note that the enums for srcBlendFactor and dstBlendFactor are consistent
// with the blending enums used in Torque Game Builder.
typedef ParticleRenderInst::BlendStyle ParticleBlendStyle;
DefineEnumType( ParticleBlendStyle );
ImplementEnumType( ParticleBlendStyle,
"The type of visual blending style to apply to the particles.n"
"@ingroup FXnn")
{ ParticleRenderInst::BlendNormal, "NORMAL", "No blending style.n" },
{ ParticleRenderInst::BlendAdditive, "ADDITIVE", "Adds the color of the pixel to the frame buffer with full alpha for each pixel.n" },
{ ParticleRenderInst::BlendSubtractive, "SUBTRACTIVE", "Subtractive Blending. Reverses the color model, causing dark colors to have a stronger visual effect.n" },
{ ParticleRenderInst::BlendPremultAlpha, "PREMULTALPHA", "Color blends with the colors of the imagemap rather than the alpha.n" },
EndImplementEnumType;
#endif // _H_PARTICLE_TYPESBut that made every file using the particleEmitter return this error:Quote:Error 5 error LNK2005: "int TypeParticleBlendStyle" (?TypeParticleBlendStyle@@3HA) already defined in graphEmitter.obj C:TorqueTorque 3D 1.2My ProjectsEmptyProjectbuildFilesVisualStudio 2010projectsgraphEmitterNode.obj EmptyProject DLLAnd some more errors which i did not include due to post size but basically just som already defined errors.
Any ideas?
About the author
IPS Bundle available at: https://www.winterleafentertainment.com/Products/IPS.aspx
#2
Edit:
Commenting this code out from initPersistFields(
However it seems more specifically to be due to
Edit:
Oh yeah the TYPEID definition:
05/19/2012 (9:11 am)
Also a specification of the C2838 error:// C2838.cpp
// compile with: /c
class Bellini {
public:
void Norma();
};
class Bottesini {
Bellini::Norma(); // C2838
};Edit:
Commenting this code out from initPersistFields(
addField( "blendStyle", TYPEID< ParticleRenderInst::BlendStyle >(), Offset(blendStyle, GraphEmitterData),
"String value that controls how emitted particles blend with the scene." );Removes the error. I would like to have that field tho so deleting it is not an option.However it seems more specifically to be due to
TYPEID< ParticleRenderInst::BlendStyle >()Does the typeid not work if DefineEnumType and ImplementEnumType is moved to another file?
Edit:
Oh yeah the TYPEID definition:
/// Return the type ID for the primary console type associated with the given native type.
///
/// There can only be one console type associated with a C++ type. This is referred to as the primary
/// console type.
///
/// @return The type ID of the primary console type for "T".
template< typename T >
S32 TYPEID() { return T::_smTypeId; } // Default assumes a structured type storing its ID in a static member variable.
Torque Owner Lukas Joergensen
WinterLeaf Entertainment
Had to take part of the .h file and put it into a .cpp file:
particleTypes.h
particleTypes.cpp
#include "platform/platform.h" #include "T3D/fx/particleTypes.h" // Enum tables used for fields blendStyle, srcBlendFactor, dstBlendFactor. // Note that the enums for srcBlendFactor and dstBlendFactor are consistent // with the blending enums used in Torque Game Builder. DefineEnumType( ParticleBlendStyle ); ImplementEnumType( ParticleBlendStyle, "The type of visual blending style to apply to the particles.n" "@ingroup FXnn") { ParticleRenderInst::BlendNormal, "NORMAL", "No blending style.n" }, { ParticleRenderInst::BlendAdditive, "ADDITIVE", "Adds the color of the pixel to the frame buffer with full alpha for each pixel.n" }, { ParticleRenderInst::BlendSubtractive, "SUBTRACTIVE", "Subtractive Blending. Reverses the color model, causing dark colors to have a stronger visual effect.n" }, { ParticleRenderInst::BlendPremultAlpha, "PREMULTALPHA", "Color blends with the colors of the imagemap rather than the alpha.n" }, EndImplementEnumType;But now i am stuck with 4 errors:
I get this twice and
I get this twice as well