Difference between revisions of "Talk:HowTo:Radiosity baking in Blender"

From VsWiki
Jump to: navigation, search
(Vertex colors messed up again: :()
(Vertex colors messed up again)
Line 4: Line 4:
 
=== Vertex colors messed up again ===
 
=== Vertex colors messed up again ===
 
Thsi topic again :( Ok, i've tried to reproduce my perfect copied vertex colors with the original blender-file and it just doesn't work (in all cases). When i use the obj file (by importing it again... as i did at work) i get a fairly good result. But when using the blender-file (basically the source file to the obj) i get the messed up VCols again. :-/ It's a bit frustrating when i have to do the rad-process over and over again, just to find out that it didn't do it right. Did you get the .blend file i sent you via mail mail? Just purge the vertex colors of the mesh on the first layer and try doing the rad-process with that mesh. I dunno what i can do to improve this behaviour, but i'll try to help where i can. --[[User:pontiac|Pontiac]] 10:40, 26 Sep 2005 (PDT)
 
Thsi topic again :( Ok, i've tried to reproduce my perfect copied vertex colors with the original blender-file and it just doesn't work (in all cases). When i use the obj file (by importing it again... as i did at work) i get a fairly good result. But when using the blender-file (basically the source file to the obj) i get the messed up VCols again. :-/ It's a bit frustrating when i have to do the rad-process over and over again, just to find out that it didn't do it right. Did you get the .blend file i sent you via mail mail? Just purge the vertex colors of the mesh on the first layer and try doing the rad-process with that mesh. I dunno what i can do to improve this behaviour, but i'll try to help where i can. --[[User:pontiac|Pontiac]] 10:40, 26 Sep 2005 (PDT)
 +
----
 +
What the... please say you forgot to use the new script?!
 +
Do you happend to have ICQ? If you do, my number is 1949713.
 +
 +
I got the .blend file - it's the file I used to reproduce the bug I fixed. When I used the obj file I had no problems, even with the old script.
 +
 +
Why do you have to relcalculate the radiosity? Isn't it only transfering the vertex colors to the original mesh that's causing trouble?
 +
I put together a little debugging version of the script, [http://www.nada.kth.se/~gimaker/vs/vccopy_dbg.py here]. It dumps some debugging info to stdout. Use it to reproduce your results and send the stdout to me (at seaghost at hellokitty.com, or whatever you find suiting). Also screendumps if you think they'd be useful in finding the problem. --[[User:tiny paintings|tiny paintings]] 12:30, 26 Sep 2005 (PDT)
  
 
=== Possible improvments ===
 
=== Possible improvments ===

Revision as of 21:30, 26 September 2005

Script talk

Vertex colors messed up again

Thsi topic again :( Ok, i've tried to reproduce my perfect copied vertex colors with the original blender-file and it just doesn't work (in all cases). When i use the obj file (by importing it again... as i did at work) i get a fairly good result. But when using the blender-file (basically the source file to the obj) i get the messed up VCols again. :-/ It's a bit frustrating when i have to do the rad-process over and over again, just to find out that it didn't do it right. Did you get the .blend file i sent you via mail mail? Just purge the vertex colors of the mesh on the first layer and try doing the rad-process with that mesh. I dunno what i can do to improve this behaviour, but i'll try to help where i can. --Pontiac 10:40, 26 Sep 2005 (PDT)


What the... please say you forgot to use the new script?! Do you happend to have ICQ? If you do, my number is 1949713.

I got the .blend file - it's the file I used to reproduce the bug I fixed. When I used the obj file I had no problems, even with the old script.

Why do you have to relcalculate the radiosity? Isn't it only transfering the vertex colors to the original mesh that's causing trouble? I put together a little debugging version of the script, here. It dumps some debugging info to stdout. Use it to reproduce your results and send the stdout to me (at seaghost at hellokitty.com, or whatever you find suiting). Also screendumps if you think they'd be useful in finding the problem. --tiny paintings 12:30, 26 Sep 2005 (PDT)

Possible improvments

  • Somehow change the script so that it sets the object centers correctly. Then we can remove the object->world transformation, sort on object space coords and and the vertex color copy would work even if one or both of the meshes are moved around. Not very urgent, just don't move the meshes around!

Original script

This is the original Script by tiny paintings. See the main page for the most recent version.

Warning: This script contains a serious bug and will only work if your objects origin (the little purple dot) is in the origin.

You have to pardon my python n00bness, this is all I could come up with. Feel free to improve it!

import Blender

# WHAT DOES IT DO?
# This script copies the vertex color information from one mesh
# to another, and does so correctly assuming the meshes have the
# same geometry, vertex-wise.

# IMPORTANT: Assumes meshes with exactly equal geometry, vertex-wise.

fromObj = "Mesh"  # Set this to the resulting mesh from radio calcuation
toObj = "Fuselage_default" # Set this to the name of your original, UV-mapped mesh.

me_from = Blender.Object.Get(fromObj).getData()
me_to = Blender.Object.Get(toObj).getData()

if not me_to and not me_from:
	print "ERROR: Source/destination object does not exist"

elif len(me_to.verts) != len(me_from.verts):
	print "ERROR: Source and destination objects must have the same number of vertices"
	
else:
	# make two lists sorted on coordinates,
	# containing a face and vertex index i and j respectively
	
	l_to = []
	l_from = []
	
	# format: [ (x,y,z, face index, vertex index), ... ]
	
	for i in range(len(me_to.faces)):
		for j in range(len(me_to.faces[i].v)):
			vert = me_to.faces[i].v[j].co
			l_to.append((vert[0], vert[1], vert[2], i, j))
			
		for j in range(len(me_from.faces[i].v)):
			vert = me_from.faces[i].v[j].co
			l_from.append((vert[0], vert[1], vert[2], i, j))
		
	# Sort the lists after vertex coordinates
	l_to.sort()	
	l_from.sort()
	
	for i in range(len(l_to)):
		to_f = l_to[i][3]
		from_f = l_from[i][3]
		to_v = l_to[i][4]
		from_v = l_from[i][4]
		
		me_to.faces[to_f].col[to_v] = me_from.faces[from_f].col[from_v]
			

	me_to.update()
	print "Copied vertex color information from object "+fromObj+" to object "+toObj+"."