I noticed there is not really a post dedicated to texture clamping.
So I'm starting one since I'm currently trying to figure it out.
Please post anything on clamping even if it doesn't directly relate to my code : 3(D)
This is a my simple function for UV mapping.
void UVmapping(void)
{
for(int tt=0; tt<9999; tt++)
{
if(trifil[tt].on)
{
for(int s=0; s<3; s++)
{
trifil[tt].u[s]=(trifil[tt].xx[s]+trifil[tt].yy[s])/52.0;
trifil[tt].v[s]=(trifil[tt].zz[s]+trifil[tt].yy[s])/52.0;
}
}
}
for(int o=0; o<500; o++)
{
if(obj[o].on)
{
for(int i=0; i<512; i++)
{
if(obj[o].tri[i].on)
{
for(int s=0;s<3;s++)
{
obj[o].tri[i].u[s]=(obj[o].tri[i].xx[s]+obj[o].x+obj[o].tri[i].yy[s]+obj[o].y)/52.0;
obj[o].tri[i].v[s]=(obj[o].tri[i].zz[s]+obj[o].z+obj[o].tri[i].yy[s]+obj[o].y)/52.0;
}
}
}
}
}
}
This is my failed attempt to clamp.
void UVmapping(void)
{
float slipx=0,slipz=0;
float lowest=0;
/* for(int tt=0; tt<9999; tt++)
{
if(trifil[tt].on)
{
for(int s=0; s<3; s++)
{
trifil[tt].u[s]=((trifil[tt].xx[s]+slipx)+trifil[tt].yy[s])/52.0;
trifil[tt].v[s]=((trifil[tt].zz[s]+slipz)+trifil[tt].yy[s])/52.0;
}
}
}*/
for(int o=0; o<500; o++)
{
if(obj[o].on)
{
for(int i=0; i<512; i++)
{
if(obj[o].tri[i].on)
{
for(int s=0;s<3;s++)
{
obj[o].tri[i].u[s]=((obj[o].tri[i].xx[s]+obj[o].x+slipx)+obj[o].tri[i].yy[s]+obj[o].y)/52.0;
obj[o].tri[i].v[s]=((obj[o].tri[i].zz[s]+obj[o].z+slipz)+obj[o].tri[i].yy[s]+obj[o].y)/52.0;
}
for(int s=0;s<3;s++)
{
int ss=s+1; if(ss>2){ss=0;}
if(abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss])<.00135)
{
slipx+=abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss]+.01)*1352;
}
if(abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss])<.00135)
{
slipz+=abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss]+.01)*1352;
}
ss=s-1; if(ss<0){ss=2;}
if(abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss])<.00135)
{
slipx+=abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss]+.01)*1352;
}
if(abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss])<.00135)
{
slipz+=abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss]+.01)*1352;
}
ss=s+1; if(ss>2){ss=0;}
if(abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss])<lowest && abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss])!=0)
{
lowest=abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss]);
}
if(abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss])<lowest && abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss])!=0)
{
lowest=abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss]);
}
ss=s-1; if(ss<0){ss=2;}
if(abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss])<lowest && abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss])!=0)
{
lowest=abs(obj[o].tri[i].u[s]-obj[o].tri[i].u[ss]);
}
if(abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss])<lowest && abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss])!=0)
{
lowest=abs(obj[o].tri[i].v[s]-obj[o].tri[i].v[ss]);
}
obj[o].tri[i].u[s]=((obj[o].tri[i].xx[s]+obj[o].x+slipx)+obj[o].tri[i].yy[s]+obj[o].y)/52.0;
obj[o].tri[i].v[s]=((obj[o].tri[i].zz[s]+obj[o].z+slipz)+obj[o].tri[i].yy[s]+obj[o].y)/52.0;
}
}
}
}
}
dbSync();
dbText(13,13,dbStr(lowest));
dbSync();
dbWait(1000);
}