Mod Tool: Difference between revisions

626 bytes added ,  11 September 2012
m
correcting mistakes on "[25] getting and setting the position of points"
m (scripting: decrypting merged integer flags)
m (correcting mistakes on "[25] getting and setting the position of points")
Line 672: Line 672:
  ' '''[25] getting and setting the position of points (without selection) right after object creation'''
  ' '''[25] getting and setting the position of points (without selection) right after object creation'''
   
   
  ' those are relative position calculated from the objects center
  ' point positions are relative to the object's center
  ' to get the real positions add relative poition to that center position
  ' to get the absolute point positions add center to point
  ' don't confuse this with the center that can be moved around
  ' to set the absolute point positions subtract center from point
' it's the mathematical center of the object
   
   
  set oRoot = application.activeproject.activescene.root
  set oRoot = application.activeproject.activescene.root
  set oObj = oRoot.addgeometry( "Cube", "MeshSurface", "TRGV" )
  set oObj = oRoot.addgeometry( "Cube", "MeshSurface", "test" )
  logmessage "TriggerVolumes." & oObj
   
' to test our code move center to somewhere else
Translate oObj, 9, 11, 13, siRelative, siGlobal, siCtr, siXYZ, , , , , , , , , , 0
SaveKey oObj & ".kine.local.posx," & oObj & ".kine.local.posy," & oObj & ".kine.local.posz", 1, , , , True
  FreezeObj oObj
  FreezeObj oObj
  set oGeometry = oObj.activeprimitive.geometry
  set oGeometry = oObj.activeprimitive.geometry
  aPositions = oGeometry.Points.PositionArray
  aPositions = oGeometry.Points.PositionArray
  '                   xyz, 0  = value
  ' get old position
  logmessage aPositions(0, 0)
'                                        (xyz, point)
  logmessage aPositions(1, 0)
  logmessage "old point 0 posx: " & aPositions(0, 0) + GetValue(oObj & ".kine.global.posx")
  logmessage aPositions(2, 0)
  logmessage "old point 0 posy: " & aPositions(1, 0) + GetValue(oObj & ".kine.global.posy")
  logmessage "old point 0 posz: " & aPositions(2, 0) + GetValue(oObj & ".kine.global.posz")
   
   
  ' changing x position of point 0 to value -12
  ' set new position
  aPositions(0, 0) = -12
aPositions(0, 0) = -7 - GetValue(oObj & ".kine.global.posx")
  ' you can add more changes here
  aPositions(1, 0) = -7 - GetValue(oObj & ".kine.global.posy")
  aPositions(2, 0) = -7 - GetValue(oObj & ".kine.global.posz")
   
   
  ' update the array
  ' update the array
  oGeometry.Points.PositionArray = aPositions
  oGeometry.Points.PositionArray = aPositions
  ' apply the changes for point 0 (in this case we changed only x dimension to -12)
  ' get new position
Translate oObj, aPositions(0, 0), aPositions(1, 0), aPositions(2, 0), siAbsolute, siView, siCtr, siXYZ, , , , , , , , , , 0
logmessage "new point 0 posx: " & aPositions(0, 0) + GetValue(oObj & ".kine.global.posx")
SaveKey oObj & ".kine.local.posx," & _
logmessage "new point 0 posy: " & aPositions(1, 0) + GetValue(oObj & ".kine.global.posy")
oObj & ".kine.local.posy," & _
logmessage "new point 0 posz: " & aPositions(2, 0) + GetValue(oObj & ".kine.global.posz")
oObj & ".kine.local.posz", 1, , , , True
' INFO : old point 0 posx: -4
' INFO : old point 0 posy: -4
' INFO : old point 0 posz: -4
' INFO : new point 0 posx: -7
' INFO : new point 0 posy: -7
' INFO : new point 0 posz: -7




8,452

edits