Jump to content

Problems successfully making attributes for variables


Recommended Posts

I am still working on this research project, and I am running up against a few rather serious blocks trying to derive the information from the simulation to input into the functions I have developed. The goal of the project is to make a traffic simulator that can be used as a drop in for even complicated city scenes with minimal input required from an artist. I currently have 2 functions, one for the particle velocity and one for the turn velocity in the intersections. I will break down each, hopefully someone will be able to help me figure out how to generate my needed attributes.

Velocity:

post-6857-0-96688600-1362526240.jpg

Simple enough, x is the only variable I care about here. It refers to the distance between a given particle and the next nearest. This one is designed to allow for automatic adjustments in velocity so the "cars" don't collide. As the cars get close together, the whole thing aproaches 0, farther away it goes to 1 and moves smoothly between the two. I will be multiplying this by a scalar and direction vector to give an actual velocity vector. I have already figured out the parameters for it using some math modeling software, but in houdini I am struggling with calculating the next nearest particle. I know I can use the distance VOP to get the actual variable, but for that I need the nearest particle value.

Rotation:

post-6857-0-59220000-1362526232.jpg

This is intended to go in the Turn POP. For this one I need to get two variables, but only on collision with one of my intersection boxes. v is the velocity that the particle has at collision. s is the distance from the colision point to a reference point on each intersection. The calculation will (should) give the correct deg/sec to calculate correct turn rate to move in a perfect quarter circle with a turn radius of s.

Also, I need a way to switch between these, meaning out of intersections the speed varying function takes effect, in intersections the speed is held constant and the turn node takes effect, turning the particle through the intersection. I am planning on using the collision POP's numhit value with a mod2 so it alternates between 0 and 1 for even and odd hits. since each intersection will produce 2 hits, it should work out perfectly. unfortunately I cannot seem to figure out how to use numhit or any other attribute in a switch node.

city streets basic.hipnc

post-6857-0-59220000-1362526232.jpg

post-6857-0-96688600-1362526240.jpg

Link to comment
Share on other sites

The proximity node in POPs will give you an attribute for the nearest particle.

The switch node doesn't work per particle, you could create groups based on you numhit attribute for inside/outside of an intersection, then get you functions to operate on only a specific group.

Does that make sense?

Edited by sam.h
Link to comment
Share on other sites

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