Overlay object

I have one cube and one sphere. I want to overlay the sphere on the cube. How can I know the sphere’s scale? Maybe the cube is a rectangle and the sphere isn’t rounded. How get it?

I can get the position, with worldPosition, more than less but not the scale.

Guess I have to do a base model and adapt de objects then calculate scale from this model. I want calculate a scale for a helmet from different characters

Thanks again.

You could use object.worldScaling to know the object’s relative scale. If you want to know its dimensions (which takes into account its scale at the time of calling the function), I wrote a Python function for it. It would be a good idea to store the result in a variable, rather than get it constantly. It’s in the BGHelper module. If you would rather just have the function, here it is. Running it with an object as the argument will return the total dimensions of the object and its offset from the object center.

I test to print your function an return.

(Vector((1.656000018119812, 2.796999931335449, 0.8799999952316284)), Vector((-0.012450218200683594, -3.051334857940674, 0.5014553070068359)))

But I don’t understand what is the offset. Is it something how orientation of object’s faces?

Edit:

(See the object on foot left only)

Without your dimension function:

with your function:

My code:


#get dimension
pata_L=GetDimensions(object =bge.logic.getCurrentScene().objects["Foot_L"])
#modify scale, without the nex line gif number 1
bge.logic.getCurrentScene().objects["model1_Foot_L"].scaling = pata_L[0]
#position
bge.logic.getCurrentScene().objects["model1_Foot_L"].worldPosition=bge.logic.getCurrentScene().objects["Foot_L"].worldPosition
...setParent(...