Example #1
0
void set_ob_property(Object *ob, bProperty *propc)
{
	bProperty *prop;
	prop = get_ob_property(ob, propc->name);
	if (prop) {
		free_property(prop);
		BLI_remlink(&ob->prop, prop);
	}
	BLI_addtail(&ob->prop, copy_property(propc));
}
Example #2
0
void BL_ConvertTextProperty(Object* object, KX_FontObject* fontobj,SCA_TimeEventManager* timemgr,SCA_IScene* scene, bool isInActiveLayer)
{
	CValue* tprop = fontobj->GetProperty("Text");
	if(!tprop) return;
	bProperty* prop = get_ob_property(object, "Text");
	if(!prop) return;

	Curve *curve = static_cast<Curve *>(object->data);
	STR_String str = curve->str;
	CValue* propval = NULL;

	switch(prop->type) {
		case GPROP_BOOL:
		{
			int value = atoi(str);
			propval = new CBoolValue((bool)(value != 0));
			tprop->SetValue(propval);
			break;
		}
		case GPROP_INT:
		{
			int value = atoi(str);
			propval = new CIntValue(value);
			tprop->SetValue(propval);
			break;
		}
		case GPROP_FLOAT:
		{
			float floatprop = atof(str);
			propval = new CFloatValue(floatprop);
			tprop->SetValue(propval);
			break;
		}
		case GPROP_STRING:
		{
			propval = new CStringValue(str, "");
			tprop->SetValue(propval);
			break;
		}
		case GPROP_TIME:
		{
			float floatprop = atof(str);

			CValue* timeval = new CFloatValue(floatprop);
			// set a subproperty called 'timer' so that
			// we can register the replica of this property
			// at the time a game object is replicated (AddObjectActuator triggers this)
			CValue *bval = new CBoolValue(true);
			timeval->SetProperty("timer",bval);
			bval->Release();
			if (isInActiveLayer)
			{
				timemgr->AddTimeProperty(timeval);
			}

			propval = timeval;
			tprop->SetValue(timeval);
		}
		default:
		{
			// todo make an assert etc.
		}
	}

	if (propval) {
		propval->Release();
	}
}