mojo3d: Entity in view?

About Monkey 2 Forums Monkey 2 Programming Help mojo3d: Entity in view?

This topic contains 26 replies, has 4 voices, and was last updated by  DruggedBunny 1 year, 1 month ago.

Viewing 12 posts - 16 through 27 (of 27 total)
  • Author
    Posts
  • #14448

    Cole Chapman
    Participant

    Trying to implement it myself — I have added the class in the bullet module.  I decided to make a new “constraint” class for mojo3d but when I call on the bullet command btPoint2PointConstraint, I get:

    bullet3-2.85.1/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h:77:2: note: no known conversion for argument 1 from ‘btRigidBody*’ to ‘btRigidBody&’

    It passes the btRigidBody(s) and btVector3(s) but appears Var is still not implemented so I am unsure how to pass references instead of pointers.

    Any ideas?

    #14450

    Mark Sibly
    Keymaster

    Can you post the stuff you’ve added to bullet.monkey2 (or all of it)?

    #14452

    Cole Chapman
    Participant

    It’s not anything so far —

    Bullet:

     

    mojo3d/scene/components/constraint:

    #14453

    Mark Sibly
    Keymaster

    Hmm, that’s weird, bullet is using references instead of pointers here.

    The easiest way to deal with this right now is probably to just add pointer versions of the ctors, eg:

    btPoint2PointConstraint(btRigidBody* rbA,btRigidBody* rbB, const btVector3& pivotInA,const btVector3& pivotInB):
    btPoint2PointConstraint(*rbA,*rbB,pivotInA,pivotInB){}

    btPoint2PointConstraint(btRigidBody* rbA,const btVector3& pivotInA):
    btPoint2PointConstraint(*rbA,pivotInA){}

    Add this directly to the btPoint2PointConstraint.h file below the existing ctors – I haven’t tested it but it compiles at least. The nicer way is probably to subclass btPoint2PointConstraint and add the new ctors there, but this should get you going for now.

    No idea why he’s done it this way, the joys of c++!

    #14454

    Mark Sibly
    Keymaster

    Actually, I’m up for having a go at getting a point2point constraint style component (or whatever) going right now, got nothing else on.

    #14455

    Cole Chapman
    Participant

    Aww Yiss!

    #14456

    Mark Sibly
    Keymaster

    I know little to nothing about constraints though! Should I just start with the simple 1 body, 1 pivot point2point type? How does/should this work? What would be a good little demo for this?

    #14457

    Cole Chapman
    Participant

    Maybe DruggedBunny can add some input but this is what I have been looking at:

    btPoint2PointConstraint Class Reference

    Bullet’s Wiki – Constraints

    Convoluted Demo

    Snippet of Panda3D’s Implementation

    Bullet – Chain Tutorial (Using Point2Point/Ball Socket Constraints)

    You could start with either but I feel like the 2 body-2pivot point2point will help you see if it’s actually working or not – not really sure when someone would use 1 body-1 pivot.

    I was thinking of the actual user-facing code looking something like:

    Going to be honest I have never really dealt with constraints and if you need me to find some more examples/references I absolutely will.  Having said all that, Point2Point looks like it really dives right into it and I think once you get this, other constraints like Hinge etc. should be a bit easier – if you’re up for the challenge!

    Edit: Couple more links:

    Bullet Manual – Page 23 (Constraints)

    Bullet – Bridge Tutorial (Uses Point2Point Constraints)

    #14458

    Mark Sibly
    Keymaster

    Attempt #1 is now up at develop!

    There’s a simple test in the tests dir called ‘constraints.monkey2’. It’s just a basic chain of cubes, but it seems to work OK.

    One weird thing is the chain should be ‘anchored’ by the cube at the top, and it sort of is, however the bottom cubes shouldn’t touch the ground but they do a little, not sure what’s up there yet…

    #14467

    Cole Chapman
    Participant

    This is great!  Thank you so much Mark!

    #14469

    DruggedBunny
    Participant

    Cool, works here. It looks correct — guessing the constraints have a little ‘flex’ in them at first glance, rather than being set to a fixed distance? Will dig in…

    EDIT: Hmm, see what you mean…

    #14471

    DruggedBunny
    Participant

    Little bit of debugging output in attached image… not sure what it means yet!

    Once settled, there’s (as expected) ~1.2 distance between each box, with 10 boxes, but their y-position isn’t at the original y-position, so I think the constraints must have a default ‘looseness’ to them. Tried the bullet docs, but they’re impenetrable and don’t actually detail what the constraint settings are for (ERP??).

    Attachments:
Viewing 12 posts - 16 through 27 (of 27 total)

You must be logged in to reply to this topic.