00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #pragma warning (disable:4786)
00017
00018 #include "Value.h"
00019 #include "VectorValue.h"
00020 #include "ErrorValue.h"
00021
00022 #include "VoidValue.h"
00023 #include "StringValue.h"
00024
00025
00026
00027
00029
00031
00032 CVectorValue::CVectorValue(float x,float y,float z, AllocationTYPE alloctype)
00033 {
00034 SetCustomFlag1(false);
00035
00036 if (alloctype == STACKVALUE)
00037 {
00038 CValue::DisableRefCount();
00039 };
00040
00041 m_vec[KX_X] = m_transformedvec[KX_X] = x;
00042 m_vec[KX_Y] = m_transformedvec[KX_Y] = y;
00043 m_vec[KX_Z] = m_transformedvec[KX_Z] = z;
00044
00045 }
00046 CVectorValue::CVectorValue(double vec[],CCString name,AllocationTYPE alloctype) {
00047
00048 SetCustomFlag1(false);
00049
00050 m_vec[KX_X] = m_transformedvec[KX_X] = vec[KX_X];
00051 m_vec[KX_Y] = m_transformedvec[KX_Y] = vec[KX_Y];
00052 m_vec[KX_Z] = m_transformedvec[KX_Z] = vec[KX_Z];
00053
00054 if (alloctype == STACKVALUE)
00055 {
00056 CValue::DisableRefCount();
00057
00058 }
00059
00060 SetName(name);
00061 }
00062
00063 CVectorValue::CVectorValue(double vec[],AllocationTYPE alloctype) {
00064
00065 SetCustomFlag1(false);
00066
00067 m_vec[KX_X] = m_transformedvec[KX_X] = vec[KX_X];
00068 m_vec[KX_Y] = m_transformedvec[KX_Y] = vec[KX_Y];
00069 m_vec[KX_Z] = m_transformedvec[KX_Z] = vec[KX_Z];
00070
00071 if (alloctype == STACKVALUE)
00072 {
00073 CValue::DisableRefCount();
00074
00075 }
00076
00077
00078 }
00079 CVectorValue::~CVectorValue()
00080 {
00081
00082 }
00083
00084 CValue* CVectorValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
00085
00086
00087
00088
00089
00090 {
00091 CValue *ret = NULL;
00092
00093 switch(op)
00094 {
00095 case VALUE_ADD_OPERATOR:
00096 {
00097 switch (dtype)
00098 {
00099 case VALUE_EMPTY_TYPE:
00100 case VALUE_VECTOR_TYPE:
00101 {
00102 ret = new CVectorValue(
00103 val->GetVector3()[KX_X] + GetVector3()[KX_X],
00104 val->GetVector3()[KX_Y] + GetVector3()[KX_Y],
00105 val->GetVector3()[KX_Z] + GetVector3()[KX_Z],
00106 CValue::HEAPVALUE);
00107 ret->SetName(GetName());
00108 break;
00109 }
00110
00111 default:
00112 ret = new CErrorValue(val->GetText() + op2str(op) + GetText());
00113 }
00114 break;
00115 }
00116 case VALUE_MUL_OPERATOR:
00117 {
00118 switch (dtype)
00119 {
00120
00121 case VALUE_EMPTY_TYPE:
00122 case VALUE_VECTOR_TYPE:
00123 {
00124
00125
00126 break;
00127 }
00128 case VALUE_FLOAT_TYPE:
00129 {
00130 ret = new CVectorValue(
00131 val->GetVector3()[KX_X] * GetVector3()[KX_X],
00132 val->GetVector3()[KX_Y] * GetVector3()[KX_Y],
00133 val->GetVector3()[KX_Z] * GetVector3()[KX_Z],
00134 CValue::HEAPVALUE);
00135 ret->SetName(GetName());
00136 break;
00137 }
00138
00139 default:
00140 ret = new CErrorValue(val->GetText() + op2str(op) + GetText());
00141 }
00142 break;
00143
00144 }
00145
00146 default:
00147 ret = new CErrorValue(val->GetText() + op2str(op) + GetText());
00148 }
00149
00150
00151 return ret;
00152 }
00153
00154 float CVectorValue::GetNumber()
00155 {
00156 return m_vec[KX_X];
00157 }
00158
00159
00160 double* CVectorValue::GetVector3(bool bGetTransformedVec)
00161 {
00162 if (bGetTransformedVec)
00163 return m_transformedvec;
00164
00165 return m_vec;
00166 }
00167
00168
00169
00170
00171
00172 void CVectorValue::SetVector(double newvec[])
00173 {
00174 m_vec[KX_X] = m_transformedvec[KX_X] = newvec[KX_X];
00175 m_vec[KX_Y] = m_transformedvec[KX_Y] = newvec[KX_Y];
00176 m_vec[KX_Z] = m_transformedvec[KX_Z] = newvec[KX_Z];
00177
00178 SetModified(true);
00179 }
00180
00181
00182 void CVectorValue::SetValue(CValue *newval)
00183 {
00184
00185 double* newvec = ((CVectorValue*)newval)->GetVector3();
00186 m_vec[KX_X] = m_transformedvec[KX_X] = newvec[KX_X];
00187 m_vec[KX_Y] = m_transformedvec[KX_Y] = newvec[KX_Y];
00188 m_vec[KX_Z] = m_transformedvec[KX_Z] = newvec[KX_Z];
00189
00190 SetModified(true);
00191 }
00192
00193 static const CCString gstrVectorStr=CCString();
00194 const CCString & CVectorValue::GetText()
00195 {
00196 assertd(false);
00197 return gstrVectorStr;
00198 }
00199
00200 CValue* CVectorValue::GetReplica() {
00201 CVectorValue* replica = new CVectorValue(*this);
00202 CValue::AddDataToReplica(replica);
00203 return replica;
00204 };
00205
00206
00207
00208
00209
00210
00211
00212