Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

Maxscript - how to import and export vertex color?

Featured Replies

  • Author
  • Localization

SxnnyB, posted Sun Jan 17, 2021 7:04 pm (61712)


I'm working with models for juiced and have located a 4 byte section that controls how far a vertex will "deform" on impact.

The first 3 bytes [xyz] are always same value per vertex with last byte always 0.
E.g.
55 55 55 00
4f 4f 4f 00 ect.

My assumption is that devs used vertex color to set this value per vertex which would allow some sections of part to deform less or not at all.

Max value of 255 so I think it is int8? Maybe? Still rather new to this so please excuse my ignorance.

I've had a look at maxscript reference site but not finding anything that jumps out as a solution.

Anyone have an example script laying around?
  • Author
  • Localization

sleepyzay, posted Tue Jan 19, 2021 8:08 pm (61750)


Here is some example code to help if it can.

Code:
Color_array=#()
for x = 1 to vertCount do (
   r = readByte f #unsigned
   g = readByte f #unsigned
   b = readByte f #unsigned
   a = readByte f #unsigned
   
   append Color_array (color r g b a)
)

msh = mesh vertices:Vert_array faces:Face_array
msh.numTVerts = UV_array.count
buildTVFaces msh
defaultVCFaces msh
setShadeCVerts msh true
setCVertMode msh true
for j = 1 to UV_array.count do setTVert msh j UV_array[j]
for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
for j = 1 to Color_array.count do setVertColor msh j Color_array[j]

  • Author
  • Localization

SxnnyB, posted Sat Jan 23, 2021 11:34 am (61802)


Hey I was able to get that to work.
how can I handle that on export?
I assume getVertColor but is there any additional code needed to write it back as byte sections?
  • Author
  • Localization

SxnnyB, posted Sat Jan 23, 2021 12:03 pm (61803)


Also I'm getting vivid colors (yellows,reds,greens) from the values when it should be all shades of greys.
If all color values are the same across rgb I should get shades from white to black only correct?

Edit: the first mesh seems to load colors correctly.
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.