Select to view content in your preferred language

How to set center pivot an Object?

4169
4
Jump to solution
04-10-2014 03:37 AM
GucluSen
Emerging Contributor
[ATTACH=CONFIG]33004[/ATTACH]

Hi,

Lots of 3D software has a button like Center Pivot/Center Origin etc. (Maya, Blender, Studio Max..)

I have imported some ready 3D models from internet but sometimes, some object's center pivot is not set and center is so far from the object.

Is there any button or tool in CityEngine to set it?

Thanks,
Güçlü
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LukeCzar
Deactivated User
Hi,

I am not sure if you can apply this info to Models, (probably Lot Shapes, or shapes, you may convert (right click on the model --> convert to shapes and try then, but you might loose textures)

Start New Rule to apply  code




"Synopsis
setPivot(axisMapSelector, cornerIndex)

Parameters
axisMapSelector (selstr)
Selector which defines the mapping of the old scope axes to the new pivot (and scope) axes. Supported values are:
xyz: Keeps the current orientation, i.e. in corner 0 (the origin, see visual guide below), the new x-axis will point along the old scope's x-axis, the new y-axis will point along the old scope's y-axis and the new z-axis will point along the old scope's z-axis.

yzx: In corner 0, the new x-axis will point along the old scope's z-axis, the new y-axis will point along the old scope's x-axis and the new z-axis will point along the old scope's x-axis.

zxy: In corner 0, the new x-axis will point along the old scope's y-axis, the new y-axis will point along the old scope's z-axis and the new z-axis will point along the old scope's x-axis.

cornerIndex (float)
Integer value in [0, 7] to select one of the scope's corners to become the new pivot.p.
The setPivot operation lets you re-position and re-orient the current shape's pivot. The new orientation will be based on the current shape'sscope axes, the axisMapSelector and the cornerIndex.

The new pivot.p will lie at a selected corner (cornerIndex) of the current shape'sscope, and the pivot will be rotated such that all axes point inside the scope.

The new scope will have zero translation and rotation (relative to the pivot), and will stay at the same place (in world coordinates), but with different axes. The geometry is projected to the new scope (i.e. stays at the same place in world coordinates).



Visual Guide

  The scope of the current shape prior to the setPivot() operation is depicted in the picture on the left. The numbers depict the cornerIndices.

  The pivots after setPivot(xyz, v) with v = the cornerIndex.

Note the orientation of the pivots: in corner 0, the axes are the same as the original scope axes; at all other corners, the direction of y is the same (or the negative) of the y axis of the original scope. The other axes are oriented such that they conicide with a scope axis.


  The pivots after setPivot(yzx, v) with v = the cornerIndex.

Note the orientation of the pivots: in corner 0, the scope axes xyz are replaced by the axes yzx.




  The pivots after setPivot(zxy, v) with v = the cornerIndex.

Note the orientation of the pivots: in corner 0, the scope axes xyz are replaced by the axes zxy."   <-----CityEngine Help



Or you can try to move the model to the origin point in Sketchup:



[ATTACH=CONFIG]33038[/ATTACH]



Lukasz

View solution in original post

0 Kudos
4 Replies
LukeCzar
Deactivated User
Hi,

I am not sure if you can apply this info to Models, (probably Lot Shapes, or shapes, you may convert (right click on the model --> convert to shapes and try then, but you might loose textures)

Start New Rule to apply  code




"Synopsis
setPivot(axisMapSelector, cornerIndex)

Parameters
axisMapSelector (selstr)
Selector which defines the mapping of the old scope axes to the new pivot (and scope) axes. Supported values are:
xyz: Keeps the current orientation, i.e. in corner 0 (the origin, see visual guide below), the new x-axis will point along the old scope's x-axis, the new y-axis will point along the old scope's y-axis and the new z-axis will point along the old scope's z-axis.

yzx: In corner 0, the new x-axis will point along the old scope's z-axis, the new y-axis will point along the old scope's x-axis and the new z-axis will point along the old scope's x-axis.

zxy: In corner 0, the new x-axis will point along the old scope's y-axis, the new y-axis will point along the old scope's z-axis and the new z-axis will point along the old scope's x-axis.

cornerIndex (float)
Integer value in [0, 7] to select one of the scope's corners to become the new pivot.p.
The setPivot operation lets you re-position and re-orient the current shape's pivot. The new orientation will be based on the current shape'sscope axes, the axisMapSelector and the cornerIndex.

The new pivot.p will lie at a selected corner (cornerIndex) of the current shape'sscope, and the pivot will be rotated such that all axes point inside the scope.

The new scope will have zero translation and rotation (relative to the pivot), and will stay at the same place (in world coordinates), but with different axes. The geometry is projected to the new scope (i.e. stays at the same place in world coordinates).



Visual Guide

  The scope of the current shape prior to the setPivot() operation is depicted in the picture on the left. The numbers depict the cornerIndices.

  The pivots after setPivot(xyz, v) with v = the cornerIndex.

Note the orientation of the pivots: in corner 0, the axes are the same as the original scope axes; at all other corners, the direction of y is the same (or the negative) of the y axis of the original scope. The other axes are oriented such that they conicide with a scope axis.


  The pivots after setPivot(yzx, v) with v = the cornerIndex.

Note the orientation of the pivots: in corner 0, the scope axes xyz are replaced by the axes yzx.




  The pivots after setPivot(zxy, v) with v = the cornerIndex.

Note the orientation of the pivots: in corner 0, the scope axes xyz are replaced by the axes zxy."   <-----CityEngine Help



Or you can try to move the model to the origin point in Sketchup:



[ATTACH=CONFIG]33038[/ATTACH]



Lukasz
0 Kudos
GucluSen
Emerging Contributor
Thanks for your detailed answer Lukas,

It's very complicated, lots of programs set this one click. I've found "Pos_Center" = false / true selection in "Object Attributes".
It is useful for some model but not all of them.

If we have imported some 3D Warehouse model or many models using other software, User can't set every model using other some programs individually.
CityEngine make it more easy way to do this. 🙂

Thanks again.
0 Kudos
JackCurran
Occasional Contributor

Being relatively new to CityEngine, I'm coming across this problem myself. It seems really bizarre to me that there is no simple way to rotate or scale an imported model about it's center. As Güçlü says - other 3D packages supply this functionality as standard. Is there no way to do this easily in CityEngine?

0 Kudos
CherylLau
Esri Regular Contributor

After inserting a model in cga using i(), you can rotate it around it's scope's center using r() and specifying the centerSelector as scopeCenter.

r operation—CGA | ArcGIS 

To rotate and scale, you could translate, rotate and scale about the origin, and then translate back.  Translate using relative offsets.

Lot -->
	i(asset, yUp, keepSizeAndPosition)
	Transform(assetInfo(asset,tx)/scope.sx, assetInfo(asset,tz)/scope.sz)
	
Transform(relOffset_x, relOffset_z) -->
	t('-relOffset_x, 0, '-relOffset_z)
	r(0, 90, 0)
	s('2, '1, '0.5)
	t('relOffset_x, 0, 'relOffset_z)