Jump to content
  • Advertisement
Sign in to follow this  
D3DXVECTOR3

Object handle on class members

This topic is 2787 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to get the handle (@) to a class member but can't find how to do so.

NormalMapMaterialDesc looks like this
[source=cpp]
class NormalMapMaterialDesc
{
public:
NormalMapMaterialDesc();
virtual ~NormalMapMaterialDesc();

BitmapData* DiffuseMap;
BitmapData* NormalMap;
BitmapData* SpecularMap;

float Shininess;
};



NormalMapMaterialDesc is registered as a value type. The object properties are registered like:
[source=cpp]
int r;

r = engine->RegisterObjectProperty("NormalMapMaterialDesc", "BitmapData@ DiffuseMap", offsetof(NormalMapMaterialDesc, DiffuseMap));
assert( r >= 0 );
r = engine->RegisterObjectProperty("NormalMapMaterialDesc", "BitmapData@ NormalMap", offsetof(NormalMapMaterialDesc, NormalMap));
assert( r >= 0 );
r = engine->RegisterObjectProperty("NormalMapMaterialDesc", "BitmapData@ SpecularMap", offsetof(NormalMapMaterialDesc, SpecularMap));
assert( r >= 0 );

r = engine->RegisterObjectProperty("NormalMapMaterialDesc", "float Shininess", offsetof(NormalMapMaterialDesc, Shininess));
assert( r >= 0 );



level.bitmapManager().Load() returns a BitmapData* (BitmapData@)

// I need to get the handle of materialDesc.DiffuseMap. I want to set it with the return value of level.bitmapManager().Load(). Now I get an exception saying "Null pointer access" I have tried putting the @ at various places but all my effords have failed.
[source=cpp]
NormalMapMaterialDesc materialDesc;
materialDesc.DiffuseMap = level.bitmapManager().Load("Images/Stone_D.png");
materialDesc.NormalMap = level.bitmapManager().Load("Images/Stone_N.png");
materialDesc.SpecularMap = level.bitmapManager().Load("Images/Stone_S.png");
materialDesc.Shininess = 66.0f;

Share this post


Link to post
Share on other sites
Advertisement
Handle assignments are done by prefixing the left expression with the @ symbol:


NormalMapMaterialDesc materialDesc;
@materialDesc.DiffuseMap = level.bitmapManager().Load("Images/Stone_D.png");
@materialDesc.NormalMap = level.bitmapManager().Load("Images/Stone_N.png");
@materialDesc.SpecularMap = level.bitmapManager().Load("Images/Stone_S.png");
materialDesc.Shininess = 66.0f;



Regards,
Andreas

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!