-2

"Create an application that visually sorts the *Static Meshes presented on the screen, by their number of vertices."

*Static mesh is just a 3D model (in Unreal Engine 4)

Here's a visual "guide" on it, that was sent along with the challenge:

https://drive.google.com/file/d/1v0-3zEoDugelGWK-U9t4GEHkA0hAuLfk/view?usp=sharing

I know I should use a sorting algorithm, but how would the number of vertices fit in it for example?

What I don't understand is how would I sort an object's location (3D Vector, XYZ) based on its Static Mesh's number of vertices (an integer), and how are the translation of both chairs so different (check video) if they have the same number of vertices, since they're the same exact Static Mesh. Does that mean their target locations aren't set but rather chosen, meaning their values are constant and exist prior sorting?

Am I approaching this all wrong?

  • This is just an idea; just think about it. What is we assign an ID to the objects and use them to identify them uniquely rather than wasting performance trying to sort mesh data? And if the meshes are identical, then do you think that we can identify them uniquely (using the mesh data)? – D-RAJ Feb 09 '21 at 14:32
  • Are you telling us that you **know** both chairs have the same mesh? The illustration you were given would imply that they are merely _similar_. – Drew Dormann Feb 09 '21 at 14:35
  • @D-RAJ I have to do it as the challenge says, it's a requirement. I think it's rather sort the object's position rather than the static mesh itself, because the static mesh is a component that is attached to the object and so it follows its position. – Lvcifer Feb 09 '21 at 14:45
  • @DrewDormann These chairs are the ones that come with UE4 starter contents. I've checked and they have the exact same "SM_Chair" static mesh. – Lvcifer Feb 09 '21 at 14:49

1 Answers1

0

Choose a starting point near the camera (let's call it cameraPos with coords x1, y1, z1 for example). Choose some point towards the direction the camera is looking at(lookAt with coords x2, y2, z2). The direction vector(let's call it dirVec) is lookAt - cameraPos(x2-x1, y2 - y1, z2 - z1). This is a vector, which represents the general direction of the camera. You sort your 3d objects and now they are ranked - for example the one with the most vertices is with rank 1, the second - 2 and so on. Now calculate the position of every object like this: pos = cameraPos + dirVec * rank. Here, your objects are now sorted visually. If you don't know how to add/subtract vectors or multiply vector by number or the meaning of these operations, you should first get familiar with it.