mojo3d: set child to have no parent?

About Monkey 2 Forums Monkey 2 Programming Help mojo3d: set child to have no parent?

This topic contains 7 replies, has 3 voices, and was last updated by  DruggedBunny 1 year, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12905

    DruggedBunny
    Participant

    I’m trying to create a child entity at a parent entity’s position, then remove the parent/child relationship to leave the child at the same scene hierarchy level as the parent.

    Setting child.Parent to Null, however, removes it from the scene, as per Property Parent:Entity() -> Setter().

    Logic here is that in Blitz3D, SetParent (entity, 0) would make the world/scene the child’s new parent, freeing it from the parent’s local space yet leaving it in the scene, in global space.

    This test shows that ‘parent’ has no parent, yet isn’t removed from the scene, and I basically want ‘child’ to end up in that same state after positioning, ie. it then has no parent, but remains in the scene with equal relationship to scene as ‘parent’…

    #12906

    DruggedBunny
    Participant

    I guess I want to make it a member of Scene.RootEntities? Is it safe to just do Scene.RootEntities.Add (entity)? Feels like setting parent to Null should do that, though, like parent’s Null status, above.

    EDIT: Nah, that’s not allowed, being private!

    #12907

    Simon Armstrong
    Participant

    I got round this issue by creating a parentless entity (not a model) which I called hidden.

    By parenting any models I didn’t want in the scene to this entity they became hidden and then could be used for templates and the like.

    #12908

    DruggedBunny
    Participant

    Hmm, guess I could do that. Wondering if it’s intended, though, as it seems weird not to be able to place into same hierarchy level as default entities.

    #12909

    DruggedBunny
    Participant

    That doesn’t do it for me — I create a nonentity:Entity and hit space to set as child’s parent, but it still just disappears:

    #12910

    DruggedBunny
    Participant

    Not actually trying to hide things here, by the way — I want child to pick up parent’s position/rotation in the world, then be freed from parent: as in create bullet at end of gun, then free from parent so I can fire independent of parent’s future movement.

    In my case, ‘gun’ means 5 units in front of current camera position at current rotation!

    #12911

    Mark Sibly
    Keymaster

    There are basically 2 problems here.

    Base Entity class defaults to hidden so ‘nonentity’ (and all it’s children) are hidden. I will probably add a ‘Pivot’ style subclass shows itself, but in the meantime if you’re using an entity as a pivot you’ll need to manually set entity.Visible=True. It’s useful right now for entities to default to hidden for various reasons.

    Also, mojo3d isn’t really thinking about what an entities matrix should be after changing it’s parent. I’ll probably change this so if you set an entities parent to null, it retains it’s world matrix and if you set it to non-null it retains its local matrix – make sense?

    With this is mind, this works for me in v1.1.09:

    This stuff should be fixed soon.

    #12912

    DruggedBunny
    Participant

    In my last version, adding the nonentity.Visible = True suggestion doesn’t actually work (still disappears), though your last matrix code seems to do it.

    But, yeah, I think what you’re saying there regarding keeping the world matrix is what I was after!

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.