splitting polygons - colours and texture corrdinates
hi,
iv managed to get together a function to split a convex polygon, but im having trouble calculating the new colours and texture coordinates for the new points, any ideas?
the code i currently have is:
//compute intersection point of line
//from ptA to ptB with the partition.
VECTOR3D v = ptB - ptA;
double sect = - partition.distance(ptA) / (partition.normal().dotProduct(v));
VERTEX3D add(ptA.x + (v.x * sect), ptA.y + (v.y * sect), ptA.z + (v.z * sect));
//set the colour
add.colour4ub((ptB.r * sect) + (ptA.r * (1-sect)), (ptB.g * sect) + (ptA.g * (1-sect)), (ptB.b * sect) + (ptA.b * (1-sect)), (ptB.a * sect) + (ptA.a * (1-sect)));
//set texture coords
add.coords((ptB.u * sect) + (ptA.u * (1-sect)), (ptB.v * sect) + (ptA.v * (1-sect)));
**PLANE3D::distance(VERTEX3D &) returns the distance a point is from the plane**
**the calculations for the new VERTEX3D work fine, iv tested this and it''s all good, its just the colours and the tex coords.. that code so nearly works, its painful, but the texture moves a little bit, depending on where the split occurs, also im about 50% sure that the colour calculations are right, cos visually they seem to work, but would be grateful for a second opinion, thanks in advance,
hybrid :D
cmon people! help! 
its just a case of calculating the new coordinate/colour based on the values of the two points on the line being tested (ptA -> ptB) and calculate the new value based on how far along the line the intersection occurs... which is ''sect'' no?

its just a case of calculating the new coordinate/colour based on the values of the two points on the line being tested (ptA -> ptB) and calculate the new value based on how far along the line the intersection occurs... which is ''sect'' no?

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement