sprockets A:M Decaling Screen frosted donut medals buildings Rubik's Cube Nidaros Cathedral Tongue Sandwich
sprockets
Recent Posts | Unread Content | Previous Banner Topics
Jump to content
Hash, Inc. - Animation:Master

Recommended Posts

Posted

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.

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

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

 

 

 

 

Oops !

  • Admin
Posted
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.

Posted

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).

  • Admin
Posted

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.

Posted

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.
  • Hash Fellow
Posted
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.

Posted

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.

Posted

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);
  • Developer
Posted

Should work with

 

HModelCache *hmc;

 

hmc->AttachCPs( cp1, cp2 );

where cp2 is attached to cp1

Posted

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.

Posted

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?

  • Hash Fellow
Posted

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:

  • Hash Fellow
Posted

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:

Posted

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.

  • Hash Fellow
Posted
where cp2 is attached to cp1

 

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

  • Developer
Posted

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 .

Posted

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).

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...