Perspective Camera Tools Release

This forum is aimed at user contributions, in the form of assets, side projects, code patches and similar.

Moderator: joepal

Perspective Camera Tools Release

Postby TwoPikachus » Fri Apr 25, 2014 2:25 am

Hi everyone,

MakeHuman is excellent software, but one thing I felt it was lacking in new releases is a perspective camera. I wanted something like this because I didn't want to erroneously model faces in orthographic mode then export them out to Max and game engines only to find that the faces I modeled don't look like I thought they would.

I asked for a perspective feature, but I was told it wasn't happening anytime soon which is fair enough, as I soon found out that adding this functionality in was no cakewalk, especially for someone coming in with next-to-no Python knowledge.

That said, I was able to cobble together a hackjob that gets the job done for me, and hopefully this will help anyone else in my same predicament.

Perspective Camera Tools v1:

Unzip the package to your makehuman source directory. This release won't work with the installed versions, only the source versions. I think.

What the package does is add some icons and some functions to, so you'll have to replace that file if asked. Make a backup before you do, just in case. This package does not remove any functionality from MakeHuman.

On the toolbar, you'll see several more new icons. They're extremely poorly-done, ugly, and not really flush with the mh theme, I know. But they were done quickly. Keep in mind I am not a python programmer by trade, nor did I want to sped forever with the code. There are probably a million better ways of doing what I did, but this is a viable workaround for people who want a perspective mode. With that in mind, let's explore what the new icons do:

CAM TYPE: Toggles the camera between Orthographic (_projection = 0, fov = 90) and Perpsective (_projection = 1, fov = 45) projection modes. Unfortunately, the camera does not function the same way in perspective as it does in ortho. The inability to move it as freely gave birth to the other following options.
FACE: Switches to perspective, resets the camera rotation, and moves the human mesh so that its face is right in front of the camera. I couldn't find a way to move the camera itself (addTranslation() really didn't behave as I expected it to) so I moved the selectedhuman instead. The mesh is moved to a location based on its height in cm, so set your height, age and gender sliders before clicking FACE. If you change any of these sliders, simply click FACE again to set its position accordingly.
UP (or DOWN, FOR..., BACK) 0.25: These buttons will move the mesh slightly in the given direction by an increment of 0.25. Use this for tweaking the mesh's position. When I created the equations for position based on height, I used the shortest mesh (female age 1 with smallest height value) and the tallest mesh (male age 25 with largest height value) and calculated the slope between the two meshes' heights. When testing, I realized that there are subtle changes made to the meshes' head and spine positions when gender and age are changed. As a result, the FACE button will give less-than-perfect results with tall women and short men. Rather than write new equations accounting for gender and possibly age, I decided to leave it up to the user to tweak as desired.
Finally, RESET HUMAN will reset the human mesh back to its starting position ([0.0, 0.0, 0.0]) to avoid any issues with the orthographic camera when you switch back to it.

I hope I'm not stepping on any toes by releasing this. I hope this is a good place to release it. I'm not a developer; I don't know exactly how to go about commits and whatever. The most coding I do is C# stuff in Unity as a hobbyist. Forgive any sloppy code. But I am confident that this won't break anything and will only add functionality to an already incredible piece of software.

Changes to
-Added a variable (humanPos) to the top of the document under the import section. This keeps track of where the human mesh is located.
-Added functions for each of the new buttons, they start around line 1390ish.
-Added an entry for each new button in the Camera Toolbar section of the createActions() function.

Thanks, everyone.
Posts: 3
Joined: Thu Mar 20, 2014 8:53 pm

Re: Perspective Camera Tools Release

Postby duststorm » Sun Apr 27, 2014 2:24 pm

We don't have a problem with this unofficial patch. :)

As long as the users note that it is basically a hack, and that the approach it uses might have other unwanted side effects.
No support is provided for this by MakeHuman's creators, which simply means: if it breaks, you're on your own.
MakeHuman™ developer
User avatar
Posts: 2566
Joined: Fri Jan 27, 2012 11:57 am
Location: Belgium

Return to User contributions

Who is online

Users browsing this forum: No registered users and 1 guest