1
Support / Re: Multiple rotations on different pivots
« on: June 13, 2013, 05:06:44 pm »
Okay I'll try that, thanks ;-)
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Matrix mat = new Matrix( target.calcSub( head.gettranslatedCenter()).normalize()).getRotationMatrix() );
head.setRotationMatrix(mat);
varying vec3 lightDir;
varying float att[gl_MaxLights];
void main()
{
vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
int i;
for (i=0; i<gl_MaxLights; ++i) {
lightDir = vec3(gl_LightSource[i].position.xyz - vVertex);
float d = length(lightDir);
att[i] = 1.0 / ( gl_LightSource[0].constantAttenuation +(gl_LightSource[0].linearAttenuation*d) +(gl_LightSource[0].quadraticAttenuation*d*d) );
}
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
varying float att[gl_MaxLights];
uniform sampler2D colorMap;
void main (void)
{
vec4 final_color;
int i;
for (i=0; i<gl_MaxLights; ++i) {
if(att[i]>0) {
final_color = final_color + ( gl_LightSource[i].diffuse * att[i] * texture2D( colorMap, gl_TexCoord[0].st ) ) ;
}
}
gl_FragColor = final_color;
}
// perso.sprite.getMain() returns the head which is the parent object of the character
cam.setPositionToCenter(perso.sprite.getMain());
cam.align(perso.sprite.getMain());
cam.rotateX(totalRotationX);
world.checkCameraCollisionEllipsoid(Camera.CAMERA_MOVEOUT, ellipsoidCam, 10, 8);
world.checkCameraCollisionEllipsoid(Camera.CAMERA_MOVEUP, ellipsoidCam, 1, 5);