Re: XREF Object Problems

Re: XREF Object Problems

lightcube
Advisor Advisor
503 Views
2 Replies
Message 1 of 3

Re: XREF Object Problems

lightcube
Advisor
Advisor

So I wanted to clarify the scenario.

 

I have an importer for a game engine that looks for prop files. When it detects that the prop already exists in MAX format, it brings the prop in as an XREF Object. It always gets placed correctly at import time--transformation if perfect (translation, rotation). Save the file, thinking all is good. Then when reopen.... all XREF objects are over at [0,0,0] with no rotation.

 

It is very bizarre.

 

I updated the code to write the prop's transform to the userdata after it's been placed... and this is just getting REALLY WEIRD.

 

I am sharing a screen shot.

 

Immediately after import (when all creation/placement of the prop is done) the prop's USERDATA write says the prop is at the origin!!! But the very prop is very obviously NOT at the origin. In the Mini MXS listenter you can clearly see the transform (I selected and printed $.transform). The current viewport transform is:

 

(matrix3 [-0.75471,0.656059,0] [-0.656059,-0.75471,0] [0,0,1] [772,1468,-328])

 

but the transform the script understood when done placing it there was:  (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])

 

Now the scene shows the prop in the correct place. When I save it and close... then re-open, it goes to origin.

 

There are no scripted controllers, no animations... just an XREF moved to some location.

 

Something in the code must be causing Max to get confused on some CRAZY way... but I can't thinkg of anything that could cause this. Maybe something to do with using clauses like with undo off or with redraw off or with sanity off...

 

I think I need a Steve or a DenisT or a Bobo to step in.... and if anything throw some random suggestions.



Shawn Olson

Developer of Wall Worm
3ds Max plugins and Scripts

3ds Max 4/Gmax - 3ds Max 2020
Mudbox 2009-2019

Windows 10 x64
i7 8700K
64GB RAM
Geforce 1080ti
0 Likes
504 Views
2 Replies
Replies (2)
Message 2 of 3

Steve_Curley
Mentor
Mentor

Denis or Bobo (not seen either for a long time :() or maybe SwordSlayer. I'm as confused as you are, only thing I can definitely help with is moving this to the Programming forum, based on the fact that it's a script which is doing the job in the first place. Can always move it back here if necessary.


Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 3 of 3

lightcube
Advisor
Advisor

So I wanted to edit the above dilemma with some new information.

 

1) I've not solved it*

2) *I scripted a workaround

3) A piece of info is wrong

 

First, the wrong piece of information: I initially posted that setUserProp was recording (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]). Well it was, but that was because I was writing to userprop before the asset was moved to the correct location. So in the example above, when I moved the setUserProp to the end of the placement loop, the correct transform of (matrix3 [-0.75471,0.656059,0] [-0.656059,-0.75471,0] [0,0,1] [772,1468,-328]) was actually written.

 

However, the issue is still there. After importing the assets as XREF Objects, placing them into the correct locations/orientations, you can fly through the entire scene and all XRef Object assets are in the desired locations.

 

But save the scene, come back, and nope... all at origin.

 

Again, no scripted functions to move the objects around 😕

 

My solution is really crazy. After all the assets are places, I simply did a loop on the assets and essentially say obj.transform = eval getUserprop obj "storedtransform" (which, incidentally, is identical to what the object currently has).

 

After doing this, you can save and re-open and the assets are where they ought to be.

 

I just want to know if there are any known gremlins that could cause something like this.



Shawn Olson

Developer of Wall Worm
3ds Max plugins and Scripts

3ds Max 4/Gmax - 3ds Max 2020
Mudbox 2009-2019

Windows 10 x64
i7 8700K
64GB RAM
Geforce 1080ti
0 Likes