Notifications
Clear all

[Closed] Matching imported objects

Okay…please don’t ask why, this is just how it is…

We have been given a “world” full of objects, sounds okay so far. We also have the separate base object files, really cool.

What’s happened though, is when the world was built, the baseline objects were converted into OBJ’s and then imported into the world, through some process or another, meaning we’ve lost almost any useful data (such as rotation and texture information)…

The problem we face, is we need to match the base objects BACK into the world in order to resurrect the texture and mapping information…

The plot thickens…

I’ve tried a direct vertext and face mapping, but that does not work, as the vert/face counts are different and the index order is not the same…

Does any one else have any ideas I might try??

Shane

4 Replies

If I gather what you’re trying correctly, have you tried using the projection modifier to remap the material? Just a thought.

1 Reply
(@rustyknight)
Joined: 11 months ago

Posts: 0

That’s an interesting idea, I’ll pass it on, but I don’t think they’ll go for it

Giggsy, I feel your pain and would interested in seeing your results…

Currently we have our client pushing out position, rotation and scale information for all the objects in the world file to a text file…gotta love that

Shane

I can only feel with you (allthough that probably doesn’t help much :/)
I’m currently doing my internship at a gaming company as a TA, and I’ve got the task to >>try<< to develop a similar script.

Basically it’s about trying to reindex the vertices so the “slave” object matches the ones of the “master” (verts of both objects to compare are the same amount, but in a different order…as a matter of fact, it’s also an OBJ-mess-up issue ).

Right now I am still busy with my other script (see http://forums.cgsociety.org/showthread.php?f=98&t=653278 ) but after that (meaning arround afternoon or so) I’m going to start doing some researching.

I’ll keep you up to date if you want, maybe we can push each other!
(starting with taking a look at the projection modifier first – thanks for the tip)

EDIT: there is a script named “Morphix2.0”.
It works quite well, but you need to create a “hint” for each elment of the object which is unsatisfying for us cause we got a lot of elements per object

I’m sort of gonna give up on this one (or at least lower the tasks priority as there is enough other stuff to do and I don’t see any chance in getting this working in the near future)

Again, my situation:
You got 2 objects, master and slave.
Master is the one with the correct vertex order (he's also the bad guy beeing imported as an OBJ ;) )
Slave is the one whoms "properties"(mapping, vertex color, etc.) you want to obtain.

My approach:
1) analyse which slave vertex corresponds to which master vertex on a threshold basis
2) clone the master, naming to reindexed-slave
3) "copy" properties from slave to reindexed-slave

Well... seems quite easy, but I broke my brain and fingers more than once ;)
The main problem was or is creating/copying the UVs.
I managed to set the mapping verts (at least they looked ok) but the hooking up with the faces didn't seem to work out right.
(and as a side effect max gets very unstable when viewing the uv layout per unwrap modifier - so something bad must have happened)


Note: the projection modifier didn't seem to work out for me.
Maybe I did something wrong, but the generated UVs looked really weird and distorted...


It probably wont help much, but here's a showable part of the script from my testing.
What it does is, it compares two meshes (named Master and Slave) which must be identical (except for the vertex order) and then shows the vertex relationship.
(like Master vertex 1 = Slave vertex 15)

    --Some vars:
    master 					= $Master
    slave 					= $Slave
    VERTEX_THRESHOLD		= 1.0
    slaveIsMasterVert 		= #()
    
    --Compares if the vertices are at the same position (with threshold)
    function compareWithThreshold lhs rhs =
    (
    	bEqual 	= false
    	bMatchX	= false
    	bMatchY	= false
    	bMatchZ	= false
    	
    	-- Check x component:
    	lhsX = lhs.x
    	rhsX = rhs.x
    	if( lhsX > rhsX ) then swap lhsX rhsX
    	if( ( lhsX + VERTEX_THRESHOLD ) >= rhsX ) then bMatchX = true
    	
    	-- Check y component:
    	lhsY = lhs.y
    	rhsY = rhs.y
    	if( lhsY > rhsY ) then swap lhsY rhsY
    	if( ( lhsY + VERTEX_THRESHOLD ) >= rhsY ) then bMatchY = true
    
    	-- Check z component:
    	lhsZ = lhs.z 
    	rhsZ = rhs.z
    	if( lhsZ > rhsZ ) then swap lhsZ rhsZ
    	if( ( lhsZ + VERTEX_THRESHOLD ) >= rhsZ ) then bMatchZ = true
    
    	-- Check if all components match:
    	if( bMatchX and bMatchY and bMatchZ ) then bEqual = true
    
    	return bEqual
    )
    
    
    --clear listener:
    clearListener()
    
    --backup original position:
    maOriginalPos = master.pos
    slOriginalPos = slave.pos
    
    --set both to 0 0 0:
    master.pos = [0,0,0]
    slave.pos = [0,0,0]
    
    --evaluate the number of verts:
    maVerts = master.numverts
    slVerts = slave.numverts
    vCount = 1
    
    --analyze objects and find the vertex relationship:
    for i = 1 to maVerts do 
    (
    	maVert = polyOp.getVert master i
    	
    	for j = 1 to slVerts do 
    	(
    		slVert = polyOp.getVert slave j
    
    		if( ( compareWithThreshold maVert slVert ) == true ) then
    		(
    			format "Found! Master: %	Slave%
" maVert slVert
    			slaveIsMasterVert[ j ] = vCount			
    			vCount = vCount + 1
    			exit
    		)
    	)
    )
    
    --test output:
    for i = 1 to vCount-1 do
    (
    	format "Slave vert % is equal to master vert % 
" i slaveIsMasterVert[i]
    )
    
    --Final step: set objects back to original position:
    master.pos = maOriginalPos
    slave.pos = slOriginalPos