I'm using Roblox Studio, and have come across the Terrain Generator. It has the text input "Seed" and always has some default number/code. I've always been bothered about what the seed is and if there is some sort of list on Roblox Seeds. Here is a screenshot of the feature: Screenshot of Terrain Editor on Roblox Studio
I've been messing around by typing in random numbers, and it has affected the terrain style. I've also googled multiple times Roblox Seeds, but have only found games and groups.
I would appreciate if I could have some sort of list on all the Roblox Seeds and also how they work.
High Performance Mark is correct. Let me explain why.
Terrain generators, cloud generators, and ocean simulators all use mathematical wave, random, and noise functions to construct interesting and believable shapes. The seed value largely does not matter to anyone except the generator. That value allows it to reliably make reproducible results very quickly. Computer programs need to find ways to optimize everything possible, and storing terrain information can be a lot of data to hold onto! So rather than saving all of it, smart systems will try to regenerate terrain whenever it needs it. Every spot in the terrain can be recalculated using a complicated math function and your seed value plays an important role in that calculation.
As an example, let's say you wanted to draw some 2D hills. You could use a sine wave to describe the height of those hills.
for distanceAway = 0, 1, 0.1 do
local hillHeight = math.sin( distanceAway )
print( hillHeight )
end
Because you're using a mathematical function to describe the hills, at any distance away you can instantly know, is it supposed to be the top of a hill, the bottom of a valley, or something in between. And it will be the same every time you run it too!
But maybe those hills all look too similar. You can add some variation and jitter to those hills by adding some random number to the height.
for distanceAway = 0, 1, 0.1 do
local hillHeight = math.sin( distanceAway ) + math.random()
print( hillHeight )
end
And this might seen like a nice addition: the hills now have more variation, they might be a little unusually spiky, but at least they aren't the same hills over and over and over again... but now we have a problem. When we ask for the same hill again, it is different!
local distanceAway = 10
local hillHeight = math.sin( distanceAway ) + math.random()
print( hillHeight )
hillHeight = math.sin( distanceAway ) + math.random()
print( hillHeight )
Imagine you're walking through the world, and you find a really cool rock or tree on a hilltop. So you walk away to go find a friend, but when you return, the hilltop is now a valley. And it would be like that everywhere you went. There would be no persistent world to revisit anywhere!
So instead of a random number, let's use a psuedo-random number from a noise function instead. This time, let's provide a seed value too!
local seedValue = 0.2357
local distanceAway = 10
local hillHeight = math.sin( distanceAway ) + math.noise( distanceAway, 0.5, seedValue )
print( hillHeight )
hillHeight = math.sin( distanceAway ) + math.noise( distanceAway, 0.5, seedValue )
print( hillHeight )
Beautiful! Providing the seed number allows the noise function to recreate the same random-looking number every time. Now we've got reproducible terrain generation and it has some interesting variation too!
If you would like to see other uses of noise, there is a fantastic slideshow made by the University of Texas that goes into depth about random numbers and noise.
I hope this helps provide context for why the Roblox Terrain Editor allows you to provide a "Seed" value. And as far as I know, there isn't a master list created of all the different seeds. But if you find a good one, be sure to share the number with your friends so they can try it out too!
a seed is basically a number that makes a terrain different, for example, you want a part with a large cave, you get the seed, you paste it and the terrain you wanted appears, each seed is different, so try as many seeds you want and find your favorite :3
Related
Is there a way to check if there is a line of sight between two agents assuming some buildings and presentation markup?
(Meaning a function that would check if two agents can see each other assuming buildings and walls)
This is how I did it once in the past. The only problem is that it might be slow if you need to do that calculation thousands of times per second. And it's only in 2D. If you need 3D, the idea is not so different.
1) add all your building nodes and everything that might be an obstacle between the two agents to a collection. You may want to put a rectangular node around your buildings to keep everything in one collection (assuming you are using space markup with nodes)
2) generate a delta distance delta (equal to 1 for example) and find the angle of the line that passes through both agents.
3) Make a loop from the position of agent1 till the position of agent2. It will be something like this:
L=delta;
while(L<LThatReachesSecondAgent){
x1 = agent1.getX() + L*cos(angle);
y1 = agent1.getY() + L*sin(angle);
for(Node n : yourCollectionOfNodes){
If(n.contains(x1,y1))
return false
}
/*This can also work maybe faster
//int numNodesInTheWay=count(yourCollectionOfNodes,n->n.contains(x1,y1));
//if(numNodesInTheWay>0) return false
*/
L+=delta;
}
return true
welcome to SOF.
No, there is no build-in function, afaik. You would have to code something manually, which is possible but not straight forward. If you want help with that, you need to provide more details on the specifics.
Given a mesh in Unity & C# (that itself was created in realtime by merging simpler base meshes), how could we during runtime* turn it into a smooth, almost like wrapped-in-cloth mesh version of itself? Not quite a fully convex version, but more rounded, softening sharp edges, bridging deep gaps and so on. The surface would also ideally look like when the "smoothing angle" normals setting is applied to imported objects. Thanks!
Before & after sketch
*The mesh setup is made by people and its specifics unknown beforehand. All its basic shape parts (before we merge them) are known though. The base parts may also remain unmerged if that helps a solution, and it would be extra terrific if there was a runtime solution that would fastly apply the wrapper mash even with base parts that change their transform over time, but a static one-time conversion would be great too.
(Some related keywords may be: marching cube algorithm & metaballs, skin above bones, meshfilter converting, smoothing shader, softening, vertices subdivision.)
There are many ways to get something similar so you can pick your preferred one:
Marching Cubes
This algorithm is easy to use but the result always inherits the blocky 'style' of it. If that's the look you want then use it. If you need something more smooth and/or pixel perfect then look for other ways.
Ray Marching and Signed Distance Functions
This is quite interesting technique that may give you a lot of control. You can represent your base parts with simple cube/cylinder/etc. equations and blend them together with simple math.
Here you can see some examples:
http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
The best thing here is that it's very simple to setup, you don't even need to merge your base parts, you just push your data to renderer. Worse, is that it may get computationaly hard on rendering part.
Old school mesh modifications
Here you have the most options but it's also most complicated. You start with your base parts which don't have much data by themselves so you should probably join them into one mesh using CSG Union operation.
Having this mesh you can compute neighbors data for your primitives:
for each vertex find triangles containing it.
for each vertex find edges containing it.
for each edge find triangles containing it.
etc.
With such data you may be able to do things like:
Find and cut some sharp vertex.
Find and cut some sharp edge.
Move the vertex to minimize angle between triangles/edges it creates.
and so on...
There are really a lot of details that may work for you or not, you just need to test some to see which one gives the preferred results
.
One simple thing I'd start with:
For each vertex find all vertices connected to it by any edge.
Compute average position of all those vertices.
Use some alpha parameter in [0,1] range to blend between initial vertex position and averaged one.
Implement multiple iterations of this algorithm and add parameter for it.
Experiment with alpha and number of iterations.
Using this way you also have two distinct phases: computation and rendering, so doing it with animation may become too slow, but just rendering the mesh will be faster than in Ray Marching approach.
Hope this helps.
EDIT:
Unfortunately I've never had such need so I don't have any sample code but here you have some pseudo-code that may help you:
You have your mesh:
Mesh mesh;
Array of vertex neighbors:
For any vertex index N, triNeighbors[N] will store indices of other vertices connected by edge
List<HashSet<int>> triNeighbors = new List<HashSet<int>>();
int[] meshTriangles = mesh.triangles;
// iterate vert indices per triangle and store neighbors
for( int i = 0; i < meshTriangles.Length; i += 3 ) {
// three indices making a triangle
int v0 = meshTriangles[i];
int v1 = meshTriangles[i+1];
int v2 = meshTriangles[i+2];
int maxV = Mathf.Max( Mathf.Max( v0, v1 ), v2 );
while( triNeighbors.Count <= maxV )
triNeighbors.Add( new HashSet<int>() );
triNeighbors[v0].Add( v1 );
triNeighbors[v0].Add( v2 );
triNeighbors[v1].Add( v0 );
triNeighbors[v1].Add( v2 );
triNeighbors[v2].Add( v0 );
triNeighbors[v2].Add( v1 );
}
Now, for any single vertex, with index N you can compute its new, averaged position like:
int counter = 0;
int N = 0;
Vector3 sum = Vector3.zero;
if( triNeighbors.Count > N && triNeighbors[N] != null )
{
foreach( int V in triNeighbors[N] ) {
sum += mesh.vertices[ V ];
counter++;
}
sum /= counter;
}
There may be some bugs in this code, I've just made it up but you should get the point.
I have written a code to create an animation (satellite movement around the Earth). When I run it, it works fine. However, when it is modified to be part of a code much more complex present in a Matlab GUI, the results produced changes (mainly because of the bigger number of points to plot). I also have noticed that if I use the OpenGL renderer the movement of the satellite is quicker than when the other renderers (Painters and Zbuffer) are used. I do not know if there are further possibilities to achieve an improvement in the rendering of the satellite movement. I think the key is, perhaps, changing the code that creates the actual position of the satellite (handles.psat) and its trajectory along the time (handles.tray)
handles.tray = zeros(1,Fin);
handles.psat = line('parent',ah4,'XData',Y(1,1), 'YData',Y(1,2),...
'ZData',Y(1,3),'Marker','o', 'MarkerSize',10,'MarkerFaceColor','b');
...
while (k<Fin)
az = az + 0.01745329252;
set(hgrot,'Matrix',makehgtform('zrotate',az));
handles.tray(k) = line([Y(k-1,1) Y(k,1)],[Y(k-1,2) Y(k,2)],...
[Y(k-1,3) Y(k,3)],...
'Color','red','LineWidth',3);
set(handles.psat,'XData',Y(k,1),'YData',Y(k,2),'ZData',Y(k,3));
pause(0.02);
k = k + 1;
if (state == 1)
state = 0;
break;
end
end
...
Did you consider to apply a rotation transform matrix on your data instead of the axis?
I think <Though I haven't checked it> that it can speedup your code.
You've used the typical tricks that I use to speed things up, like precomputing the frames, setting XData and YData rather than replotting, and selecting a renderer. Here are a couple more tips though:
1) One thing I noticed in your description is that different renderers and different complexities changed how fast your animation appeared to be running. This is often undesirable. Consider using the actual interval between frames (i.e. use tic; dt = toc) to calculate how far to advance the animation, rather than relying on pause(0.2) to generate a steady frame rate.
2) If the complexity is such that your frame rate is undesirably low, consider replacing pause(0.02) with drawnow, or at least calculate how long to pause on each frame.
3) Try to narrow down the source of your bottleneck a bit further by measuring how long the various steps take. That will let you optimize the right stage of the operation.
I am experimenting with some new ideas in Cocos2D/Box2D on iPhone.
I want to animate a small swarm of fireflies moving on circular (random?) paths... the idea is that the user can capture a firefly with a net..
I have considered using gravity simulations for this but I believe it is over complicating things... my previous experience with using Bezier curves tells me that this isn't the solution either..
Does anyone have any bright insights for me?
Thanks so much.
Do you need the fireflies to collide with each other?
I ask, as if this isn't a requirement, Box2D is probably overkill for your needs. Cocos2d is an excellent choice for this by the sounds of it, but I think you'd be better off looking into flocking algorithms like boids
Even that may be overly complicated. Mix a few sin and cosine terms together with some random scaling factors will likely be enough.
You could have one sin/cosine combination forming an ellipse nearly the size of the screen:
x = halfScreenWidth + cos (t) * halfScreenWidth * randomFactor;
y = halfScreenHeight + sin (t) * halfScreenHeight * randomFactor;
where randomFactor would be something in the realm of 0.6 to 0.9
This will give you broad elliptical motion around the screen, then you could add a smaller sin/cos factor to make them swirl around the point on that ellipse.
By multiplying your time delta (t) by different values (negative and positive) the path of the curve will move in a less geometric way. For example, if you use
x = halfScreenWidth + cos (2*t) * halfScreenWidth * randomFactor;
the ellipse will turn into a figure 8. (i think!)
Hope this helps get you started. Good luck.
One place to look for ideas would be in the domain of artificial life. They have been simulating swarms of entities for a long time. Here is a link for some simple swarm code written in Java that should give you some ideas.
http://www.aridolan.com/ofiles/Download.aspx
I want to ask about jelly physics ( http://www.youtube.com/watch?v=I74rJFB_W1k ), where I can find some good place to start making things like that ? I want to make simulation of cars crash and I want use this jelly physics, but I can't find a lot about them. I don't want use existing physics engine, I want write my own :)
Something like what you see in the video you linked to could be accomplished with a mass-spring system. However, as you vary the number of masses and springs, keeping your spring constants the same, you will get wildly varying results. In short, mass-spring systems are not good approximations of a continuum of matter.
Typically, these sorts of animations are created using what is called the Finite Element Method (FEM). The FEM does converge to a continuum, which is nice. And although it does require a bit more know-how than a mass-spring system, it really isn't too bad. The basic idea, derived from the study of continuum mechanics, can be put this way:
Break the volume of your object up into many small pieces (elements), usually tetrahedra. Let's call the entire collection of these elements the mesh. You'll actually want to make two copies of this mesh. Label one the "rest" mesh, and the other the "world" mesh. I'll tell you why next.
For each tetrahedron in your world mesh, measure how deformed it is relative to its corresponding rest tetrahedron. The measure of how deformed it is is called "strain". This is typically accomplished by first measuring what is known as the deformation gradient (often denoted F). There are several good papers that describe how to do this. Once you have F, one very typical way to define the strain (e) is:
e = 1/2(F^T * F) - I. This is known as Green's strain. It is invariant to rotations, which makes it very convenient.
Using the properties of the material you are trying to simulate (gelatin, rubber, steel, etc.), and using the strain you measured in the step above, derive the "stress" of each tetrahdron.
For each tetrahedron, visit each node (vertex, corner, point (these all mean the same thing)) and average the area-weighted normal vectors (in the rest shape) of the three triangular faces that share that node. Multiply the tetrahedron's stress by that averaged vector, and there's the elastic force acting on that node due to the stress of that tetrahedron. Of course, each node could potentially belong to multiple tetrahedra, so you'll want to be able to sum up these forces.
Integrate! There are easy ways to do this, and hard ways. Either way, you'll want to loop over every node in your world mesh and divide its forces by its mass to determine its acceleration. The easy way to proceed from here is to:
Multiply its acceleration by some small time value dt. This gives you a change in velocity, dv.
Add dv to the node's current velocity to get a new total velocity.
Multiply that velocity by dt to get a change in position, dx.
Add dx to the node's current position to get a new position.
This approach is known as explicit forward Euler integration. You will have to use very small values of dt to get it to work without blowing up, but it is so easy to implement that it works well as a starting point.
Repeat steps 2 through 5 for as long as you want.
I've left out a lot of details and fancy extras, but hopefully you can infer a lot of what I've left out. Here is a link to some instructions I used the first time I did this. The webpage contains some useful pseudocode, as well as links to some relevant material.
http://sealab.cs.utah.edu/Courses/CS6967-F08/Project-2/
The following link is also very useful:
http://sealab.cs.utah.edu/Courses/CS6967-F08/FE-notes.pdf
This is a really fun topic, and I wish you the best of luck! If you get stuck, just drop me a comment.
That rolling jelly cube video was made with Blender, which uses the Bullet physics engine for soft body simulation. The bullet documentation in general is very sparse and for soft body dynamics almost nonexistent. You're best bet would be to read the source code.
Then write your own version ;)
Here is a page with some pretty good tutorials on it. The one you are looking for is probably in the (inverse) Kinematics and Mass & Spring Models sections.
Hint: A jelly can be seen as a 3 dimensional cloth ;-)
Also, try having a look at the search results for spring pressure soft body model - they might get you going in the right direction :-)
See this guy's page Maciej Matyka, topic of soft body
Unfortunately 2d only but might be something to start with is JellyPhysics and JellyCar