sweepTest How it should be used

The end result of this problem is to use sweepTest for detection.
I started digging through the documentation on sweepTest

I don’t quite understand this example

TransformStart and TransformEnd Those are the two parameters that I don’t understand

What I’m going to test for is animation control how do I get the parameters and pass in sweepTest Do collision detection?

I searched the forums and there were no similar cases…

In your example, those are the start location and end location of the weapon in world space.

What about getting start transform in enableGhostCollision (now should be renamed to getStartTransform) and end transform in disableGhostCollision (now should be renamed to getEndTransform) then do a sweepTest.

1 Like
    public void getStartTransform(){
        SkinningControl modelSkinningControl = ((Node)modelSyana.model).getChild(0).getControl(SkinningControl.class);
        modelSkinningControl.getAttachmentsNode("Bone023").addControl(ghostControl);
    Transform  Start = modelSkinningControl.getSpatial().getWorldTransform();//new Transform(modelSkinningControl.getSpatial().getLocalTranslation());
       
       //ghostControl.setCcdSweptSphereRadius(10f);
         modelSyana.bulletAppState.getPhysicsSpace().add(modelSyana.ghostControl);
         //modelSyana.bulletAppState.getPhysicsSpace().addCollisionListener(this);
         
         
    }
    
    public void getEndTransform(){
        SkinningControl modelSkinningControl = ((Node)modelSyana.model).getChild(0).getControl(SkinningControl.class);
        modelSkinningControl.getAttachmentsNode("Bone023").removeControl(ghostControl);
        Transform End = modelSkinningControl.getSpatial().getWorldTransform();//new Transform(modelSkinningControl.getSpatial().getLocalScale());
        List<PhysicsSweepTestResult> sweep = bulletAppState.getPhysicsSpace().sweepTest(modelSyana.shape,Start,End);

         modelSyana.bulletAppState.getPhysicsSpace().remove(modelSyana.ghostControl);
    }

Transform Start = ?
Transform End = ?

  • Where does the assignment of Transform come from?

  • I just need to sweepTest in getEndTransform, right?

I believe the Start and End I have shown in the code are wrong

modelSkinningControl.getAttachmentsNode("Bone023").getWorlTransform().clone();

or from the weapon object.

Yes.

1 Like

image
Thank you for your help. I have understood how to use it

1 Like

video
You can see it in the video I made three attacks

The first time is to face the target The attack of the weapon missed

The last two attacks were carried out by standing on the side of the model
The weapon hit the target
sweepTest The middle swing animation that is only detected at the beginning and end of the weapon is not detected

:thinking: :thinking: :thinking:
What did I do wrong?

    public void getStartTransform(){
        SkinningControl modelSkinningControl = ((Node)modelSyana.model).getChild(0).getControl(SkinningControl.class);
        //modelSkinningControl.getAttachmentsNode("Bone023").addControl(ghostControl);
       Start = modelSkinningControl.getAttachmentsNode("Bone023").getWorldTransform().clone();//((Node)modelSyana.model.getChild(0)).getChild(0).getWorldTransform();modelSkinningControl.getAttachmentsNode("Bone023").getWorldTransform();
       
 
         
    }
    
    public void getEndTransform(){
        
        List<Vector3f> centers = new ArrayList<>(2);
        centers.add(new Vector3f(0f, 0.5f, 0f));
        centers.add(new Vector3f(-0.5f, 3f, -0.5f));
        List<Float> radii = new ArrayList<>(2);
        radii.add(0.5f);
        radii.add(0.5f);
       MultiSphere   shape = new MultiSphere(centers, radii);
        
        SkinningControl modelSkinningControl = ((Node)modelSyana.model).getChild(0).getControl(SkinningControl.class);
         End =modelSkinningControl.getAttachmentsNode("Bone023").getWorldTransform().clone();//((Node)modelSyana.model.getChild(0)).getChild(0).getWorldTransform(); 
        List<PhysicsSweepTestResult> sweep = bulletAppState.getPhysicsSpace().sweepTest(shape,Start,End);
       
        for(int i=0;i<sweep.size();i++){
        System.err.println(sweep.get(i).getCollisionObject());
        
        }