Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

hlsl - how do i reflect meshes of the same type to be opposite.

$
0
0
Hi all and thanks for reading.

My issue is that I wish to know the correct method for reflecting a mesh against another of the same type using the shader.

Im sure this can be done, but I am a noob so that might explain why i cant find any resources that directly point out how to rotate a mesh in hlsl (though i am sure there is etc)

To give you the scenario..
Imagine I have a wing already loaded and flapping by vertex animation in the shader.
I have another copy of that mesh in the program and imitating the movement of the first wing mesh, as it is literally a copy of the first meshes hlsl code that animates the wing, jyst with the function specified for the second mesh etc.

I want the second mesh to appear opposite to the 1st mesh so i have a rudimentary pair of flapping wings, linear in the fashion regarding the flap element.

ATM, I have a mesh with two wings attahced, both on the same side, both flapping in unison. I am desperate to swap one wing to the opposite side of my mesh utilising those wings.

DirectX 10 is seperating me from the men!


I am pretty confident I goota do something around here


	renderMesh(pd3dDevice, g_p_TechniqueWingLeft, &g_wing1);

	//code here to render opposite side i think
       // I think it needs a rotation and a possible D3DXToRadians thingy 

	//currently the pointy wing to differentiate (note: reset this back in shader later)
	renderMesh(pd3dDevice, g_p_TechniqueWingRight, &g_wing2);





Below is the code section manipulating the mesh , this is in my mind the ideal place to do the rotation so it is done here rather than relying on D3DMatrixRotationY or something like that.



VS_OUTPUT RenderTigerWingRightVS(VS_INPUT input)
{
	VS_OUTPUT Output;
	
	//**********************************************************************//
	// Deform the mesh here for the right wing.	                        //
	// .									//
	//**********************************************************************//
	
	float wingBase2 = 0.55;				//The tiger is created with its wing pointing
										//straight out on the x axis, so the wing 
	//wingBase2 = (4/3.14159) / 180;

	if (input.vPos.x > wingBase2 )		//begins at x= tailBase
	{
		float distanceFromBum = wingBase2 - input.vPos.y;
		
		input.vPos.z = g_fTailAngle * distanceFromBum;  //Wag from side to side.
	}

	
	float3 vNormalWorldSpace;
	
	// Transform the position from object space to homogeneous projection space
	Output.Position = mul(input.vPos, g_mWorldViewProjection);
	
	// Whatever we do to the object we must do to its normal vector.    
	vNormalWorldSpace = normalize(mul(input.vNormal, (float3x3)g_mWorld)); // normal (world space)

	// Calc diffuse color    
	Output.Diffuse.rgb = g_MaterialDiffuseColor * g_LightDiffuse * max(0,dot(vNormalWorldSpace, g_LightDir)) + 
						 g_MaterialAmbientColor;   
		
	Output.Diffuse.a = 1.0f; 
	
	// Just copy the texture coordinate through
	Output.TextureUV = input.vTexCoord0; 
	
	return Output;    
}

/*********************************END RIGHT WING******************************/






For anyone still reading.......
Help.......
& thanks.
Gruffy

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>