Sign in to follow this  

Object handle on class members

This topic is 2569 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
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

This topic is 2569 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this