[Solved] Positioning elements in 3D space via Blender


#1

Hey Embers,

Those of you dabbling in creating 3D compositions of multiple objects may quickly realize the same thing I have - it’s damn hard. Knowing where to place things without a continuous render of how it all looks is both time-consuming and unnecessarily difficult.

While Cinder does have excellent mouse+keyboard support for camera control, positioning multiple objects, possibly animating them to move and rotate is a horse of a different color. To me, Blender seemed to be the obvious choice to get a sense of where I might want to place items in 3D space and then use the values in my Cinder project to create an identical layout.

However - I’m having trouble re-creating the exact same camera that Blender uses, and I’m not sure what’s left to tweak. Allow me demonstrate… Below is my scene in Blender:

The camera in Blender shows:

Re-creating the object positions/sizes and camera configuration yields this in Cinder:

As you can see - it’s not completely wrong. The biggest issue is the framing, and I’m not sure what isn’t ‘matching’. I’ve looked into getting the projection matrix out of Blender, but that seems to require a bit of Python I’ve yet to get working. I would have thought the field-of-view is the issue, but I’ve tripled checked that value, and the unit both Cinder and Blender uses. If anyone has any ideas of what to tweak I’m all ears.

For posterity, the setup in cinder is as follows:

void CinderProjectApp::setup()
{
	mCube1Pos = { 4.16731, 0.0, -1.85926 };
	mCube1Size = {2,2,2};

	mCube2Pos = { -6.32747, 4.8883, 3.05238 };
	mCube2Size = { 2,2,2 };

	mSpherePos = { -4.36681, -0.170805, 0.440636 };

	// Blender rendering thing
	float fov = 49.1;
	ci::vec3 eye = { 0, -12.4907, 0 };
	ci::vec3 target = { 0,0,0 };
	mBlenderCamera.setFov( fov );
	mBlenderCamera.lookAt( eye, target );
}

Thanks in advance,
Gazoo


#2

You could try mBlenderCamera.setFovHorizontal( fov );.


#3

Just eyeballing it, but the aspect ratio of your window and the frame in blender look different to me, which could account for some extra padding.


#4

@paul.houx - mBlenderCamera.setFovHorizontal( fov );

Yields:

Even closer… But in a way leaves me more confused. Can Blender possibly achieve the box it shows with the values now set as they are? I’m even more uncertain as to what can account for the black padding top and bottom. As you point out @lithium the aspect ratio looks different, but with the Fov as is, I’m not sure how to clip that padding.

Gazoo


#5

If your aspect is not the same in Blender and Cinder you will get padding. Make sure that you set the aspect before calling setFovHorizontal, because the aspect ratio is used in the conversion from horizontal to vertical fov.


#6

@gabor_papp - I had no idea that the order was of importance! Much obliged for that piece of advice.

Things look to be a perfect match now - or at least - close enough for my own needs :slight_smile:

Match