I am trying to render some 3D model in blender and use them as a texture sprite in a game which uses Apple’s SpriteKit. I have an isometric map with tiles size : 32 as width and 24 as height, Since I use same size tile whole over the map (isometric) I need to use an orthographic projection I think! please tell me if I am wrong but I was pretty sure! anyway...
I am using Blender to render my sprites (3D models) but I can not set the camera direction to have the rendered image really fit with the map. The attached picture shows the problem, take a look at the building.
I have also attached the geometric math that I have used to create my render script in Blender.
I found out that if I use a 32,24 tile I need to look at from 29Deg 29Min 28Sec but it seems not alright as the iOS simulator shows!
Can anyone help me on this? How do I have to prepare my sprite to fit well on my isometric map?
Those who have experience with isometric map games are welcome to answer and I really appreciate it.
Here is the code I wrote in python to render the 3D Model, I have also set the camera to Orthographic manually.
import bpy cam = bpy.data.objects["Camera"] def look_at(cam, point): loc_camera = cam.matrix_world.to_translation() direction = point - loc_camera # point the cameras '-Z' and use its 'Y' as up rot_quat = direction.to_track_quat('-Z', 'Y') # assume we're using euler rotation cam.rotation_euler = rot_quat.to_euler() meshObj = bpy.data.objects["plate"] meshObj.rotation_mode = 'XYZ' #meshObj.rotation_euler = (0,0,0) d = meshObj.dimensions # Finding maximum dim of the object objectScale = 1 if d >= d: objectScale = d / 16 elif d >= d: objectScale = d / 16 cam.rotation_mode = 'XYZ' cam.location = (20.416*objectScale,20.416*objectScale,20.416*objectScale) #cam.rotation_euler = (0.7853,0.7853,0.5147) cam.rotation_euler = (0.7853,0.7853,0) look_at(cam, meshObj.matrix_world.to_translation()) alamp = bpy.data.objects["Lamp"] alamp.location = (17.416*objectScale/4,17.416*objectScale/4,20*objectScale/4) print("Scaling ",objectScale) bpy.context.scene.render.filepath = "/Users/iman/Documents/Render/ISOBUILDING.png" bpy.ops.render.render(write_still=True, use_viewport=True, scene="Camera”)