00001
00002 extern "C" int Gdfra;
00003
00004 #include "KX_ConvertProperties.h"
00005 #include "blender.h"
00006 #include "game.h"
00007 #include "Value.h"
00008 #include "VectorValue.h"
00009 #include "BoolValue.h"
00010 #include "StringValue.h"
00011 #include "FloatValue.h"
00012 #include "KX_GameObject.h"
00013
00014 #include "IntValue.h"
00015 #include "SCA_TimeEventManager.h"
00016 #include "SCA_IScene.h"
00017
00018
00019 void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventManager* timemgr,SCA_IScene* scene)
00020 {
00021
00022 bProperty* prop = (bProperty*)object->prop.first;
00023 CValue* propval;
00024 bool show_debug_info;
00025 while(prop)
00026 {
00027
00028 propval = NULL;
00029 show_debug_info = bool (prop->flag & PROP_DEBUG);
00030
00031 switch(prop->type) {
00032 case PROP_BOOL:
00033 {
00034 propval = new CBoolValue((bool)(prop->data != 0));
00035 gameobj->SetProperty(prop->name,propval);
00036
00037 break;
00038 }
00039 case PROP_INT:
00040 {
00041 int intprop = (int)prop->data;
00042 propval = new CIntValue((int)prop->data);
00043 gameobj->SetProperty(prop->name,propval);
00044 break;
00045 }
00046 case PROP_FLOAT:
00047 {
00048
00049 float floatprop = *((float*)&prop->data);
00050 propval = new CFloatValue(floatprop);
00051 gameobj->SetProperty(prop->name,propval);
00052 }
00053 break;
00054 case PROP_STRING:
00055 {
00056
00057 propval = new CStringValue((char*)prop->poin,"");
00058 gameobj->SetProperty(prop->name,propval);
00059 break;
00060 }
00061 case PROP_TIME:
00062 {
00063
00064
00065
00066
00067
00068
00069
00070 int BlenderHackTM = (Gdfra - prop->data)/2;
00071
00072 CValue* timeval = new CFloatValue((int)BlenderHackTM);
00073 timemgr->AddTimeProperty(timeval);
00074 propval = timeval;
00075 gameobj->SetProperty(prop->name,timeval);
00076
00077 }
00078 default:
00079 {
00080
00081 }
00082 }
00083
00084 if (propval)
00085 {
00086 if (show_debug_info)
00087 {
00088 scene->AddDebugProperty(gameobj,CCString(prop->name));
00089 }
00090 }
00091
00092 prop = prop->next;
00093 }
00094
00095
00096 }