Creating many different StationaryMovement nodes quickly - one-simulator

I'm trying to create many stationary nodes with different locations (to act as bus stop nodes). At the minute, I'm creating many groups containing just one node with different locations.
Group6.groupID = Bus_stop
Group6.nrofHosts = 1
Group6.movementModel = StationaryMovement
Group6.nodeLocation = 1936,1386
Group7.groupID = Bus_stop
Group7.nrofHosts = 1
Group7.movementModel = StationaryMovement
Group7.nodeLocation = 3055,945
Is there a quicker way than copying the same few lines and changing the node location every time?
StationaryMovement only accepts one pair of coordinates, and wont dynamically create nodes from an array.
Cheers!

There are options like GridLocation but for your purpose probably easiest is to extend the StationaryMovement module (i.e., to make new module) to accept array of locations.

Related

Roblox - creating a multistory maze

I am trying to create a multistory maze. I found it fairly easy to create the first level, then I realized I had no idea how to simply raise this first level up in order to create a second level beneath it.
Also, is there a way to 'fuse' all of these wall parts into one object and then raise this object up?
Edit: Much to my embarrassment, their is a way to fuse objects. The 'Union' tool is what I needed, but had no idea existed. I 'fused' (unioned) the various parts that made up my walls and joined them together into one big part. After that unioning, moving the entire maze upwards became quite easy.
I don't understand your problem but I think that you're making a 3D maze in roblox and you want the first level to go up and the second level to form below the level.
If the maze is NOT procedurally generated AND the maps are built by hand. Then you can make the script detect if the player won, and then raise the first level by either using tween or using loops (I'd recommend tween because loops and linear tweening does the same), and then make an effect that shows it forming (Transparency, parts coming back together, etc..).
I will show you the simplest example. But you can add whatever you want
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.5, Enum.TweenStyle.Linear, Enum.TweenDirection.Out) --Customize it to your liking
local levels = game.LevelStorageParent.LevelFolderOrModelHere:GetChildren()
local pos = workspace.Level1.Position --Change (Not the levels because we are not cloning this)
local levelYRaise = 10 --Put any number or just get bounding box for full raise
ts:Create(workspace.Level1, ti, {Position = Vector3.new(pos.X, pos.Y+levelYRaise, pos.Z):Play()
local newLevel = levels.Level2:Clone()
newLevel.Parent = workspace
newLevel.Pos = workspace.Level1.Position - Vector3.new(0, workspace.Level1.Size.Y, 0)
newLevel.Transparency = 1
ts:Create(newLevel, ti, {Transparency = 0}):Play()
Change the code to your liking and your hierarchy names and parenting

Is there a way to return a list of the nodes along a network between an agent and it's destination?

I'd like to return and capture a list of the path elements and nodes that an agent will travel if given a moveTo() command. From this list, I can see if the agent will pass through certain nodes where the agent will behave differently (slow down, pause for 1 minute, etc.). I can then cycle through moveTo() commands for each node and change the parameters based on the node it's going through.
I'd love to give some sample code, but I'm not sure where to begin to get the list. TIA
You can use this function to get the shortest route from source to target:
RouteData rd = RouteData findShortestPath(ILocation source, ILocation target, Node[] nodesToAvoid, Path[] pathsToAvoid);
You can access the elements of rd by calling rd.getMovements().get(index).getNetworkElement(). This will return an object which could be an instance of a path, or a node, or a rectangular node etc.
For more details you can look here: AnyLogic Help - TransporterControl

When connecting to a merger node is there any reason to use a number other than 0 as the second argument if the input is not channel splitter

I understand that when you connect a splitter to a merger you can do something like this:
splitter.connect(merger, 1, 0);
But when connecting an input source such as a stereo buffer source directly to a merger is there any reason ever to set the second argument of the connect method to something other than zero ? I assume the answer is no, but I'm not sure and looking for validation.
var stereoSoundSource = audioContext.createBufferSource();
stereoSoundSource.buffer = whatever;
stereoSoundSource.connect(merger, 0, 1);
In short, no.
Splitter is currently the only node that has multiple outputs, so it's the only node for which you would ever need to specify an output other than 0.
There are scenarios where you would do this with a splitter. For example, imagine how to create a graph that flips stereo channels:
var merger = context.createMerger(2);
var splitter = context.createSplitter(2);
splitter.connect(merger,0,1);
splitter.connect(merger,1,0);
In the future, some other nodes might acquire other outputs (like, I've proposed using a separate output for the envelope in a noise gate/expander node), and then there might be other cases (and this answer would change).

What is the "proper" way to sum multi channel audio buffers to mono

I am using the channel splitter and merger to attempt to split a stereo file into two discrete channels and then funnel them back into the node graph as a "mono" input source that plays in both the left and right monitors. I figured out a way to do it but it uses the stereoPanner node set to 0.5 , and it feels a bit "hacky". How would I do this without using the stereoPanner node ?
//____________________________________________BEGIN Setup
var merger = audioContext.createChannelMerger();
var stereoPanner = audioContext.createStereoPanner();
var stereoInputSource = audioContext.createBufferSource();
stereoInputSource.buffer = soundObj.soundToPlay;
//____________________________________________END Setup
stereoInputSource.connect(merger, 0, 0);
merger.connect(stereoPanner);
stereoPanner.pan.value = 0.5;
stereoPanner.connect(audioContext.destination);
Create a ChannelMerger with only one channel and use to to force downmixing?
Just take the mean (average) of the left and right sample.
I guess I was over thinking this. The following seems to work. I guess the names of the nodes are what is a bit confusing. I would have though I would need a merge node for this
stereoInputSource.connect(splitter);
splitter.connect(monoGain, 0); // left output
splitter.connect(monoGain, 1); // right output
monoGain.connect(audioContext.destination);
EDIT
The "correct" way is what Chris mentioned. Explicitly setting the output channel on the merge node invocation is what confused me.
var stereoInputSource = audioContext.createBufferSource();
var merger = audioContext.createChannelMerger(1); // Set number of channels
stereoInputSource.buffer = soundObj.soundToPlay;
stereoInputSource.connect(merger);
merger.connect(audioContext.destination)

( PCL createViewPort ): multiple poinclouds spin simultaneously in window

I am going to create two viewport in order to visualize two independent point cloud.
Here is a part of my code:
PORT1 = 0; PORT2=0;
vis->createViewPort (0.5,0.0,1.0,1.0,PORT1);
vis->setBackgroundColor(0,0,0,PORT1);
vis->addPointCloud<pcl::PointXYZ>(*cloud1, "left cloud",PORT1);
vis->createViewPort (0.0,0.0,0.5,1.0,PORT2);
vis->setBackgroundColor(0.1,0.1,0.1,PORT2);
vis->addPointCloud<pcl::PointXYZ>(*cloud2, "right cloud",PORT2);
the visualizer shows cloud1 and cloud2 in the same window. But when i want to change the view of one pointcloud (using mouse), the other spin simultaneously . Is there any way to make different pointclouds to view independant from each other? (I have created the visualizer in a thread and so I can not create two different visualizer)
Thank you every body
I have reached to an answer (from pcl users forum):
You can not use one visualizer in two or more threads. The current version of PCL (1.7), does not support this task.
But you can make two different threads with different visualizers. Then you will see each cloud in separate windows, and you can change the view of each window independently.
You can do them independent just creating separate camers for each of them. Your code updated with this advice will look in the following way:
PORT1 = 0; PORT2=0;
vis->createViewPort (0.5,0.0,1.0,1.0,PORT1);
vis->setBackgroundColor(0,0,0,PORT1);
vis->addPointCloud<pcl::PointXYZ>(*cloud1, "left cloud",PORT1);
vis->createViewPortCamera(PORT1);
vis->createViewPort (0.0,0.0,0.5,1.0,PORT2);
vis->setBackgroundColor(0.1,0.1,0.1,PORT2);
vis->addPointCloud<pcl::PointXYZ>(*cloud2, "right cloud",PORT2);
vis->createViewPortCamera(PORT2);
Where vis is:
boost::shared_ptr vis (new pcl::visualization::PCLVisualizer ("id"));