iam using this version of the raycast
space.RayCast(raio, maxDistance, Filter, results)
the filter is a function like this
private bool Filter(BroadPhaseEntry entry)
{
...
}
supose i want the raycast to work only with Static meshes, i should use this filter ? how can i know what the BroadPhaseEntry is ? lots of "IS A" in the code? this will run for each objecct "near" the ray, would be slow ?
---
PloobsEngine Released: http://ploobs.com.br/?p=504
[Raycast] How to use the filter function
[Raycast] How to use the filter function
Last edited by thiago on Sat Apr 02, 2011 6:04 pm, edited 2 times in total.
Re: [Raycast] How to use the filter function
More questions.
in the last version i used:
space.BroadPhase.GetEntities(new BoundingSphere(po.Position,distance),ent);
to get the entities inside a bounding sphere, how can i do this now ?
[edit] space.BroadPhase.QueryAccelerator ? i found ...
--
and to detect the colisions happening with an entity
Entity.CollisionPairs and iterate throw it
how now ?
iam using
foreach (var item in bo.Entity.CollisionInformation.OverlappedCollidables)
to recover the entities and the triangles meshes i need to
check if the collidable is EntityCollidable and if it is i recover the entity ? Also check if it is a StaticMesh ....
too many casts, iam afraid >.<
BroadphaseEntry can be a Collidable
Collidable can be Static Mesh and EntityCollidable (in my case now)
EntityCollidable has an entity
the entity has the tag (where i put my game object)
look at my code
is there another way ?
--
I cant put scale in the entity.WorldTransform matrix
and in the static mesh constructor ? can i ?
triangleGroup = new StaticMesh(vertices, indices, new AffineTransform(scale, Quaternion.CreateFromRotationMatrix(rotation), position));
it works ? or i need to apply the scale by hand (multiplying all vertices) ?
thanks as always
---
PloobsEngine Released: http://ploobs.com.br/?p=504
in the last version i used:
space.BroadPhase.GetEntities(new BoundingSphere(po.Position,distance),ent);
to get the entities inside a bounding sphere, how can i do this now ?
[edit] space.BroadPhase.QueryAccelerator ? i found ...
--
and to detect the colisions happening with an entity
Entity.CollisionPairs and iterate throw it
how now ?
iam using
foreach (var item in bo.Entity.CollisionInformation.OverlappedCollidables)
to recover the entities and the triangles meshes i need to
check if the collidable is EntityCollidable and if it is i recover the entity ? Also check if it is a StaticMesh ....
too many casts, iam afraid >.<
BroadphaseEntry can be a Collidable
Collidable can be Static Mesh and EntityCollidable (in my case now)
EntityCollidable has an entity
the entity has the tag (where i put my game object)
look at my code
Code: Select all
internal static IPhysicObject RecoverFromBroadPhaseEntry(BroadPhaseEntry entry)
{
IPhysicObject phyObj = null;
if (entry is Collidable)
{
Collidable collidable = (entry as Collidable);
if (collidable is EntityCollidable)
{
phyObj = (collidable as EntityCollidable).Entity.Tag as IPhysicObject;
}
if (collidable is StaticMesh)
{
phyObj = (collidable as StaticMesh).Tag as IPhysicObject;
}
}
return phyObj;
}
--
I cant put scale in the entity.WorldTransform matrix
and in the static mesh constructor ? can i ?
triangleGroup = new StaticMesh(vertices, indices, new AffineTransform(scale, Quaternion.CreateFromRotationMatrix(rotation), position));
it works ? or i need to apply the scale by hand (multiplying all vertices) ?
thanks as always
---
PloobsEngine Released: http://ploobs.com.br/?p=504
Re: [Raycast] How to use the filter function
Using "is" or an "as" followed by a null check would suffice. I wouldn't worry about performance too much. The type checking will take a matter of dozens of nanoseconds. Unless there are many, many thousands of such queries per frame, it will be unnoticeable.supose i want the raycast to work only with Static meshes, i should use this filter ? how can i know what the BroadPhaseEntry is ? lots of "IS A" in the code? this will run for each objecct "near" the ray, would be slow ?
Yup!to get the entities inside a bounding sphere, how can i do this now ?
[edit] space.BroadPhase.QueryAccelerator ? i found ...
While I wouldn't worry about performance here either (unless it's happening every frame on every object), I do agree that it's pretty annoying to do that amount of casting to grab a tag.check if the collidable is EntityCollidable and if it is i recover the entity ? Also check if it is a StaticMesh ....
How about adding a Tag to the BroadPhaseEntry itself? It appears that that would avoid the casting issues entirely.
Correct; that property is designed to only accept rigid transformations, since an entity's state is defined using rigid transforms (orientation and position). If you need to transform a convex shape using any arbitrary linear transform, consider using the TransformableShape (or TransformableEntity for convenience).I cant put scale in the entity.WorldTransform matrix
That should work fine. Applying it by hand would work as well, or multiplying multiple transformation matrices to construct the AffineTransform. StaticMeshes are designed to use AffineTransforms, unlike Entities. AffineTransforms are a superset of RigidTransforms. In addition to the rigid transform's orientation and position, affine transforms offer uniform or non-uniform scaling and shearing.and in the static mesh constructor ? can i ?
triangleGroup = new StaticMesh(vertices, indices, new AffineTransform(scale, Quaternion.CreateFromRotationMatrix(rotation), position));
it works ? or i need to apply the scale by hand (multiplying all vertices) ?
Re: [Raycast] How to use the filter function
I went ahead and pushed a new version to the development fork which includes a tag on all BroadPhaseEntries, you can grab it here: http://bepuphysics.codeplex.com/SourceC ... evelopment
Re: [Raycast] How to use the filter function
iam getting some compile error trying to compile this version you posted
in MeshingBoundingBoxTree.cs
Error 1 The namespace 'BEPUphysics.DataStructures' already contains a definition for 'MeshBoundingBoxTree' C:\Users\tpastor\Desktop\bepuCode\BEPUphysics\DataStructures\Deprecated\MeshBoundingBoxTree.cs 23 18 BEPUphysics
Error 2 The type 'BEPUphysics.DataStructures.MeshBoundingBoxTree' already contains a definition for 'Node' C:\Users\tpastor\Desktop\bepuCode\BEPUphysics\DataStructures\Deprecated\MeshBoundingBoxTree.cs 724 25 BEPUphysics
i just cloned the repo, unloaded the w7 and xbox projects and compiled.
--
PloobsEngine released
http://ploobsengine.codeplex.com/
in MeshingBoundingBoxTree.cs
Error 1 The namespace 'BEPUphysics.DataStructures' already contains a definition for 'MeshBoundingBoxTree' C:\Users\tpastor\Desktop\bepuCode\BEPUphysics\DataStructures\Deprecated\MeshBoundingBoxTree.cs 23 18 BEPUphysics
Error 2 The type 'BEPUphysics.DataStructures.MeshBoundingBoxTree' already contains a definition for 'Node' C:\Users\tpastor\Desktop\bepuCode\BEPUphysics\DataStructures\Deprecated\MeshBoundingBoxTree.cs 724 25 BEPUphysics
i just cloned the repo, unloaded the w7 and xbox projects and compiled.
--
PloobsEngine released
http://ploobsengine.codeplex.com/
Re: [Raycast] How to use the filter function
Yeah sorry about that, after fixing the WP7/Xbox360 versions I forgot that I had enabled compilation on the Windows versions for testing
To fix it, just right click on the DataStructures/Deprecated trees and set their build action to none.
To fix it, just right click on the DataStructures/Deprecated trees and set their build action to none.