Sign in to follow this  
Dragon_Strike

help with gemorphing

Recommended Posts

im trying to get geomorphing working in my program... im using the algorithm described in röttgers paper... everything looks fine expt when the morphing ocurs where to different detillevels meet... röttger says in his paper "the blending value for a shared edge is obtained by taking th eminimum of the blending values of the two involved blocks"... i dont rly understand is important sentence.. right now im taking the minimum blending value of the current node and its neighbour in the directing from the center to the current morphed vertex... blending for right fan vertex = min(node(x,z), node(x+nodesize,z)) which works fine until the neighbouring vertex one or more child and less than 4... since the child has a corner in the morphing vertex its corner vertex isnt morphed... my question is how do i take the neighbours child into account?
works:
|\   /|\  /|
| \ / | \/ |
| / \ | /\ |
|/   \|/  \|

doesnt work:
|\   /|\  /|
| \ / | \/ |
| / \ |\/\ |
|/   \|/\ \|



here is the sourcecode for rendering a leaf node:
// BMatrix = Blendingfactors (= min(max(0,2*(1-f)), 1);)

		if (!(Matrix[GetIndex(x+ChildOffset, z+ChildOffset)] || Matrix[GetIndex(x+ChildOffset, z-ChildOffset)] || Matrix[GetIndex(x-ChildOffset, z-ChildOffset)] || Matrix[GetIndex(x-ChildOffset, z+ChildOffset)]))
		{
			glBegin( GL_TRIANGLE_FAN );
				
			Height = (GetHeight(x+ChildEdgeSize,z+ChildEdgeSize)+GetHeight(x-ChildEdgeSize,z-ChildEdgeSize)+
				     GetHeight(x+ChildEdgeSize,z+ChildEdgeSize)+GetHeight(x-ChildEdgeSize,z-ChildEdgeSize))/4.0f*(1-BMatrix[GetIndex(x, z)])+
					 GetHeight(x,z)*BMatrix[GetIndex(x, z)];

			// CENTER
			RenderVertex(x, z, Height);

			// TOP RIGHT	
			RenderVertex(x+ChildEdgeSize, z+ChildEdgeSize);

			if ( (x+EdgeSize) <= m_size && Matrix[GetIndex(x+EdgeSize, z)])
			{
				Blend = min(BMatrix[GetIndex(x, z)],BMatrix[GetIndex(x+EdgeSize, z)]);
				Height = (GetHeight(x+ChildEdgeSize,z+ChildEdgeSize)+GetHeight(x+ChildEdgeSize,z-ChildEdgeSize))/2.0f*(1-Blend)+
					 GetHeight(x+ChildEdgeSize, z)*Blend;
				// RIGHT
				RenderVertex(x+ChildEdgeSize, z, Height);
			}

			// BOTTOM RIGHT			
			RenderVertex(x+ChildEdgeSize, z-ChildEdgeSize);
			
			if ( (z-EdgeSize) > 0 && Matrix[GetIndex(x, z-EdgeSize)])
			{
				Blend = min(BMatrix[GetIndex(x, z)],BMatrix[GetIndex(x, z-EdgeSize)]);
				Height = (GetHeight(x+ChildEdgeSize,z-ChildEdgeSize)+GetHeight(x-ChildEdgeSize,z-ChildEdgeSize))/2.0f*(1-Blend)+
					 GetHeight(x, z-ChildEdgeSize)*Blend;
				// BOTTOM
				RenderVertex(x, z-ChildEdgeSize, Height);
			}

			// BOTTOM LEFT
			RenderVertex(x-ChildEdgeSize, z-ChildEdgeSize);

			if ( (x-EdgeSize) > 0 && Matrix[GetIndex(x-EdgeSize, z)])
			{
				Blend = min(BMatrix[GetIndex(x, z)],BMatrix[GetIndex(x-EdgeSize, z)]);
				Height = (GetHeight(x-ChildEdgeSize,z+ChildEdgeSize)+GetHeight(x-ChildEdgeSize,z-ChildEdgeSize))/2.0f*(1-Blend)+
					 GetHeight(x-ChildEdgeSize, z)*Blend;
				// LEFT
				RenderVertex(x-ChildEdgeSize, z, Height);
			}

			// TOP LEFT
			RenderVertex(x-ChildEdgeSize, z+ChildEdgeSize);

			if ( (z+EdgeSize) <= m_size && Matrix[GetIndex(x, z+EdgeSize)])
			{
				Blend = min(BMatrix[GetIndex(x, z)],BMatrix[GetIndex(x, z+EdgeSize)]);
				Height = (GetHeight(x+ChildEdgeSize,z+ChildEdgeSize)+GetHeight(x-ChildEdgeSize,z+ChildEdgeSize))/2.0f*(1-Blend)+
					 GetHeight(x, z+ChildEdgeSize)*Blend;
				// TOP
				RenderVertex(x, z+ChildEdgeSize, Height);
			}

			// TOP RIGHT	
			RenderVertex(x+ChildEdgeSize, z+ChildEdgeSize);

		glEnd();
		
		}




i hope atleast someone understood... if there is something ive written unclear please tell me and ill try to sort it out... [Edited by - Dragon_Strike on July 21, 2006 12:01:20 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this