Jump to content
Hash, Inc. Forums
nemyax

SOLVED: Connecting two splines

Recommended Posts

How do I connect two existing splines to create one continuous spline? I don't see any methods to that effect in HModelCache, HCP or HSpline.

Share this post


Link to post
Share on other sites

drag endpoint of one of the splines to the end of the other spline then right click

 

 

 

 

Oops !

Share this post


Link to post
Share on other sites
drag endpoint of one of the splines to the end of the other spline then right click

 

He means programatically with code as opposed to via mouse in the interface.

Short of initiating a macro (or equivalent) that would locate, select and then join the ends of two splines (presumably those that have been selected prior) we have to dig deeper into the API code for the answer to what class or routine can accomplish that for a plugin.

 

Added: It is rather unfortunate that way back when many of the plugin writers of the past carried on their discussions of coding for A:M plugins in a Google Group (or equivalent). As such it's hard to resurrect those discussions and learn from the best practices of the past. I'm sure there are good reasons not to post programming information in public but I fail to see much of the longer term benefits when those resources vanish. I'd guess the dev group I'm thinking of very likely was formed before this forum arrived on the scene and so that was a natural place to post dev info because the regular mailing list of that timeframe wasn't designed for that purpose. If we can recall the url we can often gain access via wayback machine... assuming that a robots.txt entry on the server didn't prevent that archiving from occurring.

Share this post


Link to post
Share on other sites

This looks like an oversight during the preparation of the SDK, because more advanced operations are readily available (such as HModelCache::CopyExtrude), but this basic and important one isn't (apparently).

Share this post


Link to post
Share on other sites

I"d say it's there but just included in another operation.

An example of the process in operation would be that of the Connect plugin that takes any number of splines and connects those that cross each other within a designated distance.

Steffen wrote that plugin so if he can share the code that would reveal the method used to connect those splines.

Share this post


Link to post
Share on other sites

I"d say it's there but just included in another operation.

 

I sure hope so.

 

the Connect plugin that takes any number of splines and connects those that cross each other within a designated distance

There's always the option of building a new spline from CPs whose properties are identical to those of the original CPs. But that's a braindamaged way to do it, because you break group membership, weighting, spline actions and a million other things. Hopefully the Connect plugin doesn't use the method. The host program clearly doesn't.

Share this post


Link to post
Share on other sites
How do I connect two existing splines to create one continuous spline? I don't see any methods to that effect in HModelCache, HCP or HSpline.

 

I've submitted this to AMReports as a "bug", hopefully to get some feedback from Steffen. I'll try submitting this later , something is not working on AMReports for me.

 

 

In the meantime... I know next to zero about the code but perhaps looking at the files can tell us something.

 

It appears that a spline is be held in an array that holds a set of values for each CP. The third value is a CP number followed by XYZ data.

 

Two separate splines appear to be in two separate arrays but when two splines are joined (in this case, CP 4 was dragged onto CP5), the two arrays are concatenated but with the target CP's data deleted after being copied to the dragged CP.

 

twosplines.JPG

 

 

 

But that's a braindamaged way to do it, because you break group membership, weighting, spline actions and a million other things.

 

 

Probably still true with the above but perhaps some more file comparison with simple cases would reveal how the other aspects are accounted for.

Share this post


Link to post
Share on other sites

I'll try submitting this later

Thanks!

 

perhaps looking at the files can tell us something

There's no need. Navigating splines is very easy in the API, but the functions for associating an existing CP with a different spline are nowhere to be seen.

Share this post


Link to post
Share on other sites

It turns out a spline can be considered a CP's parent. For example, this returns the ID of the head CP of mycp's spline:

((HSpline*)(mycp->GetParent()))->GetHeadCP()->GetID()

However, this doesn't seem to work:

mycp->SetParent(myotherspline);

Share this post


Link to post
Share on other sites

Should work with

 

HModelCache *hmc;

 

hmc->AttachCPs( cp1, cp2 );

where cp2 is attached to cp1

Share this post


Link to post
Share on other sites

Thanks, I'll try that. One of the things I tried was to attach the same two CPs with the same argument order twice, but that only crashed A:M.

Share this post


Link to post
Share on other sites

yoda64

Did you mean this should work?

 

hmc->AttachCPs(jack, socket);
hmc->AttachCPs(socket, jack);

Doing this on stacked CPs causes a crash. Doing it on loose ends sends A:M into an infinite loop. Do you have an example of working code that does this right?

Share this post


Link to post
Share on other sites

yoda64

Did you mean this should work?

hmc->AttachCPs(jack, socket);
hmc->AttachCPs(socket, jack);

 

To me, that looks like you are attaching the same two CPs twice. :huh:

Share this post


Link to post
Share on other sites

That's exactly how I understood yoda64's reply.

Share this post


Link to post
Share on other sites

Should work with

 

HModelCache *hmc;

 

hmc->AttachCPs( cp1, cp2 );

 

where cp2 is attached to cp1

 

 

 

I only count one attachment operation going on there. :unsure:

Share this post


Link to post
Share on other sites

I took "where cp2 is attached to cp1" to mean that it's already been attached.

The AttachCPs method doesn't do what I need. Instead of making a single spline it stacks CPs where multiple splines meet.

Share this post


Link to post
Share on other sites
where cp2 is attached to cp1

 

I read that as saying what the result of the operation will be.

Share this post


Link to post
Share on other sites

Sorry for the misleading information . I've looked today into the source and neymax is right there is no method for joining splines (AttachCP's doesn't work for this purpose) .

It's now on the todo , but needs a update for V18 , otherwise it won't work .

Share this post


Link to post
Share on other sites

yoda64

Thanks for looking into it! I'll wait for the A:M and SDK update.

Share this post


Link to post
Share on other sites

Visually, you'd be riding the spline on a 3D curve with a normal perpendicular to your "path" of travel. You would be on a "planned" path of travel by a simple curve or spiral trajectory... in 3D. But then, the path needs to change to meet the requirements of another path (which you know nothing about). That path has a current very simple and understandable vertex location and trajectory with an obvious normal. But has a different "path" predetermined" by "it's" original intent.

 

So, the two have to come together.

 

In 3D, it's, well, twice as hard. So, let's do the 2D example...before moving on to vertical curves.

 

'A' approaches at a slope of 2% (2' per 100') while 'B' is approaching at 1%. The objects are 200' apart. They will intersect at a distance of 66.67' from Point 'A' and 133.33' from Point 'B', right? Fortunately, they're traveling at the same speed! But, unfortunately, it's unfeasible to turn any angle without time... hence the need for "vertical curves".

 

Vertical curves use the very basic quadratic equation and could be easily be looked up on the web, but you won't find a simple answer as to how to program your question. They're called "Vertical Curves" in everyday practices of civil engineering because that's the only place the math was necessary (ie. changing from a 0% slope to 8% on the way to the store is like a roller coaster ride stomach check that you don't want unexpectedly.)

 

But once you figure that part out, the beauty is that the math along each plane of perspective works independently from each other (if that makes any sense).

 

So, if I'm not mistaken...You could do the math to make a line "converge" with another line in "Top" view while someone else makes the same line "converge" in "Front (Back/Right/Left) View"...and it should all work out without any problems. But to look at the actual equation result... I don't know. And I don't know about working with others.

 

Of course, A:M has 4 options (moderator check?) as to how to compute a line "convergence". When I use AutoCAD at work, it's just Fillet and specify a radius (In "Top" View).

Share this post


Link to post
Share on other sites

Steffen has listed 6687 as fixed.

 

I do expect to see some joined splines come out of this. B)

Share this post


Link to post
Share on other sites

Hmmm... it's turning good crossings into bad ones?

Share this post


Link to post
Share on other sites

Thanks to update 18p+ and the accompanying SDK update, this functionality is working now! Thanks for the excellent support.

Here's a little teaser: https://drive.google.com/open?id=0B___ge5IO2Jddk1kY1ZFQ3dMaEE

 

Without destroying the UV map? That would be a very cool thing for exporters/importers :).

 

See you

*Fuchur*

Share this post


Link to post
Share on other sites

It needs some more testing, but yes, generally it preserves UVs and 5-pointers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×