I think that we should have a convention for artists to place all pivot
points at the bottom of the model, at the center between all points
touching the ground. That way the models won't extend underground and
rotations would happen as expected.

That approach would work in most cases, including street lamps, buildings,
post boxes.., although there may be some rare exceptions.

I made a simple blender script that sets the model origin to the average of
all points of the model that are touching the ground. I am sending it as an
attachment.

Regards,
Kristijan T

On Wed, Mar 25, 2015 at 9:13 PM Peter Wendorff <[email protected]>
wrote:

> Hi Kristijan,
> (next try, thunderbird unfortunately encrypted the previous attempt,
> might have overseen that - if it's not a bug in the Thunderbird UI).
>
> Am 24.03.2015 um 23:28 schrieb Kristijan Trajkovski:
> > [...]
> > As for scale conversions i think that the main issue would be to find
> > out the correct scale based on user's input, so perhaps it would be the
> > best to provide a unit standard (for example 1 blender unit = 1 meter)
> > and in this way we can defer the required scale to 3d modellers instead
> > of trying to guess or approximate scale.
>
> Scaling isn't the only factor, and a robust solution should cope with at
> least some sort of changes of the OSM data:
>
> A building may be corrected in its dimensions (half a meter more or less
> are often difficult to map).
> Therefore the model might need some sort of reference points on the
> ground to be matched to the building polygon.
>
> Even if you don't look that deep, it should IMHO be possible to use the
> same model for different buildings, thus rotation is a must.
>
> Overall, it follows that the matching from osm building to 3d model
> needs some way to define:
> - which model (e.g. by model id)
> - which orientation (nodes of the osm polygon/multipolygon to reference
> nodes on the model
>
> Even harder it's for street lamps, post boxes and stuff like that as
> they are mapped as a node only, while the mapping might require an
> orientation of the model.
>
> regards
> Peter
>
> _______________________________________________
> dev mailing list
> [email protected]
> https://lists.openstreetmap.org/listinfo/dev
>
# This stub runs a python script relative to the currently open
# blend file, useful when editing scripts externally.

import bpy
import os
import mathutils

bottomZ = 99999999
difftolerance = 0.01
bottomVert = list()

current_obj = bpy.context.active_object 

for v in current_obj.data.vertices:
    wco = current_obj.matrix_world * v.co
    if wco[2] < bottomZ:
        bottomZ = wco[2]
        bottomVert = [v]
    elif wco[2] < bottomZ+difftolerance:
        bottomVert.append(v)

avg = mathutils.Vector((0, 0, 0))
for v in bottomVert:
    avg += v.co

avg /= len(bottomVert)
wavg = current_obj.matrix_world * avg

bpy.context.scene.cursor_location = wavg
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
bpy.context.active_object.location = [0, 0, 0]
_______________________________________________
dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/dev

Reply via email to