Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 26 May 2000 - 07:10 AM
Posted 26 May 2000 - 07:15 AM
Posted 26 May 2000 - 07:37 AM
Posted 26 May 2000 - 10:42 AM
Posted 26 May 2000 - 11:33 AM
Posted 26 May 2000 - 01:43 PM
Posted 26 May 2000 - 01:48 PM
void __fastcall CalcVertexNormal(PVERTEX pVertex)
{
float x = pVertex->x;
float y = pVertex->y;
float z = pVertex->z;
float dx1 = (x-tx1);
float dx2 = (x-tx2);
float dx3 = (x-tx3);
float dx4 = (x-tx4);
float dy1 = (y-ty1);
float dy2 = (y-ty2);
float dy3 = (y-ty3);
float dy4 = (y-ty4);
float dz1 = (z-tz1);
float dz2 = (z-tz2);
float dz3 = (z-tz3);
float dz4 = (z-tz4);
float n1 = dx1*dx1 + dy1*dy1 + dz1*dz1;
float n2 = dx2*dx2 + dy2*dy2 + dz2*dz2;
float n3 = dx3*dx3 + dy3*dy3 + dz3*dz3;
float n4 = dx4*dx4 + dy4*dy4 + dz4*dz4;
n1 = MB_SIZE*MB_SIZE / (sqrt(n1) * n1);
n2 = MB_SIZE*MB_SIZE / (sqrt(n2) * n2);
n3 = MB_SIZE*MB_SIZE / (sqrt(n3) * n3);
n4 = MB_SIZE*MB_SIZE / (sqrt(n4) * n4);
pVertex->nx = dx1*n1 + dx2*n2 + dx3*n3 + dx4*n4;
pVertex->ny = dy1*n1 + dy2*n2 + dy3*n3 + dy4*n4;
pVertex->nz = dz1*n1 + dz2*n2 + dz3*n3 + dz4*n4;
}
Posted 26 May 2000 - 02:10 PM
Posted 26 May 2000 - 02:26 PM
Posted 26 May 2000 - 02:35 PM
Posted 26 May 2000 - 03:42 PM
Posted 26 May 2000 - 04:55 PM
rr = (x-tx1)*(x-tx1) + (y-ty1)*(y-ty1) + (z-tz1)*(z-tz1);
Force = MB_SIZE*MB_SIZE/rr;
n = MB_SIZE*MB_SIZE / (sqrt(rr) * rr);
pVertex->nx = (x-ballx)*n;
pVertex->ny = (y-bally)*n;
pVertex->nz = (z-ballz)*n;
Posted 26 May 2000 - 04:59 PM
inline D3DVECTOR CMetaBallApp::Normal(D3DVECTOR &Pos)
{
D3DVECTOR N = D3DVECTOR(0,0,0);
for( int i = 0; i < m_nNumBalls; i ++ )
{
D3DVECTOR v = Pos - m_Balls;
float m = SquareMagnitude(v);
m = SQRADIUS / (m*m);
N += v*m;
}
return Normalize(N);
}
Posted 26 May 2000 - 05:15 PM
Posted 26 May 2000 - 05:33 PM
Posted 26 May 2000 - 06:48 PM
inline float CMetaBallApp::Energy(D3DVECTOR &Pos)
{
float e = 0;
for( int i = 0; i < m_nNumBalls; i++ )
{
float SqDistance = SquareMagnitude(Pos - m_Balls[ i ]);
e += SQRADIUS / SqDistance;
}
return e;
}
inline D3DVECTOR CMetaBallApp::Normal(D3DVECTOR &Pos)
{
D3DVECTOR N = D3DVECTOR(0,0,0);
for( int i = 0; i < m_nNumBalls; i ++ )
{
D3DVECTOR v = Pos - m_Balls[ i ];
float SqDistance = SquareMagnitude(v);
v /= (float)sqrt(SqDistance); // Normalize the vector
// We should scale this vector so that the contribution from this
// metaball is inversely proportional to the square distance, because
// the energy from it is also inversely proportional to the square
// distance.
N += (SQRADIUS / SqDistance)*v;
}
return Normalize(N);
}
Posted 26 May 2000 - 08:00 PM
Posted 27 May 2000 - 06:26 AM
Posted 27 May 2000 - 09:01 AM
Posted 27 May 2000 - 09:11 AM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.