My case:
I need to create a simulation environment for synthetic dataset generation for pose estimation problem.
Therefore I need to create a loop as below:
- Create n object of k classes at random location over the ground.
- Let gravity to pull them to the ground and collide with each other.
- Take an RGBD shot of scene from camera.
- Track final position of each cuboid.
- Save RBG image with depth map as jpg files and positions in json.
- Delete each object.
I’m totally new in Unreal Engine and It’s pretty hard to figure out, how to put everything together in C++ code.
My questions:
How can I spawn chosen object in loop during runtime of simulation? Which class should handle it?
How to enable blocks to be pulled by gravity and collide each other? I expect them to form some kind of pyramid on the ground…
And finally, how to track them to figure out their pose?
I will appreciate any suggestions, since I’m really stucked with it right now…
Hey WKAtende,
These are good questions. UE4 is an incredibly complex and undocumented piece of software. It has a very nice physics engine. Unless you wanted to do a 2d simulation in JavaScript, UE4 seems like a good tool for this.
I would recommend using “Blueprints”, and to take a course on Udemy (they go on sale almost every week): https://www.udemy.com/course/unreal-engine-4-the-complete-beginners-course
For me, the path to learning UE4 C++ really got started with learning UE4 Blueprints.
For how to implement:
You can spawn actors using “Spawn Actor of Class” in blueprints.
If you spawn all the cubes first, then loop through them to turn on physics, you won’t get “hitches” from the actor spawning (spawning is expensive for performance).
You can take a “photo” using a Camera actor. Search youtube for “ue4 security camera” and you should find an example of handling images.
Good luck with your project!
Michael
Thanks for direction. In the meanwhile I’ve created my environment, but got another problem - taking RGBD screenshots (with depth). I use simple Camera Actor for taking RGB shots. Do you know how to deal with it?
Hmmm… depth is a relative term, so it’s either relative to the camera or ground plane. You could do a series of projectiions from or toward. I would start with “line trace by channel”.