Advertisement

Object handle on class members

Started by December 05, 2010 09:50 AM
1 comment, last by D3DXVECTOR3 13 years, 11 months ago
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;
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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Many thanks, it works now.
I'm sure i have tested this before though. guess there was something else incorrect at the time.

This topic is closed to new replies.

Advertisement