tom.drastic.net

Archives Posts

maxscript…

April 12th, 2008 by tom

“snapshotAsMesh object” gives you the current object completly collapsed.
bad thing is, the transform matrix is also applied, so all vertices are in world space.
get the vertices back into local space, you multiply every vertex with the inverse transformation matrix:

  mesh = snapshotAsMesh obj
  worldTransform = obj.transform
  invWorldTransform = inverse worldTransform 

  for v = 1 to mesh.numverts  do
  (
    vert=getVert mesh v
    vert*=invWorldTransform -- daadaaa
    WriteFloat f vert.x
    WriteFloat f vert.y
    WriteFloat f vert.z
  )

for your normals you have to do the same, just multiply with the inverse world matrix. but only use rotation this time.

do not use obj.mesh directly to get object space vertex coordinates, or your script will become unbelivable slow…..

Filed under maxscript, dev, 3d, 3dsmax having No Comments »

Archives Posts

random maxscript questions

April 10th, 2008 by tom

just some random questions i had when starting with a maxscript exporter…

how do i read animated values ?
for printing an object position at time T, do:

print at time T obj.pos.x

getting information about scene animation

animationrange.end
animationrange.start

what is the current framerate ?
use the global variable “frameRate”

how do i rewind or set the max timeline?
use the global variable sliderTime to set it.

sliderTime =0

how to get vertex normals ?
this way your normals look like you wanted them. (”smoothing groups safe”)

for ve = 1 to mesh.numfaces do
(
    norm=meshop.getFaceRNormals mesh ve
    format "% % %" norm[1].x norm[1].y norm[1].z
    format "% % %" norm[2].x norm[2].y norm[2].z
    format "% % %" norm[3].x norm[3].y norm[3].z
)

what is the color i set at rendering->environment->background color ?
use the global variable “backgroundColor” :)

how to test if an object is animated ?
you can check (boolean) “obj.isanimated”.
i think this works not if vertices of the object are animated. only if position/rotation/etc. are animated..
also this is false if the object is linked to a bone, which is animated!

Filed under maxscript, dev, 3d, 3dsmax having No Comments »

Archives Posts

baking mesh animations using point cache

February 27th, 2008 by tom

i use the collada file format for importing 3d objects into my “system”.
nice thing of the collada file format is, it contains informations about animations.
but those animations are only for whole objects, not for vertex data.
if you use it for displaying robots or bone/skin stuff this is ok.
but you can not use it for baking complex animations created in 3ds max.

3ds max has the point cache modifier for objects.
this modifier exports baked and sampled animations to a file.
which is exactly the feature collada is missing.
so you can bake mesh animations for your object and read the exported files in your engine.

using the point cache modifier

1. create your animation using for example the twist modifier on an object
2. put the point cache modifier on top of the modifier stack
3. press record, enter file name and you are done
4. the button “disable modifiers below” you can turn of the animation modifier, now play the animation and you’ll se the sampled animation.

point cache pc2 file format

the exported pc2 files contain simple information about the animation and a big chunk of sampled vertex data.
i found a description of the format here

char    cacheSignature[12];   // Will be 'POINTCACHE2' followed by a trailing null character.
int     fileVersion;          // Currently 1
int     numPoints;            // Number of points per sample
float   startFrame;           // Corresponds to the UI value of the same name.
float   sampleRate;           // Corresponds to the UI value of the same name.
int     numSamples;           // Defines how many samples are stored in the file.

this is the header information.
after that the vertex data follows as floats (3 floats for a vertex):

numSamples*numPoints*3

Filed under dev, howto, 3d, 3dsmax having No Comments »

Archives Posts

3ds max / mudflow normal map workflow

January 20th, 2008 by tom

i use this for realtime graphics, so i am ignoring creation of displacement maps, just focus on normal map generation.

building basic model in 3dsmax

- build a model / use subdivision
- unwrap model for later normal map texture coordinates

importing model into mudbox

- export model from 3ds max as .obj file
- import model into mudbox
- subdivide (shift-d) to a higher level, e.g. level 3
- paint your stuff onto it.

getting your normal map into 3ds max

- choose utilities->texture baking
- select “low resolution mesh”: “[modelname] level 0″
- select high resolution mesh: “[modelname] level [highest number]”
- activate “create normal map”, choose filename
- deactivate “create displacement map”
- open advances settings
- enable smooth UV’s
- choose preset “3dsmax”
- start map baking process
- switch to 3ds max
- open the material editor
- goto “maps”
- click “none” next to “bump”
- choose “normal bump”
- select your image file you exported from mudbox
- finished

mudboxnmap.jpg

this is the original version (~4000 faces) and the result after setting the normal map.
its far from being finished and the uvw map is really crappy, but you’ll get the idea…

misc:
check the great mudbox tutorials at pixelcg.com/

Archives Posts

timelapse of modeling an insect like thing

August 22nd, 2007 by tom

recorded a small modeling session in 3ds max, creating an insect. original time was 22 minutes.
the whole thing is basically done using the box modeling method, just using the tools extrude / bevel / quick slice.

Filed under 3d, 3dsmax having 1 Comment »

Archives Posts

import sketchup to 3ds max

August 19th, 2007 by tom

there is that wonderful xml format digital assets exchange (.dae) format called collada.
google earth models (.kmz) contain the mesh information as a dae file.

this also works with the free version of sketchup!

what you have to do is get that .dae file out of the .kmz and import it into 3ds max.
a kmz file is basicaly a zip file, which contains the model and textures and information on where on earth the model should be placed etc..

  1. export your sketchup scene as “3d model” - “google earth x (*.kmz)”
  2. find the file and rename it to “.zip”
  3. unzip the content of the file
  4. open max - choose “file” - “import” - choose “dae” file format, and open your file

perhaps max says something like:

    -Warning: Meter conversion factor is too small or invalid: 0.01

there is a way to change this:

open the .dae file in your favorite text-editor.

  • find the line:
    <unit name="centimeters" meter="0.01"/>
  • relpace “0.01″ with something bigger, like “1.00″
  • save the file
  • now you should be able to import the scene into 3ds max

i used 3ds max v9 for it and this collada importer , but there should be free collada importer for earler versions of max and nealry every other 3d tool like maya or blender etc…

Filed under howto, 3d, sketchup, 3dsmax having 7 Comments »

Archives Posts

how to use png textures with alpha channel in max

August 19th, 2007 by tom

you can use one png file as diffuse color map and transparency map at the same time. so you don’t need to create 2 files for this in 3ds max.

  1. create your transparent texture
  2. save as 24bit png file
  3. switch to max, open the material editorm choose an empty slot
  4. choose “maps”
  5. click the “none” button next to “diffuse color”
  6. select “bitmap” and choose your png file
  7. go back to the material editor (e.g. “03 - default”in the pulldown menu under the material slots)
  8. click the “none” button next to “opacity”
  9. select “bitmap” and choose the same png file
  10. switch “mono channel output” to “alpha” (in “bitmap parameters”)
Filed under 2d, howto, 3d, 3dsmax having 12 Comments »

Archives Posts

baking sketchup materials in 3ds max

June 18th, 2007 by tom

this little tutorial shows how to export a model from sketchup and bake the materials to one texture map, to make it easier for (e.g.) realtime use / exporting it from 3ds max.. etc.

this works only with sketchup pro version

1. create textured model in sketchup

eckdings23.png

2. export the file as 3d model -> 3ds -> use the following options:

  • export: single object
  • export texture maps / preserving texture coordinates

bild-40.png

you will get a directory full of textures and a 3ds file.

3. import in 3ds max

open 3ds max / file -> import -> choose 3ds file

you can now render the scene, it will be textured as it is in sketchup.

where is the texture map ?
at this moment the textures are applied as multiple submaterials in 3ds max.
to see the material:

  1. open material editor
  2. klick “get material” (the icon is an arrow and sphere)
  3. select “browse from:” “scene” to see all materials in the current scene
  4. choose e.g. “Material #66 Multi/Sub Object”
  5. double click to replace the current selected material
  6. now you see the different submaterials

4. bake textures into oneselect the object to bake

  1. choose rendering -> render to texture or press “0″
  2. remember the number you setat “Mapping Coordinates”: “Channel”(**)
  3. scroll down to “output” / choose “add” / select “complete map”
  4. choose a texture size for example 512×512
  5. change “baked material settings”: select “Output Into Source”
  6. klick “Render”
  7. open “Material Editor”
  8. choose an empty material
  9. open “Maps”
  10. click the “None” Next to “Diffuse Color”
  11. choose “Bitmap”
  12. select the image you rendered using the render to texture tool previously
  13. set “Map Channel” to the number from step (**)
  14. assign material to your object
  15. click “show map in viewport” to see the texture in 3ds max

You now have baked all Textures into one.

bild-41.png

The Resuling Texturemap will never be optimal, because you are working with automatically generated uv coordinates. you can optimizie the used space a bit if you remove faces from the model, which are never seen.

You also should considering to enable gi or shadows etc before rendering to the texture to make everything look better :D

Filed under howto, 3d, sketchup, 3dsmax having 3 Comments »