Bifrost Forum

Welcome to the Bifrost Forum. This is the place for artists using Bifrost to ask and answer questions, browse popular topics, and share knowledge about creating effects procedurally using Bifrost.
You can also visit the Bifrost Community on AREA to download an array of ready-to-use graphs, read Bifrost news and updates, and find the latest tutorials.

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

This page has been translated for your convenience with an automatic translation service. This is not an official translation and may contain errors and inaccurate translations. Autodesk does not warrant, either expressly or implied, the accuracy, reliability or completeness of the information translated by the machine translation service and will not be liable for damages or losses caused by the trust placed in the translation service.
Translate

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Message 1 of 13

07-20-2020
02:47 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-20-2020
02:47 AM

I'd like to use Maya's *implicit* objects as locators to control the influence of deformers and fields:

- implicitSphere

- implicitCube

- implicitCone

These objects have size attributes (e.g. radius, cone angle) and transformation attributes (a transform node).

Unfortunately, I can't just import them into the Bifrost Graph.

How can I use these objects in Bifrost?

How do I calculate e.g. how close a point is to an implicitSphere's center considering the sphere's transformation?

Solved! Go to Solution.

Solved by Grahame_Fuller. Go to Solution.

12 REPLIES 12

Message 2 of 13

07-20-2020
03:12 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-20-2020
03:12 AM

Isnt the extrude compound using an influence objet?

https://area.autodesk.com/downloads/extrude/#

----------------------------------------------------------------

https://linktr.ee/cg_oglu

https://linktr.ee/cg_oglu

Message 3 of 13

07-20-2020
03:33 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-20-2020
03:33 AM

No, it is just a location and a dropoff value.

I could wire a locator's position and maybe a scaling value.

But for example the implicitCone has a specific shape (same with non uniform scale on all objects).

Even for the moved/rotated/scaled sphere I don't know how to calculate if a point is inside.

Message 4 of 13

07-20-2020
06:20 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-20-2020
06:20 AM

Hi Roland,

Right now, there is no built-in way to test whether points are inside something like an implicit sphere. However, it's a fairly straightforward computation in the graph if you know the sphere's radius and world transform. (If you do this computation a lot, it would be helpful to publish a reusable compound for it.)

To get inputs like the radius and world transform into the graph, you'll need to connect them individually:

- At the top level of the graph, create a new port on the input node by connecting something of the appropriate type. You'll find that most parameters in Maya use doubles (or vectors/matrices of doubles, etc.), but you can use floats and they will be converted automatically on input.
- In Maya's Node Editor, display both the implicit shape and the Bifrost graph, and connect them. A lot of the ports like radius on the implicit sphere aren't visible by default, so to select them you need to click the big circle at the top of the node and select Other.

I hope that helps,

gray

Grahame Fuller

Learning Content Developer

Message 5 of 13

07-20-2020
07:12 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

Message 6 of 13

07-20-2020
08:48 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-20-2020
08:48 AM

Hi Roland,

The easiest way is probably to convert the point positions that you are testing into the local coordinates of the sphere, and check their lengths against the radius.

- Use inverse_matrix to invert the sphere's world matrix. Note that you could have just input the inverse directly from Maya, but maybe you need the uninverted matrix for something else anyway. It's the same amount of computation in the end — it's just a question of whether you are asking Maya or Bifrost to do the maths.
- Use vector3_to_vector4 to convert the point positions to 4D vectors with w = 1. This is so that they get transformed as point positions rather than vectors.
- Use matrix_multiply to transform the positions. Note that the order is important: matrix first, then the positions.
- Use vector4_to_vector3 to convert the results back to ordinary 3D positions.
- Use length_squared to get their squared lengths, and compare those to the square of the radius. This can be a bit more efficient than comparing their lengths to the radius directly.
- If they are less or equal, then the points are inside the sphere. To do something with those points, you probably want to use the original, untransformed positions rather than those in the sphere's local coordinates.

I hope that helps,

gray

Grahame Fuller

Learning Content Developer

Message 7 of 13

07-20-2020
01:40 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-20-2020
01:40 PM

Don't I first have to set the translation for the sphere matrix to zero?

Message 8 of 13

07-20-2020
01:57 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-20-2020
01:57 PM

You shouldn't need to set the translation of the matrix to zero, assuming that you want to move the sphere and find the points inside it based on its current position, wherever that may be.

Maybe I'm misunderstanding what you are trying to do?

gray

Grahame Fuller

Learning Content Developer

Message 9 of 13

07-20-2020
02:21 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-20-2020
02:21 PM

I thought that when I apply the inverse matrix WITH the translation i would move the point around.

All I want to do is rotate and scale the points position, before I measure its distance to the sphere center, right?

On the other hand... when I apply the inverse matrix WITH the translation then I just measure the points distance to (0,0,0). Is that correct?

I can only test it tomorrow (I’m in Germany).

Message 10 of 13

07-20-2020
03:01 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-20-2020
03:01 PM

What I posted above doesn't actually move anything (unless you use set_point_position with those values). The idea is to convert the point positions from world coordinates so that they are expressed relative to the sphere instead. This is so that you can compare their lengths to the sphere's radius and know whether they are inside or not.

If you move the sphere so that it now encloses different points, you need to take that translation into account when converting the points' coordinates. This is why you need to *not* zero out the sphere's translation.

But note that this is just for determining whether the points are inside the sphere and should be deformed or not. What happens next depends on how you want to deform those points.

For example, if you want to add an offset to their current positions, you'd start with the original, unconverted, world-space positions of those points. On the other hand, if you want to scale them about the sphere's center, you'd multiply the converted positions by some factor and then convert them back to world space before you set their new values on the geometry. (Converting back to world-space involves turning them back to 4D with w = 1 again, multiplying them matrix-first with the uninverted matrix, and finally turning them back to 3D.)

Good luck!

gray

Grahame Fuller

Learning Content Developer

Message 11 of 13

07-21-2020
01:45 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-21-2020
01:45 AM

Ok, it workes! 😀

In this example I shrink the surface of the torus along the point normals, but only inside the implicit sphere.

The sphere can be moved, rotated, scaled.

This is the compound that checks if points are inside the sphere.

It outputs an array of factors for each point on the torus geometry and I can multiply any modification (grow, shrink, noise, etc.) with the factor (see the final graph).

How do I find out if a point is inside the moved/rotated/scaled sphere?

I followed @Grahame_Fuller's advice to transform the points with the Inverse Matrix of the sphere and then just measure the distance to the center (= length of the position vector).

The position inside the sphere is then divided by the radius and the result (clamped and fcurved) is the array of factors.

The final graph for this grow/shrink modification looks like this.

Note that the implicit sphere (createNode implicitSphere) cannot be dragged into the Bifrost Graph directly. You have to create the plugs on the input node and then in the Node Editor connect the sphere's worldMatrix and Radius.

Piece of cake, right?

Message 12 of 13

07-21-2020
03:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-21-2020
03:15 AM

Oh, before I forget it:

Here's a MEL script that

- creates an implicit sphere
- creates a new input node on the selected bifrostBoard (usually "bifrostGraph1" in the Outliner)
- creates the plugs "matrix" and "radius" on that new input node
- connects the implicit sphere's "worldMatrix[0]" and "Radius" to the bifrostBoard (=the input node)
- creates the influenceSphere_pointFactor compound (needs to be installed in your user compounds)
- connects the inputNode matrix and radius to the influenceSphere_pointFactor compound

IMPORTANT: the node "bifrostGraph#" needs to be selected in the Outliner when you execute this.

Put this on your shelf.

Makes your life easier when you test this stuff 🙂

```
$bifrostBoards = `ls -sl -type "bifrostBoard"`;
if (size($bifrostBoards)) {
$sphereName = `createNode implicitSphere`;
$name = `vnnCompound $bifrostBoards[0] "/" -addIONode true`;
vnnCompound $bifrostBoards[0] "/" -renameNode $name $sphereName;
vnnNode $bifrostBoards[0] ("/" + $sphereName) -createOutputPort ($sphereName + "Matrix") "Math::float4x4";
vnnNode $bifrostBoards[0] ("/" + $sphereName) -createOutputPort ($sphereName + "Radius") "float";
connectAttr ($sphereName + ".worldMatrix[0]") ($bifrostBoards[0] + ("." + $sphereName + "Matrix"));
connectAttr ($sphereName + ".radius") ($bifrostBoards[0] + ("." + $sphereName + "Radius"));
$name = `vnnCompound $bifrostBoards[0] "/" -addNode "BifrostGraph,User::Compounds,influenceSphere_pointFactor"`;
vnnConnect $bifrostBoards[0] ("." + $sphereName + "Matrix") ("/" + $name[0] + ".matrix");
vnnConnect $bifrostBoards[0] ("." + $sphereName + "Radius") ("/" + $name[0] + ".radius");
} else warning "No bifrostBoard node selected (e.g. \"bifrostGraph1\")";
```

Message 13 of 13

07-21-2020
03:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-21-2020
03:58 AM

I'm glad it helped. I like that illustration — it really helps to show how it works.

gray

Grahame Fuller

Learning Content Developer

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page