Jump to content

[SOLVED] custom types integration


photo

Recommended Posts

hi, i need to integrate my vector types with Unigine-script vector types(vec3, vec4, etc.).

the main idea is :

1. define in my vector class some conversion functions to unigine vector types (copy ctor, operator=, type conversion operator)

class dVec3 {
...
		#ifdef UNIGINE_VERSION
		
		inline dVec3(const Unigine::dvec3 &v)
		{
			this->x = v.x;
			this->y = v.y;
			this->z = v.z;
		}
		
		operator Unigine::dvec3() const
		{
			return Unigine::dvec3(x, y, z);
		}
		
		#endif
...
}

2. define some VariableToType <> and TypeToVariable <> templates

	DECLARE_VARIABLE_TO_TYPE(GlobeXY::dVec3, GlobeXY::dVec3, getDVec3, );
	DECLARE_VARIABLE_TO_TYPE(const GlobeXY::dVec3 &, GlobeXY::dVec3, getDVec3, );

	DECLARE_TYPE_TO_VARIABLE_REF(GlobeXY::dVec3, setDVec3, );
	DECLARE_TYPE_TO_VARIABLE_STACK(const GlobeXY::dVec3 &, setDVec3, );
 

3. all seems to be well, except the

#undef DECLARE_VARIABLE_TO_TYPE

#undef DECLARE_TYPE_TO_VARIABLE_REF

#undef DECLARE_TYPE_TO_VARIABLE_STACK

in UnigineInterpreter.h

 

i think you have to remove this #undefs for ability to do things like this without copy-paste this defines to user code.

 

Link to comment
×
×
  • Create New...