An-Cadsolutions      Imgsystems

Kirjoittaja Aihe: 3dsmax: point3 to float??  (Luettu 1782 kertaa)

xcx

  • Administrator
  • *****
  • Viestejä: 2301
  • Sukupuoli: Mies
    • Profiili
    • Verajankorva.com
    • Sähköposti
Vs: point3 to float??
« Vastaus #15 : Toukokuu 16, 2007, 02:46:17 pm »
Tukee myös FFD 2x2x2 modifieria

Koodia: [Valitse]
-- FFD Points
--
-- www.verajankorva.com

__aCPPoints = #()

/*** Create point helpers for every ffd control point ***/
fn fnCreatePoints _obj =
(
obj = _obj
m = obj.modifiers[1]
if ((classof m) != FFD_4X4X4) and ((classof m) != FFD_2x2x2) do
(
messageBox "No FFD modifier found"
return 0
)

animateAll m
iCpCount = 0
if (classof m) == FFD_4X4X4 do
iCpCount = 64
if (classof m) == FFD_2x2x2 do
iCpCount = 8
__aCPPoints = #()
for i=1 to iCpCount do
(
p = point()
p.pos = fnGetCpPos obj m i
append __aCPPoints p
)

sScript = stringStream ""
format "dependsOn " to:sScript
for i=1 to __aCPPoints.count do
format "$% " __aCPPoints[i].name to:sScript
format "\n" to:sScript
format "b = $%\n" obj.name to:sScript
format "m = b.modifiers[1]\n" to:sScript
for i=1 to __aCPPoints.count do
format "cp% = m.control_point_%\n" i i to:sScript
format "objTM = b.objectTransform\n" to:sScript
format "modTM = (getModContextTM b m) * m.lattice_transform.value\n" to:sScript
format "modBBMin=getModContextBBoxMin b m\n" to:sScript
format "modBBMax=getModContextBBoxMax b m\n" to:sScript
for i=1 to __aCPPoints.count do
(
format "cp%World = ($%.pos * (inverse objTM) * modTM - modBBMin) / (modBBMax - modBBMin)\n" i __aCPPoints[i].name to:sScript
format "m[#master][#control_point_%].value = cp%World\n" i i to:sScript
)
format "(matrix3 [1,0,0] [0,1,0] [0,0,1] [-1.98109,1.23891,0])\n" to:sScript

p = point()
ts = Transform_Script()
p.transform.controller = ts
ts.script = sScript
)

/*** Get control point position in world space ***/
fn fnGetCpPos _obj _ffd _iCpIndex =
(

cp = _ffd[#master]["control_point_"+(_iCpIndex as string)].value
objTM = _obj.objectTransform
modTM = (getModContextTM _obj _ffd) * _ffd.lattice_transform.value
modBBMin = getModContextBBoxMin _obj _ffd
modBBMax = getModContextBBoxMax _obj _ffd
cpWorld = (modBBMin + (cp * (modBBMax - modBBMin)) * (inverse modTM) * objTM)
return cpWorld
)

fnCreatePoints $
Senior Technical Artist - Remedy Games
http://www.verajankorva.com

fossa

  • Hero Member
  • *****
  • Viestejä: 791
  • Sukupuoli: Mies
  • Digital Arts / Taideakatemia / Turkuamk
    • Profiili
    • valtteri.digitalartsturku.net
    • Sähköposti
Vs: point3 to float??
« Vastaus #16 : Toukokuu 17, 2007, 01:41:22 pm »
JES!!
Avian älyttömät kiitokset!!, et usko kuinka tarpeeseen tää tulee tulemaan  :)  :)  :)

xcx

  • Administrator
  • *****
  • Viestejä: 2301
  • Sukupuoli: Mies
    • Profiili
    • Verajankorva.com
    • Sähköposti
Vs: point3 to float??
« Vastaus #17 : Toukokuu 18, 2007, 10:06:30 am »
Gut, gut.
Senior Technical Artist - Remedy Games
http://www.verajankorva.com