Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Vertices and melding (or welding) two objects similar to metaballs

Author
Message
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 31st May 2010 03:53
Okay here's what I'm looking to do and what I've done.

Say I have two spheres. I lock the vertexdata for one sphere and transform all the locations of its vertices into real world lorcations. What I want to do is also perform this on another sphere and raycast the vertex positions to sphere one. If the distance is correct (note that sphere two is being positioned with the mouse) than the vertices are repositioned and welded to sphere one - kind of like metaballing. The trouble I am having is that lock vertexdata can only be done for one object/limb at a time - and in order to keep moving sphere two, I cannot combine mesh data so that it's part of the object/limb currently locked by the vertexdata command. So are there any ideas for melding/welding two objects via vertexdata commands? Any ideas, suggestions or simple examples would help - I don't want you writing a big strip of code just so I can take it I'm only looking for understanding.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 31st May 2010 05:27 Edited at: 2nd Jun 2010 10:51
Okay I think I'm grasping it now... If I make a memblock for the first sphere and store all the vertices' real world positions in it then I can use the vertexdata commands to manipulate the second sphere and tell it's vertices how to act in accordance with the first sphere's vertices.

EDIT:
Om nom nom nom - why can't I get this - seems easy enough now that I 'grasp' dbpro

EDIT ONCE MORE:
Okay here's what I've got. Use the middle mouse button to move the object, right click to rotate, arrow keys to move... what I want to have happen is when you click the mouse and have the object near a certain proximity, the two objects will combine... I'm going for a "Sporeā„¢" Kind of meta-ball limb effect here

Can someone help me out here... I'm kind of lost... many thanks to any who try... really!

EDIT ONCE AGAIN:
OI I don't get it... no one can shed any light on this? Anything at all

-Daryn

EDIT:
okay - now I am doing this


The only thing I can deduce is that it's something to do with the vertices. I've tried leaving them as locals, converting them into 3d space, projecting their positions from the center of both spheres - and nada - all I want them to do is have one static object and the other conform to it when it gets close enough.

If it's something easy that I am over looking, someone point me in the right direction 'cause I've sat and just ran through it in my head and it seems to be right - but this is programming Anyone, really - just give me a heads up.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Jun 2010 12:42
Can't you have the two spheres as limbs of 1 object therefore being able to use memblocks on them?

My signature is NOT a moderator plaything! Stop changing it!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Jun 2010 13:49
Tricky one, no matter how you do it, there is no easy method for this, not in any language.

Might be worth trying to magnetize instead. Well, you could check the vertices in one sphere against the vertices in another sphere, and if 2 vertices are close enough, work out the average position and set both vertices to that. This means that each vertex in a moving sphere would need to find the closest vertex in the static sphere.

You would have some real problems with complex shapes, but spheres might just work well enough, especially geospheres - DBPro's spheres are a bit grid-ish for the job, a geosphere would mould much better (more equi-sized polygons you see).

If this is purely for sticking an arm onto some mad creature, then maybe another angle is needed. For instance, you might have 10 vertexes on the shoulder of an arm that you want to attach, like an open end. Then these vertexes would need to be flagged so you know which ones should mould onto the body shape. So if you have an arm, with the 10 vertexes, you could find the closest 10 vertexes on the body mesh and adjust the positions of your flagged vertexes and the 10 nearest vertexes, maybe average the positions again.


Health, Ammo, and bacon and eggs!
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 2nd Jun 2010 15:44 Edited at: 2nd Jun 2010 16:33
I see what your saying Van B, maybe tell the arm object to close it's end and then spread it and connect when near the sphere. Lord Einstein gave me some help last night and actually got two sphere's to mold together - but they both had to be static and vectors weren't used.

Would it be worth the trouble creating projections from the center of both spheres to their vertices?

(I mean... Say I had only one sphere just to explain this - from the center of the sphere a ray would be cast out to all vertices on that sphere... if another object was doing the same and an intersection occured, the vertices that have collided or obscured the raycast would be moved to the opposing sphere's obscurring vertices and then the poly's deleted) This is so confusing. When I printed these results to the screen, the positions weren't real world - am I transposing vectors right or using the wrong base matrix? I have no clue. Thanks for answering - I thought no one would

EDIT:
Also I figured it wouldn't work but I also tried:


Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 2nd Jun 2010 19:15 Edited at: 2nd Jun 2010 20:32
Ooooh - what's this a new post... oh my... lookie what I have...

om-nom nom nom boogie cheese skillet muffin milf! ha ha!



Took me two days to figure that out - wtf - needed to convert coordinates and not normalize... silly me

Here's a simple example - you can meddle with the camera if you want a better view - speed ain't bad but it could be better...


Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.

Login to post a reply

Server time is: 2026-07-25 16:20:16
Your offset time is: 2026-07-25 16:20:16