Syncing nodes for float-chunked-double based world (Resolevd)

Hey, so, I’m liking jme3 so far, but I ran into a bit of a hiccup, I’ve seen this talked about before, float-based physics and rendering in a double-based world, and recently it was implemented in space engineers: and so I started pseudocoding a DoubleNode(because I didnt want to have to deal with handling controls for each and every node i want to have support for traveling between clusters: public class DoubleNode extends Node { private double x, y, z; @Override public void updateLogicalState(float tpf){ super.updateLogicalState(tpf); if(isOutOf10000()){ Node[] clusters = ClusterHandler.getOccupiedClusters(x, y, z); for(Node cluster : clusters){ if(/*clone doesnt exist in cluster*/false){ //get relative float position //clone doublenode //pass relative position to clone //cluster.attach(clone); } } if(/*speed is high enough*/false){ ClusterHandler.changeCluster(this); } if(isAtSwitchZone()){ ClusterHandler.changeCluster(this); } }else{ if(isAtKillZone()){ removeFromParent(); } } } private boolean isAtKillZone() { return false; } private boolean isAtSwitchZone() { return false; } private boolean isOutOf10000() { return false; } }
Basically, each cluster is 10km without interfering with other clusters, there’s 3km of overlap on either side, if an object is traveling fast enough, it will transition to the next node as soon as possible, if not, it will wait until the switchZone. If a node is within the overlap, it will clone itself into the other clusters, however, I dont know how i should sync those nodes between clusters, otherwise you’d be fighting out in the skies and a ship would just disappear, it would be aggravating. (no, I havent gotten too far into the class, yes, I want to catch problems early on) I hope I’ve explained my problem well enough, thanks for any and all support :slight_smile:

PS if I seem down, it’s because it’s because it’s 11:37, and annoying code problems are annoying, XD, and I’ve already done my fair share of googling :frowning:

And if I used the world revolves around the player approach, I don’t know how multiplayer or physics friendly it would be

In a general sense, I think you are mixing visualization with game objects here. The node shouldn’t have to know about the double coordinates because the double coordinates are part of the game object. They get synched (using some formula) to the view based on current location relative to camera or whatever. You visual area gets built from game objects that are relative to some local location… and thus can be float just fine.

Basically, the camera stays still and the world moves around you. Everything becomes relative to the camera.

And as for the physics question, physics can be applied local to a node as well, so no problem moving the world around the player.

Thanks for the response, but I had those doubles there to save world position, so it knew which clusters it’d occupy, if that’s what you meant. And I see now, how you’d make the world move around the player. :slight_smile:

Okay, but do you think you could give me a small example, I’m looping through the possibilities and I’m coming up with nothing, thanks for the help!
Edit: Oh wait I think I know what you mean now, but if you just applied physics locally, is there any easy/built-in way to add a rigidbody to the player? If per-say he was hit by a boulder ? :stuck_out_tongue: Or retrieve how far the player should move?

Yes, but world position is an attribute of your game objects. It is not an attribute of the ‘view’. Extending Node is usually a sign of a bad design… and in this case it’s a sign that you are improperly mixing ‘model’ and ‘view’ (in the MVC sense).

Technically, wouldn’t I be mixing model and controller, not view and controller? (if i understand correctly, sorry, kinda new to the whole thing) I only did it that way because it made more sense in my head to just extend node to so anything extending doublenode would automatically have the cluster control working in the background, and I wouldnt have to create extra control objects and atttach them to any node I’d want traveling between clusters, I just thought it would clean up the code a bit, But since I find myself leaning towardss the world-around-player approach, I guess it’s obsolete :confused:

Nodes are definitely a view. If you had a control that copied the position from your model to your Node then you’d have a controller… which would be the control (name is not a coincidence).

Okay, thank you, but I’m saying I did it that way only because it’s cleaner (in my opnion) just extending doublenode is less work than attaching a controller to each node I want to have double support, just about what helps me sleep at the end of the day, haha, if it helps you, I did start out trying to use a controller, but I found this better for me, but I get where you’re coming from :wink: As for physics being applied to the player, have any hints or tips that could save me a few breathers? :smiley:

Well, it’s only cleaner because you are using Node as a game object. When your game objects have more than just position, it will start to get more and more unclean. Then someday you’ll want to change your view or move the model to the server and have to reimplement everything… then you’ll be all “man, if I’d only listened and not implemented this dirty clean design…” :wink:

Yes, I will use AbstractControl for other things, but I made the exception here because it’s so universal, and the double support was all I planned for that, nothing else. But like I said, it’s obsolete at this point. Now, back to the topic, if oyu happen to know about applying physics to the player in an world around player environment off the top of your head, could you PLEASE give me some pointers? And btw, clean and dirty are relative :wink:

Either use

Or use the raw Physics Objects and apply it to the scene yourself:

Thank you for the help! I’ll get back to you on how it works out for me :smiley: