32 #ifndef Transform_INCLUDE_ONCE 33 #define Transform_INCLUDE_ONCE 78 Transform(): mWorldMatrixUpdateTick(0), mAssumeIdentityWorldMatrix(false), mParent(
NULL)
80 VL_DEBUG_SET_OBJECT_NAME()
82 #ifdef VL_USER_DATA_TRANSFORM 83 mTransformUserData =
NULL;
88 Transform(
const mat4& matrix): mWorldMatrixUpdateTick(0), mAssumeIdentityWorldMatrix(false), mParent(
NULL)
90 VL_DEBUG_SET_OBJECT_NAME()
92 #ifdef VL_USER_DATA_TRANSFORM 93 mTransformUserData =
NULL;
96 setLocalMatrix(matrix);
97 setWorldMatrix(matrix);
111 void translate(real x, real y, real z);
115 void translate(
const vec3& t);
119 void scale(real x, real y, real z);
123 void rotate(real
degrees, real x, real y, real z);
127 void rotate(
const vec3& from,
const vec3& to);
131 void preMultiply(
const mat4& m);
135 void postMultiply(
const mat4& m);
163 mWorldMatrix = matrix;
164 ++mWorldMatrixUpdateTick;
178 mLocalMatrix = matrix;
179 setWorldMatrix(matrix);
197 if( assumeIdentityWorldMatrix() )
199 setWorldMatrix(
mat4());
203 if( parent() && !parent()->assumeIdentityWorldMatrix() )
205 setWorldMatrix( parent()->worldMatrix() * localMatrix() );
209 setWorldMatrix( localMatrix() );
216 computeWorldMatrix(camera);
217 for(
size_t i=0; i<mChildren.size(); ++i)
218 mChildren[i]->computeWorldMatrixRecursive(camera);
224 mat4 world = localMatrix();
251 mChildren.push_back(child);
262 size_t insert_point = mChildren.size();
263 mChildren.resize(mChildren.size() + count);
265 for(
size_t i=0; i<count; ++i, ++ptr)
269 (*ptr) = children[i];
280 size_t insert_point = mChildren.size();
281 mChildren.resize(mChildren.size() + count);
283 for(
size_t i=0; i<count; ++i)
286 ptr[i] = children[i];
287 ptr[i]->mParent =
this;
295 addChildren( &children[0], children.size() );
302 addChildren( &children[0], children.size() );
309 VL_CHECK( index < (
int)mChildren.size() )
310 mChildren[index]->mParent =
NULL;
311 mChildren[index] = child;
312 mChildren[index]->
mParent =
this;
325 std::vector< ref<Transform> >::iterator it;
326 it = std::find(mChildren.begin(), mChildren.end(), child);
328 if (it != mChildren.end())
330 (*it)->mParent =
NULL;
338 VL_CHECK( index + count <= (
int)mChildren.size() );
340 for(
int j=index; j<index+count; ++j)
341 mChildren[j]->mParent =
NULL;
343 for(
int i=index+count, j=index; i<(int)mChildren.size(); ++i, ++j)
344 mChildren[j] = mChildren[i];
346 mChildren.resize( mChildren.size() - count );
352 for(
int i=0; i<(int)mChildren.size(); ++i)
353 mChildren[i]->mParent =
NULL;
360 for(
int i=0; i<(int)mChildren.size(); ++i)
362 mChildren[i]->eraseAllChildrenRecursive();
363 mChildren[i]->mParent =
NULL;
371 for(
int i=0; i<(int)mChildren.size(); ++i)
373 mChildren[i]->setLocalAndWorldMatrix( mChildren[i]->worldMatrix() );
374 mChildren[i]->eraseAllChildrenRecursive();
375 mChildren[i]->mParent =
NULL;
385 mParent->eraseChild(
this);
386 setLocalMatrix( worldMatrix() );
393 std::vector< ref<Transform> > tmp (mChildren);
401 for(
size_t i=0; i<mChildren.size(); ++i)
402 mChildren[i]->shrinkRecursive();
414 std::set<const Transform*> tr_set;
415 for(
size_t i=0; i<mChildren.size(); ++i)
416 tr_set.insert( mChildren[i].get() );
417 return tr_set.size() != mChildren.size();
420 #ifdef VL_USER_DATA_TRANSFORM 422 const Object* transformUserData()
const {
return mTransformUserData.get(); }
423 Object* transformUserData() {
return mTransformUserData.get(); }
424 void setTransformUserData(
Object* data) { mTransformUserData = data; }
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Visualization Library main namespace.
The base class for all the reference counted objects.
fmat4 mat4
Defined as: 'typedef fmat4 mat4'. See also VL_PIPELINE_PRECISION.
The ref<> class is used to reference-count an Object.
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Visualization Library's enums in the 'vl' namespace.