当前位置: 首页>>代码示例>>C#>>正文


C# btVector3.setValue方法代码示例

本文整理汇总了C#中btVector3.setValue方法的典型用法代码示例。如果您正苦于以下问题:C# btVector3.setValue方法的具体用法?C# btVector3.setValue怎么用?C# btVector3.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在btVector3的用法示例。


在下文中一共展示了btVector3.setValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: drawAabb

		public virtual void drawAabb( ref btVector3 from, ref btVector3 to, ref btVector3 color )
		{

			btVector3 halfExtents; to.SubAndScale( ref from, 0.5f, out halfExtents );
			btVector3 center; to.AddAndScale( ref from, 0.5f, out center );
			int i, j;

			btVector3 edgecoord = new btVector3( 1f, 1f, 1f ), pa, pb;
			for( i = 0; i < 4; i++ )
			{
				for( j = 0; j < 3; j++ )
				{
					edgecoord.Mult( ref halfExtents, out pa );
					pa.Add( ref center, out pa );


					int othercoord = j % 3;
					edgecoord[othercoord] *= -1f;

					edgecoord.Mult( ref halfExtents, out pb );
					pb.Add( ref center, out pb );

					drawLine( ref pa, ref pb, ref color );
				}
				edgecoord.setValue( -1, -1, -1 );
				if( i < 3 )
					edgecoord[i] *= -1;
			}
		}
开发者ID:d3x0r,项目名称:Voxelarium,代码行数:29,代码来源:IDebugDraw.cs

示例2: getBroadphaseAabb

		///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
		///will add some transform later
		virtual void getBroadphaseAabb( ref btVector3 aabbMin, ref btVector3 aabbMax )
		{
			aabbMin.setValue( -BT_LARGE_FLOAT, -BT_LARGE_FLOAT, -BT_LARGE_FLOAT );
			aabbMax.setValue( BT_LARGE_FLOAT, BT_LARGE_FLOAT, BT_LARGE_FLOAT );
		}
开发者ID:d3x0r,项目名称:Voxelarium,代码行数:7,代码来源:SimpleBroadphase.h.cs

示例3: calculateLocalInertia

		public override void calculateLocalInertia( double mass, out btVector3 inertia )
		{

			//Until Bullet 2.77 a box approximation was used, so uncomment this if you need backwards compatibility
			//#define USE_BOX_INERTIA_APPROXIMATION 1
#if !USE_BOX_INERTIA_APPROXIMATION

			/*
			cylinder is defined as following:
			*
			* - principle axis aligned along y by default, radius in x, z-value not used
			* - for btCylinderShapeX: principle axis aligned along x, radius in y direction, z-value not used
			* - for btCylinderShapeZ: principle axis aligned along z, radius in x direction, y-value not used
			*
			*/

			double radius2; // square of cylinder radius
			double height2; // square of cylinder height
			btVector3 halfExtents; getHalfExtentsWithMargin( out halfExtents ); // get cylinder dimension
			double div12 = mass / 12.0f;
			double div4 = mass / 4.0f;
			double div2 = mass / 2.0f;
			int idxRadius, idxHeight;

			switch( m_upAxis )  // get indices of radius and height of cylinder
			{
				case 0:     // cylinder is aligned along x
					idxRadius = 1;
					idxHeight = 0;
					break;
				case 2:     // cylinder is aligned along z
					idxRadius = 0;
					idxHeight = 2;
					break;
				default:    // cylinder is aligned along y
					idxRadius = 0;
					idxHeight = 1;
					break;
			}

			// calculate squares
			radius2 = halfExtents[idxRadius] * halfExtents[idxRadius];
			height2 = (double)( 4.0 ) * halfExtents[idxHeight] * halfExtents[idxHeight];

			// calculate tensor terms
			double t1 = div12 * height2 + div4 * radius2;
			double t2 = div2 * radius2;

			switch( m_upAxis )  // set diagonal elements of inertia tensor
			{
				case 0:     // cylinder is aligned along x
					btVector3.setValue( out inertia, t2, t1, t1 );
					break;
				case 2:     // cylinder is aligned along z
					btVector3.setValue( out inertia, t1, t1, t2 );
					break;
				default:    // cylinder is aligned along y
					btVector3.setValue( out inertia, t1, t2, t1 );
					break;
			}
#else //USE_BOX_INERTIA_APPROXIMATION
			//approximation of box shape
			btVector3 halfExtents; getHalfExtentsWithMargin( out halfExtents );

			double lx = (double)( 2.0) * ( halfExtents.x );
			double ly = (double)( 2.0) * ( halfExtents.y );
			double lz = (double)( 2.0) * ( halfExtents.z );

			inertia.setValue( mass / ( (double)( 12.0 ) ) * ( ly * ly + lz * lz ),
							mass / ( (double)( 12.0 ) ) * ( lx * lx + lz * lz ),
							mass / ( (double)( 12.0 ) ) * ( lx * lx + ly * ly ) );
#endif //USE_BOX_INERTIA_APPROXIMATION
		}
开发者ID:d3x0r,项目名称:Voxelarium,代码行数:73,代码来源:CylinderShape.cs

示例4: calculatePrincipalAxisTransform

		///computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia
		///and the center of mass to the current coordinate system. "masses" points to an array of masses of the children. The resulting transform
		///"principal" has to be applied inversely to all children transforms in order for the local coordinate system of the compound
		///shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform
		///of the collision object by the principal transform.
		void calculatePrincipalAxisTransform( double[] masses, ref btTransform principal, ref btVector3 inertia )
		{
			int n = m_children.Count;

			double totalMass = 0;
			btVector3 center = btVector3.Zero;
			int k;

			for( k = 0; k < n; k++ )
			{
				Debug.Assert( masses[k] > 0 );
				center.AddScale( ref m_children[k].m_transform.m_origin, masses[k], out center );
				totalMass += masses[k];
			}

			Debug.Assert( totalMass > 0 );

			center /= totalMass;
			principal.setOrigin( ref center );

			btMatrix3x3 tensor = new btMatrix3x3( 0, 0, 0, 0, 0, 0, 0, 0, 0);
			for( k = 0; k < n; k++ )
			{
				btVector3 i;
				m_children[k].m_childShape.calculateLocalInertia( masses[k], out i );

				btTransform t = m_children[k].m_transform;
				btVector3 o; t.m_origin.Sub(ref center, out o );

				//compute inertia tensor in coordinate system of compound shape
				btMatrix3x3 j; t.m_basis.transpose( out j);
				j.m_el0 *= i.x;
				j.m_el1 *= i.y;
				j.m_el2 *= i.z;
				btMatrix3x3 j2;
				t.m_basis.Mult( ref j, out j2 );

				//add inertia tensor
				tensor.m_el0 += j2.m_el0;
				tensor.m_el1 += j2.m_el1;
				tensor.m_el2 += j2.m_el2;

				//compute inertia tensor of pointmass at o
				double o2 = o.length2();
				j[0].setValue( o2, 0, 0 );
				j[1].setValue( 0, o2, 0 );
				j[2].setValue( 0, 0, o2 );
				j.m_el0 += o * -o.x;
				j.m_el1 += o * -o.y;
				j.m_el2 += o * -o.z;

				//add inertia tensor of pointmass
				tensor.m_el0.AddScale( ref j.m_el0, masses[k], out tensor.m_el0 );
				tensor.m_el1.AddScale( ref j.m_el1, masses[k], out tensor.m_el1 );
				tensor.m_el2.AddScale( ref j.m_el2, masses[k], out tensor.m_el2 );
			}

			tensor.diagonalize( out  principal.m_basis, (double)( 0.00001 ), 20 );
			inertia.setValue( tensor[0][0], tensor[1][1], tensor[2][2] );
		}
开发者ID:d3x0r,项目名称:Voxelarium,代码行数:65,代码来源:CompoundShape.cs


注:本文中的btVector3.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。