Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

KX_ConvertProperties.cpp

Go to the documentation of this file.
00001 
00002 extern "C" int Gdfra; // ranzig blender heckwerk :(
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 //#include "ListValue.h"
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                         //promp->poin= &prop->data;
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                         //prop->poin= &prop->data;
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                         //prop->poin= callocN(MAX_PROPSTRING, "property string");
00057                         propval = new CStringValue((char*)prop->poin,"");
00058                         gameobj->SetProperty(prop->name,propval);
00059                         break;
00060                 }
00061                 case PROP_TIME:
00062                 {
00063                         // time property is essentially a float property that is updated by the system to
00064                         // reflect time changes
00065                         // let wel: time values bevatten reeds een correctie van de huidige tijdvalue = (Gdfra - prop->data)/2;
00066                         // take care: time values contain a time correction for the current time = (Gdfra - prop->data)/2;
00067                         // really messy :(
00068 
00069                         //int bla = Gdfra - 2*prop->data;
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                         // todo make an assert etc.
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 }

Generated at Thu Feb 1 13:03:04 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000