Blender V2.61 - r43446

VectorValue.h

Go to the documentation of this file.
00001 /*
00002  * VectorValue.h: interface for the CVectorValue class.
00003  * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
00004  *
00005  * Permission to use, copy, modify, distribute and sell this software
00006  * and its documentation for any purpose is hereby granted without fee,
00007  * provided that the above copyright notice appear in all copies and
00008  * that both that copyright notice and this permission notice appear
00009  * in supporting documentation.  Erwin Coumans makes no
00010  * representations about the suitability of this software for any
00011  * purpose.  It is provided "as is" without express or implied warranty.
00012  *
00013  */
00014 
00019 #if !defined _VECTORVALUE_H
00020 #define _VECTORVALUE_H
00021 
00022 #include "Value.h"
00023 
00024 #define KX_X 0
00025 #define KX_Y 1
00026 #define KX_Z 2
00027 
00028 
00029 class CVectorValue : public CPropValue  
00030 {
00031     //PLUGIN_DECLARE_SERIAL(CVectorValue,CValue)
00032 
00033 public:
00034     //void Transform(rcMatrix4x4 mat);
00035     virtual void SetValue(CValue* newval);
00036     void SetVector(double newvec[]);
00037     void Configure(CValue* menuvalue);
00038     virtual double* GetVector3(bool bGetTransformedVec=false);
00039     virtual double      GetNumber();
00040     
00041     CValue*     Calc(VALUE_OPERATOR op, CValue *val) {
00042         return val->CalcFinal(VALUE_VECTOR_TYPE, op, this);
00043     }
00044     
00045     CValue*     CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
00046     
00047     
00048     CVectorValue(double vec[],const char *name,AllocationTYPE alloctype=CValue::HEAPVALUE);
00049     CVectorValue() {};
00050 
00051     CVectorValue(double vec[],AllocationTYPE alloctype=CValue::HEAPVALUE);
00052     CVectorValue(float x,float y,float z, AllocationTYPE alloctype = CValue::HEAPVALUE);
00053     virtual ~CVectorValue();
00054     //virtual bool ExportT3D(File *txtfile,bool bNoName=false);
00055     void AddConfigurationData(CValue* menuvalue);
00056     
00057 
00058 
00059     virtual CValue* GetReplica();
00060     virtual const STR_String & GetText();
00061 
00062 /*
00063     void            SnapPoint(float num,int snap)
00064     {
00065         if (num > 0) num += ((float)snap / 2);
00066         else num -= ((float)snap / 2);
00067         num = (long)(((long)(num / snap)) * snap);
00068     };
00069 
00070     void SnapPosition(const double snapvec[])
00071     {
00072         
00073         if (snapvec[KX_X] >= 1)
00074             SnapPoint(m_vec[KX_X],snapvec[KX_X]);
00075         if (snapvec[KX_Y] >= 1)
00076             SnapPoint(m_vec[KX_Y],snapvec[KX_Y]);
00077         if (snapvec[KX_Z] >= 1)
00078             SnapPoint(m_vec[KX_Z],snapvec[KX_Z]);
00079             
00080     }
00081 */
00082     
00083 protected:
00084     double              m_vec[3];
00085     double              m_transformedvec[3];
00086 
00087 
00088 #ifdef WITH_CXX_GUARDEDALLOC
00089 public:
00090     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CVectorValue"); }
00091     void operator delete( void *mem ) { MEM_freeN(mem); }
00092 #endif
00093 };
00094 
00095 #endif // !defined _VECTORVALUE_H
00096