PageRenderTime 264ms CodeModel.GetById 140ms app.highlight 10ms RepoModel.GetById 111ms app.codeStats 0ms

/indra/newview/llflexibleobject.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 147 lines | 74 code | 18 blank | 55 comment | 0 complexity | 066f40e065fe7987dd465dd4e60f6dd7 MD5 | raw file
  1/** 
  2 * @file llflexibleobject.h
  3 * @author JJ Ventrella, Andrew Meadows, Tom Yedwab
  4 * @brief Flexible object definition
  5 *
  6 * $LicenseInfo:firstyear=2006&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28/**
 29 * This is for specifying objects in the world that are animated and 
 30 * rendered locally - on the viewer. Flexible Objects are linear arrays
 31 * of positions, which stay at a fixed distance from each other. One 
 32 * position is fixed as an "anchor" and is attached to some other object 
 33 * in the world, determined by the server. All the other positions are 
 34 * updated according to local physics. 
 35 */
 36
 37#ifndef LL_LLFLEXIBLEOBJECT_H
 38#define LL_LLFLEXIBLEOBJECT_H
 39
 40#include "llprimitive.h"
 41#include "llvovolume.h"
 42#include "llwind.h"
 43
 44// 10 ms for the whole thing!
 45const F32	FLEXIBLE_OBJECT_TIMESLICE		= 0.003f;
 46const U32	FLEXIBLE_OBJECT_MAX_LOD			= 10;
 47
 48// See llprimitive.h for LLFlexibleObjectData and DEFAULT/MIN/MAX values 
 49
 50//-------------------------------------------------------------------
 51
 52struct LLFlexibleObjectSection
 53{
 54	// Input parameters
 55	LLVector2		mScale;
 56	LLQuaternion	mAxisRotation;
 57	// Simulated state
 58	LLVector3		mPosition;
 59	LLVector3		mVelocity;
 60	LLVector3		mDirection;
 61	LLQuaternion	mRotation;
 62	// Derivatives (Not all currently used, will come back with LLVolume changes to automagically generate normals)
 63	LLVector3		mdPosition;
 64	//LLMatrix4		mRotScale;
 65	//LLMatrix4		mdRotScale;
 66};
 67
 68//---------------------------------------------------------
 69// The LLVolumeImplFlexible class 
 70//---------------------------------------------------------
 71class LLVolumeImplFlexible : public LLVolumeInterface
 72{
 73	public:
 74		LLVolumeImplFlexible(LLViewerObject* volume, LLFlexibleObjectData* attributes);
 75
 76		// Implements LLVolumeInterface
 77		U32 getID() const { return mID; }
 78		LLVector3 getFramePosition() const;
 79		LLQuaternion getFrameRotation() const;
 80		LLVolumeInterfaceType getInterfaceType() const		{ return INTERFACE_FLEXIBLE; }
 81		BOOL doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 82		BOOL doUpdateGeometry(LLDrawable *drawable);
 83		LLVector3 getPivotPosition() const;
 84		void onSetVolume(const LLVolumeParams &volume_params, const S32 detail);
 85		void onSetScale(const LLVector3 &scale, BOOL damped);
 86		void onParameterChanged(U16 param_type, LLNetworkData *data, BOOL in_use, bool local_origin);
 87		void onShift(const LLVector4a &shift_vector);
 88		bool isVolumeUnique() const { return true; }
 89		bool isVolumeGlobal() const { return true; }
 90		bool isActive() const { return true; }
 91		const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const;
 92		void updateRelativeXform();
 93		void doFlexibleUpdate(); // Called to update the simulation
 94		void doFlexibleRebuild(); // Called to rebuild the geometry
 95		void preRebuild();
 96
 97		//void				setAttributes( LLFlexibleObjectData );
 98		void				setParentPositionAndRotationDirectly( LLVector3 p, LLQuaternion r );
 99		void				setUsingCollisionSphere( bool u );
100		void				setCollisionSphere( LLVector3 position, F32 radius );
101		void				setRenderingCollisionSphere( bool r);
102
103		LLVector3			getEndPosition();
104		LLQuaternion		getEndRotation();
105		LLVector3			getNodePosition( int nodeIndex );
106		LLVector3			getAnchorPosition() const;
107
108	private:
109		//--------------------------------------
110		// private members
111		//--------------------------------------
112	    // Backlink only; don't make this an LLPointer.
113		LLViewerObject*				mVO;
114		LLTimer						mTimer;
115		LLVector3					mAnchorPosition;
116		LLVector3					mParentPosition;
117		LLQuaternion				mParentRotation;
118		LLQuaternion				mLastFrameRotation;
119		LLQuaternion				mLastSegmentRotation;
120		BOOL						mInitialized;
121		BOOL						mUpdated;
122		LLFlexibleObjectData*		mAttributes;
123		LLFlexibleObjectSection		mSection	[ (1<<FLEXIBLE_OBJECT_MAX_SECTIONS)+1 ];
124		S32							mInitializedRes;
125		S32							mSimulateRes;
126		S32							mRenderRes;
127		U32							mFrameNum;
128		LLVector3					mCollisionSpherePosition;
129		F32							mCollisionSphereRadius;
130		U32							mID;
131
132		//--------------------------------------
133		// private methods
134		//--------------------------------------
135		void setAttributesOfAllSections	(LLVector3* inScale = NULL);
136
137		void remapSections(LLFlexibleObjectSection *source, S32 source_sections,
138										 LLFlexibleObjectSection *dest, S32 dest_sections);
139		
140public:
141		// Global setting for update rate
142		static F32					sUpdateFactor;
143
144};// end of class definition
145
146
147#endif // LL_LLFLEXIBLEOBJECT_H