Most efficient way of animating hundreds of gameobjects with blender shape keys - c#

I have my trees edited by shape keys in blender, now I want to trigger this wind animation in unity. I used animator and controller for this, but now I found out that there are blendshapes and I could use loop to change blendshape key value. There will be more than hundreds of trees, and i think to start courotine for each tree is not efficient, nor update this value each frame. It should run endlessly, of course I will animate only visible trees, but still dont know most efficient way.

Maybe someone else can give a more technical answer for how you can do it (as you are asking), but the more practical answer is that you wouldn't. Find some way to cheat it. Use 2D sprites that look good enough, like even most AAA games do/did. Or at least make sure you've only got a few trees visible at a time. If they're close enough to really notice, then you could use 3D for just the close models with 2D stuff in the back, etc.
Or some other your-game-specific way you can think of to cheat the art.

Related

Controllable Mass of Fluid Character

I am kind of new to unity,to any kind of engine,actually.
I am trying to find a way to have a controllable mass of fluid,i mean to be able to go forward,back and so on using the arrow keys.
At first i thought about having some kind of mesh filled with simulated liquid but it doesn't really fit for my project....
Long story short, i need to be able to move a droplet of water.
I think you should start with instantiating just a lot of balls (2d or 3d) - as a representation for droplets. You can give them all physics colliders and rigidbody mass and you will be able to control them all, by proximity or individually.
In the future you can replace spheres with some kind of surface-generating algorithm like metaballs or raymarching

2D Procedural Generation

I'm currently trying to implement procedurally generated tilemaps for an overworld. I'm as far as generating noise and building the tilemaps using different ranges within the generated noise. However, they're very crude as each different 'biome' is just one tile. What is the best way to implement the detailing and edges of each biome? e.g flowers/trees/etc spread out in a forest biome, beach-to-water transition tiles between beach and ocean biome, etc.
For some context, I built an engine in MonoGame with a friend of mine. We implemented a chunk loading system for dynamic generation and infinite scrolling with no load screens(not exactly state of the art, I know, but I was proud of it). Each chunk is 50x50 tiles, and there are 9 chunks loaded at any given time. When the player moves chunks in any direction, the chunks on the opposite corner are unloaded and new ones are loaded in the direction the player is walking. Since the player is starting on the opposite of where chunks are being generated, it hasn't been a problem thus far as the maps are big enough that they're done generating by the time the player gets to them. I'm not sure whether the current method I have in mind is going to change this or not.
Anyway, I'm thinking that I need to determine within each biome a specific set of tiles and generate noise for each biome instance to determine placement of 'detail' tiles specific to that biome. For the edges, I'd just loop through each adjacent tile to determine whether it's a different biome. If so, use the transition tile. However, the whole idea seems very inefficient as that's a ton of noise to generate as well as looping through 7500 tiles every time the player moves chunks. I've been trying to think of a better method, but this is my first foray into procedural generation and I haven't been able to find much online that talks about anything more in-depth than generating noise and using that noise to generate chunks of land. Is there a more efficient method I should use or is my next step going to be optimizing? I can't imagine my method is going to be very efficient or practical due to how much I'm going to be looping through every tile. Anyone have any ideas or suggestions? Thanks in advance.
One idea:
Use noise to generate height, temperature, rain, ... for each chunk
Use generated values to determine the biome for each chunk
For each tile interpolate the generated of the surrounding chunks
Use the interpolated values to select ground textures, plants, ...
That should generate smooth borders between biomes and also different chunks with the same biome can have a different feel.

Most efficient way to make tall pile of objects?

Ok Im trying to make a TALL pile of objects, ideally where the outer layer/ones touchable by the user on ground level have rigid bodies and are able to be moved.
Ive succeeded using https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjem72Awa3eAhWKEZAKHbHMCBcQwqsBMAB6BAgGEAQ&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPJBPCnuaqIo&usg=AOvVaw1ewMypDbMyIV-qz8LZoo2e to make a shallow pile of objects that can move around, but no matter how many objects I drop in play mode, they inevitably bounce off each other and distribute out on the ground.
I need a TALL pile that won't all collapse - reducing polys as much as possible for gameplay, whats the best way to do this? Is there a way to use a particle system like I did with blender and a premade object:
How is this typically done in unity?
You will want to stack them in your scene, enter play mode, let them fall and come to rest then just keep going back and forth. Once you have a good stack. Clear all the random debri, then create an empty and drag all the items into it in the inspector scene view, then you can make the empty into a prefab and set pikes wherever you want.
Alternatively you can remove there rigid bodies and parent them to an empty and just add a simple block collider(if you don't want the column to come apart)

Detecting truck wheels

I am currently working on a project which we have a set of photos of trucks going by a camera. I need to detect what type of truck it is (how many wheels it has). So I am using EMGU to try to detect this.
Problem I have is I cannot seem to be able to detect the wheels using EMGU's HoughCircle detection, it doesn't detect all the wheels and will also detect random circles in the foliage.
So I don't know what I should try next, I tried implementing SURF algo to match wheels between them but this does not seem to work either since they aren't exactly the same, is there a way I could implement a "loose" SURF algo?
This is what I start with.
This is what I get after the Hough Circle detection. Many erroneous detections, has some are not even close to having a circle and the back wheels are detected as a single one for some reason.
Would it be possible to either confirm that the detected circle are actually wheels using SURF and matching them between themselves? I am a bit lost on what I should do next, any help would be greatly appreciated.
(sorry for the bad English)
UPDATE
Here is what i did.
I used blob tracking to be able to find the blob in my set of photos. With this I effectively can locate the moving truck. Then i split the rectangle of the blob in two and take the lower half from there i know i get the zone that should contain the wheels which greatly increases the detection. I will then run a light intensity loose check on the wheels i get. Since they are in general more black i should get a decently low value for those and can discard anything that is too white, 180/255 and up. I also know that my circles radius cannot be greater than half the detection zone divided by half.
In this answer I describe an approach that was tested successfully with the following images:
The image processing pipeline begins by either downsampling the input image, or performing a color reduction operation to decrease the amount data (colors) in the image. This creates smaller groups of pixels to work with. I chose to downsample:
The 2nd stage of the pipeline performs a gaussian blur in order to smooth/blur the images:
Next, the images are ready to be thresholded, i.e binarized:
The 4th stage requires executing Hough Circles on the binarized image to locate the wheels:
The final stage of the pipeline would be to draw the circles that were found over the original image:
This approach is not a robust solution. It's meant only to inspire you to continue your search for answers.
I don't do C#, sorry. Good luck!
First, the wheels projections are ellipses and not circles. Second, some background gradient can easily produce circle-like object so there should be no surprise here. The problem with ellipses of course is that they have 5 DOF and not 3DOF as circles. Note thatfive dimensional Hough space becomes impractical. Some generalized Hough transforms can probably solve ellipse problem at the expense of a lot of additional false alarm (FA) circles. To counter FA you have to verify that they really are wheels that belong to a truck and nothing else.
You probably need to start with specifying your problem in terms of objects and backgrounds rather than wheel detection. This is important since objects would create a visual context to detect wheels and background analysis will show how easy would it be to segment a truck (object) on the first place. If camera is static one can use motion to detect background. If background is relatively uniform a gaussian mixture models of its colors may help to eliminate much of it.
I strongly suggest using:
http://cvlabwww.epfl.ch/~lepetit/papers/hinterstoisser_pami11.pdf
and the C# implementation:
https://github.com/dajuric/accord-net-extensions
(take a look at samples)
This algorithm can achieve real-time performance by using more than 2000 templates (20-30 fps) - so you can cover ellipse (projection) and circle shape cases.
You can modify hand tracking sample (FastTemplateMatchingDemo)
by putting your own binary templates (make them in Paint :-))
P.S:
To suppress false-positives some kind of tracking is also incorporated. The link to the library that I have posted also contains some tracking algortihms like: Discrete Kalman Filter and Particle Filter all with samples!
This library is still under development so there is possibility that something will not work.
Please do not hesitate sending me a message.

How do I create Tetris Blocks in XNA with C#?

I'm making a Tetris Clone in C# with XNA, and I'm unsure of how to actually implement the blocks.
I don't think that making the shapes as images will work (because parts are removed when lines are formed), so I Have blocks to make up the pieces like This.
Unfortunately, I don't know how to actually define the blocks to make the pieces, nor do I know how to manipulate them to make them rotate, etc.
Edit: I would also need assistance in learning how to make the Tetris Grid too.
I haven't created tetris before, but after some thinking, I believe that I would use a simple matrix to create my pieces. For example, your whole game board would be one big matrix. A subset of that matrix, say a 4x4 block of it, would be a game piece. Which parts of that 4x4 block would be filled would be determined by which particular piece you want to create. Each part of the matrix can have a boolean flag that would indicate if it's filled or not. This is a very simplistic view of it, but I think it's a viable solution.
Use a boolean matrix to model the state of the screen. Each piece is itself another smaller boolean matrix.
Rotating a piece is as simple as playing with the coordinates a little bit (I left this to you).
About how to render, just draw a piece tile for each true value in your matrix ored with the current falling piece shifted and rotated.
For the blocks, I would strongly suggest working in 3D. You can still make the game look like 2D by locking the camera etc, but you will benefit a lot from working in vector graphics. Your blocks will be simple cubes (flat or with some depth) that you rotate and move around the screen.
For the grid, look at #fortran's and #aaron's answers, a boolean matrix will do the trick.
Maybe this link to Coding4Fun will help. It's in german, but you should be able to get the source code and take a look on how about the problem is solved here.
Just to be sure, here the direct download link.

Categories

Resources