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 1 Comment »

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

vsys svn checkout

July 31st, 2007 by tom

checking out vsys project from svn into eclipse

1. setting up svn in eclipse

  1. install eclipse 3.x
  2. install subclipse as described at http://subclipse.tigris.org/install.html
  3. goto “window” -> “open perspective” -> “other” -> “svn repository exploring”
  4. right click into “SVN Repository” then “new”->”repository location”
  5. url: https://admin.neonature.net/svn_vsys/
  6. go back to perspective “java (default)”

2. checking out project from svn

  1. right click on package explorer
  2. select “new”->”svn”->”checkout project from svn”
  3. choose svn://svn.5711.org/projects/vsys
  4. choose “trunk” -> “vsys”+highest number
  5. click next
  6. check “check out as a poject configured using the new project wizard”
  7. click finish
  8. select “java project”
  9. click next
  10. enter project name
  11. project layout: “use project folder as root…”
  12. click finish

3. getting vsys compiled

  1. right click the project in the package explorer, select “properties”
  2. select java build path
  3. choose tab “source”
  4. click “add folder”
  5. check “plugins” and “vsys”
  6. click “yes” when asking to remove source folder
  7. click ok
  8. click “yes” when asking to remove old resources
  9. right click the project in the package explorer, select “properties”
  10. select java build path
  11. choose tab “libraries”
  12. click “add jars” select all files in lib folder of the current project
  13. click ok
  14. now all errors should be gone.

4. start

  1. click “run” -> “run…”
  2. double click “java application”
  3. choose main project and main class
  4. choose tab “arguments” paste into “VM arguments”: -Djava.library.path=”${project_loc}/lib/”

if ”${project_loc}/lib/” does not work, use the full path to your lib directory.
you should also download the current lwjgl package and putt all “dll, dylib and jar files in that lib folder.”

Filed under dev, vsys having No Comments »