本文整理汇总了C#中BulletDotNET.btVector3类的典型用法代码示例。如果您正苦于以下问题:C# btVector3类的具体用法?C# btVector3怎么用?C# btVector3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
btVector3类属于BulletDotNET命名空间,在下文中一共展示了btVector3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setGravity
public void setGravity(btVector3 v)
{
if (m_disposed)
throw new ObjectDisposedException(ToString());
BulletAPI_BtDynamicsWorld_setGravity(m_handle,v.Handle);
}
示例2: applyImpulse
public void applyImpulse(btVector3 force, btVector3 rel_pos)
{
if (m_disposed)
throw new ObjectDisposedException(ToString());
BulletAPI_BtRigidBody_applyImpulse(m_handle, force.Handle, rel_pos.Handle);
}
示例3: isInside
public bool isInside(btVector3 pt, float tolerance)
{
if (m_disposed)
throw new ObjectDisposedException(ToString());
return BulletAPI_BtBoxShape_isInside(m_handle, pt.Handle, tolerance);
}
示例4: setAngularLowerLimit
public void setAngularLowerLimit(btVector3 linearLower)
{
if (m_disposed)
throw new ObjectDisposedException(ToString());
BulletAPI_BtGeneric6DofConstraint_setAngularLowerLimit(m_handle, linearLower.Handle);
}
示例5: findOrAddVertex
public int findOrAddVertex(btVector3 vertex, bool removeDuplicateVertices)
{
if (m_disposed)
throw new ObjectDisposedException(ToString());
return BulletAPI_BtTriangleMesh_findOrAddVertex(m_handle, vertex.Handle, removeDuplicateVertices);
}
示例6: applyCentralForce
public void applyCentralForce(btVector3 force)
{
if (m_disposed)
throw new ObjectDisposedException(ToString());
BulletAPI_BtRigidBody_applyCentralForce(m_handle, force.Handle);
}
示例7: rayTest
public void rayTest(btVector3 rayFromWorld, btVector3 rayToWorld, btRayResultCallback resultCallback)
{
if (m_disposed)
throw new ObjectDisposedException(ToString());
BulletAPI_btCollisionWorld_rayTest(m_handle, rayFromWorld.Handle, rayToWorld.Handle, resultCallback.Handle);
}
示例8: addTriangle
public void addTriangle( btVector3 vertex0, btVector3 vertex1, btVector3 vertex2, bool removeDuplicates)
{
if (m_disposed)
throw new ObjectDisposedException(ToString());
BulletAPI_BtTriangleMesh_addTriangle(m_handle, vertex0.Handle, vertex1.Handle, vertex2.Handle,
removeDuplicates);
}
示例9: btRigidBody
public btRigidBody(float mass, btMotionState motionState, btCollisionShape collisionShape, btVector3 localInertia)
{
m_constructionInfo = new btRigidBodyConstructionInfo();
m_constructionInfo.m_collisionShape = collisionShape;
m_constructionInfo.m_localInertia = localInertia;
m_constructionInfo.m_motionState = motionState;
m_constructionInfo.m_startWorldTransform = btTransform.getIdentity();
m_constructionInfo.SetGenericDefaultValues();
m_constructionInfo.m_mass = mass;
m_constructionInfo.commit();
m_handle = BulletAPI_CreateBtRigidBody(m_constructionInfo.Handle);
}
示例10: changeAddAngularForce
private void changeAddAngularForce(float timestep)
{
if (!m_isSelected)
{
lock (m_angularforcelist)
{
//m_log.Info("[PHYSICS]: dequeing forcelist");
if (IsPhysical)
{
Vector3 iforce = Vector3.Zero;
for (int i = 0; i < m_angularforcelist.Count; i++)
{
iforce = iforce + m_angularforcelist[i];
}
if (Body != null && Body.Handle != IntPtr.Zero)
{
if (tempAddForce != null && tempAddForce.Handle != IntPtr.Zero)
tempAddForce.Dispose();
enableBodySoft();
tempAddForce = new btVector3(iforce.X, iforce.Y, iforce.Z);
Body.applyTorqueImpulse(tempAddForce);
}
}
m_angularforcelist.Clear();
}
m_collisionscore = 0;
m_interpenetrationcount = 0;
}
m_taintaddangularforce = false;
}
示例11: SetTerrain
public override void SetTerrain(float[] heightMap, double[,] normalHeightMap)
{
if (m_terrainShape != null)
DeleteTerrain();
float hfmax = -9000;
float hfmin = 90000;
for (int i = 0; i <heightMap.Length;i++)
{
if (Single.IsNaN(heightMap[i]) || Single.IsInfinity(heightMap[i]))
{
heightMap[i] = 0f;
}
hfmin = (heightMap[i] < hfmin) ? heightMap[i] : hfmin;
hfmax = (heightMap[i] > hfmax) ? heightMap[i] : hfmax;
}
// store this for later reference.
// Note, we're storing it after we check it for anomolies above
_origheightmap = heightMap;
hfmin = 0;
hfmax = 256;
m_terrainShape = new btHeightfieldTerrainShape((int)Constants.RegionSize, (int)Constants.RegionSize, heightMap,
1.0f, hfmin, hfmax, (int)btHeightfieldTerrainShape.UPAxis.Z,
(int)btHeightfieldTerrainShape.PHY_ScalarType.PHY_FLOAT, false);
float AabbCenterX = Constants.RegionSize/2f;
float AabbCenterY = Constants.RegionSize/2f;
float AabbCenterZ = 0;
float temphfmin, temphfmax;
temphfmin = hfmin;
temphfmax = hfmax;
if (temphfmin < 0)
{
temphfmax = 0 - temphfmin;
temphfmin = 0 - temphfmin;
}
else if (temphfmin > 0)
{
temphfmax = temphfmax + (0 - temphfmin);
//temphfmin = temphfmin + (0 - temphfmin);
}
AabbCenterZ = temphfmax/2f;
if (m_terrainPosition == null)
{
m_terrainPosition = new btVector3(AabbCenterX, AabbCenterY, AabbCenterZ);
}
else
{
try
{
m_terrainPosition.setValue(AabbCenterX, AabbCenterY, AabbCenterZ);
}
catch (ObjectDisposedException)
{
m_terrainPosition = new btVector3(AabbCenterX, AabbCenterY, AabbCenterZ);
}
}
if (m_terrainMotionState != null)
{
m_terrainMotionState.Dispose();
m_terrainMotionState = null;
}
m_terrainTransform = new btTransform(QuatIdentity, m_terrainPosition);
m_terrainMotionState = new btDefaultMotionState(m_terrainTransform);
TerrainBody = new btRigidBody(0, m_terrainMotionState, m_terrainShape);
TerrainBody.setUserPointer((IntPtr)0);
m_world.addRigidBody(TerrainBody);
}
示例12: SetBody
public void SetBody(float mass)
{
if (!IsPhysical || childrenPrim.Count == 0)
{
if (tempMotionState1 != null && tempMotionState1.Handle != IntPtr.Zero)
tempMotionState1.Dispose();
if (tempTransform2 != null && tempTransform2.Handle != IntPtr.Zero)
tempTransform2.Dispose();
if (tempOrientation2 != null && tempOrientation2.Handle != IntPtr.Zero)
tempOrientation2.Dispose();
if (tempPosition2 != null && tempPosition2.Handle != IntPtr.Zero)
tempPosition2.Dispose();
tempOrientation2 = new btQuaternion(_orientation.X, _orientation.Y, _orientation.Z, _orientation.W);
tempPosition2 = new btVector3(_position.X, _position.Y, _position.Z);
tempTransform2 = new btTransform(tempOrientation2, tempPosition2);
tempMotionState1 = new btDefaultMotionState(tempTransform2, _parent_scene.TransZero);
if (tempInertia1 != null && tempInertia1.Handle != IntPtr.Zero)
tempInertia1.Dispose();
tempInertia1 = new btVector3(0, 0, 0);
prim_geom.calculateLocalInertia(mass, tempInertia1);
if (mass != 0)
_parent_scene.addActivePrim(this);
else
_parent_scene.remActivePrim(this);
// Body = new btRigidBody(mass, tempMotionState1, prim_geom);
//else
Body = new btRigidBody(mass, tempMotionState1, prim_geom, tempInertia1);
if (prim_geom is btGImpactMeshShape)
{
((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1, 1, 1));
((btGImpactMeshShape)prim_geom).updateBound();
}
//Body.setCollisionFlags(Body.getCollisionFlags() | (int)ContactFlags.CF_CUSTOM_MATERIAL_CALLBACK);
//Body.setUserPointer((IntPtr) (int)m_localID);
_parent_scene.AddPrimToScene(this);
}
else
{
// bool hasTrimesh = false;
lock (childrenPrim)
{
foreach (BulletDotNETPrim chld in childrenPrim)
{
if (chld == null)
continue;
// if (chld.NeedsMeshing())
// hasTrimesh = true;
}
}
//if (hasTrimesh)
//{
ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
// createmesh returns null when it doesn't mesh.
/*
if (_mesh is Mesh)
{
}
else
{
m_log.Warn("[PHYSICS]: Can't link a OpenSim.Region.Physics.Meshing.Mesh object");
return;
}
*/
foreach (BulletDotNETPrim chld in childrenPrim)
{
if (chld == null)
continue;
Vector3 offset = chld.Position - Position;
Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z);
pos *= Quaternion.Inverse(Orientation);
//pos *= Orientation;
offset = pos;
chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
_mesh.Append(chld._mesh);
}
setMesh(_parent_scene, _mesh);
//}
if (tempMotionState1 != null && tempMotionState1.Handle != IntPtr.Zero)
tempMotionState1.Dispose();
if (tempTransform2 != null && tempTransform2.Handle != IntPtr.Zero)
tempTransform2.Dispose();
//.........这里部分代码省略.........
示例13: BulletDotNETScene
public BulletDotNETScene(string sceneIdentifier)
{
BulletLock = new object();
// m_sceneIdentifier = sceneIdentifier;
VectorZero = new btVector3(0, 0, 0);
QuatIdentity = new btQuaternion(0, 0, 0, 1);
TransZero = new btTransform(QuatIdentity, VectorZero);
m_gravity = new btVector3(0, 0, gravityz);
}
示例14: AvatarGeomAndBodyCreation
/// <summary>
/// This creates the Avatar's physical Surrogate at the position supplied
/// </summary>
/// <param name="npositionX"></param>
/// <param name="npositionY"></param>
/// <param name="npositionZ"></param>
// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
// place that is safe to call this routine AvatarGeomAndBodyCreation.
private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
{
if (CAPSULE_LENGTH <= 0)
{
m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
CAPSULE_LENGTH = 0.01f;
}
if (CAPSULE_RADIUS <= 0)
{
m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
CAPSULE_RADIUS = 0.01f;
}
Shell = new btCapsuleShape(CAPSULE_RADIUS, CAPSULE_LENGTH);
if (m_bodyPosition == null)
m_bodyPosition = new btVector3(npositionX, npositionY, npositionZ);
m_bodyPosition.setValue(npositionX, npositionY, npositionZ);
if (m_bodyOrientation == null)
m_bodyOrientation = new btQuaternion(m_CapsuleOrientationAxis, (Utils.DEG_TO_RAD * 90));
if (m_bodyTransform == null)
m_bodyTransform = new btTransform(m_bodyOrientation, m_bodyPosition);
else
{
m_bodyTransform.Dispose();
m_bodyTransform = new btTransform(m_bodyOrientation, m_bodyPosition);
}
if (m_bodyMotionState == null)
m_bodyMotionState = new btDefaultMotionState(m_bodyTransform);
else
m_bodyMotionState.setWorldTransform(m_bodyTransform);
m_mass = Mass;
Body = new btRigidBody(m_mass, m_bodyMotionState, Shell);
// this is used for self identification. User localID instead of body handle
Body.setUserPointer(new IntPtr((int)m_localID));
if (ClosestCastResult != null)
ClosestCastResult.Dispose();
ClosestCastResult = new ClosestNotMeRayResultCallback(Body);
m_parent_scene.AddRigidBody(Body);
Body.setActivationState(4);
if (m_aMotor != null)
{
if (m_aMotor.Handle != IntPtr.Zero)
{
m_parent_scene.getBulletWorld().removeConstraint(m_aMotor);
m_aMotor.Dispose();
}
m_aMotor = null;
}
m_aMotor = new btGeneric6DofConstraint(Body, m_parent_scene.TerrainBody,
m_parent_scene.TransZero,
m_parent_scene.TransZero, false);
m_aMotor.setAngularLowerLimit(m_parent_scene.VectorZero);
m_aMotor.setAngularUpperLimit(m_parent_scene.VectorZero);
}
示例15: btBoxShape
public btBoxShape(btVector3 boxHalfExtents)
: base()
{
m_handle = BulletAPI_CreateBtBoxShape(boxHalfExtents.Handle);
}