I think you have hit the nail on the head there Wjbender.
i suspect the normals are being 'corrupted' during the merge.

Im afraid (and sorry) I dont have the time to look at this more closely ATM,
but Im juggling too many other jobs at this time already.


OFF-HAND, I dont think using txesmi's calculaions is a good idea,
because if either of the meshes had 'custom' normals, re-calculating
them will erase any customisation/weightings.

BUT, youve sucessfully spotted that the vertices needed to be rotated,
and you seem to have implemented that OK, but normals are also VERY
angle-dependant, so they need rotated too.

I have never actually tried this, and so it is only an extrapolation of the
little that I THINK I know.

So try this UNTESTED code and see how we go.
This is the 'source1' mesh vertex loop, and you will need to do the same
calculation in the 'source2's loop also.
Code:
...
		for (iterate=0;iterate<vertices_source1;iterate++)	
		{
			temp1.x=source1.x+vbuffer_source1[iterate].x*source1.scale_x;
			temp1.y=source1.y+vbuffer_source1[iterate].y*source1.scale_z;
			temp1.z=source1.z+vbuffer_source1[iterate].z*source1.scale_y;
			
			VECTOR final;
			final.x=temp1.x;
			final.y=temp1.z;
			final.z=temp1.y;
			vec_rotate(final.x,source1.pan);

			merged_vbuffer[iterate].x=final.x;
			merged_vbuffer[iterate].y=final.z;
			merged_vbuffer[iterate].z=final.y;

			//	=========  START of EvilSOB's suggestion	===============
			VECTOR new_norm;
			new_norm.x = vbuffer_source1[iterate].nx;
			new_norm.y = vbuffer_source1[iterate].ny;
			new_norm.z = vbuffer_source1[iterate].nz;
			vec_rotate(new_norm, source1.pan);
			//  vec_normalize(new_norm, 1);   //maybe?!?
			//
			merged_vbuffer[iterate].nx = new_norm.nx;
			merged_vbuffer[iterate].ny = new_norm.ny;
			merged_vbuffer[iterate].nz = new_norm.nz;
			//	=========  END of EvilSOB's suggestion	===============
			
			merged_vbuffer[iterate].u1=vbuffer_source1[iterate].u1;
			merged_vbuffer[iterate].v1=vbuffer_source1[iterate].v1;
			merged_vbuffer[iterate].u2=vbuffer_source1[iterate].u2;
			merged_vbuffer[iterate].v2=vbuffer_source1[iterate].v2;
			
		}
...

These following points are listed in priority order, as best as I can figure...

Bear in mind, this is code 'off the top of my head', so firstly, beware of syntax or bracket errors.

Secondly, it is POSSIBLE this code will need to have the ny/nz swapovers for the vec-rotate, but I suspect not,
so this code does NOT have the swapping implemented yet, try it as-is first.

And thirdly, Im not sure of vec-rotate working with normals... I just dont understand the maths inside normals
enough to be sure, so if things still wont look right, try some other vec-rotational functions,
like vec_rotateback() or ang_add, or even vec_add/vec_sub. I strongly suggest also using
vec_normalize on these results if you 'break away' from the original vec_rotate.

And in combination with these, it may be worth putting in a vec_normalize between
the vec-rotating and the storing into merged_vbuffer. But I think this is probably un-necessary.
(I have shown it in the code but have left it commented-out initially)


Best of luck... and I hope this helps...

I am watching this thread with interest...


[EDIT] I missed Pappenheimer's post, and its good its 'fixed', but hopefully someone will try my suggestions anyway...




Last edited by EvilSOB; 06/02/12 16:26.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial