Archived

This topic is now archived and is closed to further replies.

Weird unresolved external symbols.. 4-th time:)

This topic is 5579 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay.. i really need to get em fixed.. i have tried everything, triple checked everything and i cannot think of any possible reason why 80% of them occur. I am sure i have all the lib files i need for the error funcs. All includes seem to be in place, cpp files needed should all be in the project. also the funcs with errors only use funcs from the cpp files i have AND math.h (which i suspect is the problem someway). i have tried rebuilding and even recreating the project. It could be the project settings. Yeah, this is my 4-th posting so if i failed to mention something my previous 3 should contain it... just look over my profile.. they shuld be the most recent new threads. here are the errors: the error list: Linking... Animation.obj : error LNK2001: unresolved external symbol "public: void __thiscall cQuaternion::ConvertToAxisAngle(void)" (?ConvertToAxisAngle@cQuaternion@@QAEXXZ) Animation.obj : error LNK2001: unresolved external symbol "public: int __thiscall cPart::ApplyCurrentToRotFrom(class cQuaternion *,int)" (?ApplyCurrentToRotFrom@cPart@@QAEHPAVcQuaternion@@H@Z) BSPStuff.obj : error LNK2001: unresolved external symbol "public: bool __thiscall cCITriangle::CheckSplit(class cPlane &,class cVertex *)" (?CheckSplit@cCITriangle@@QAE_NAAVcPlane@@PAVcVertex@@@Z) BSPStuff.obj : error LNK2001: unresolved external symbol "public: enum ePlaneLocation __thiscall cPlane::Test(class cPoint3 const &)" (?Test@cPlane@@QAE?AW4ePlaneLocation@@ABVcPoint3@@@Z) BSPStuff.obj : error LNK2001: unresolved external symbol "public: void __thiscall cPlane::Create(class cPoint3 const &,class cPoint3 const &,class cPoint3 const &)" (?Create@cPlane@@QAEXABVcPoint3@@00@Z) Culling.obj : error LNK2001: unresolved external symbol "public: float __thiscall cPlane::Func(class cPoint3 const &)" (?Func@cPlane@@QAEMABVcPoint3@@@Z) Patches.obj : error LNK2001: unresolved external symbol "public: float __thiscall cPlane::Func(class cPoint3 const &)" (?Func@cPlane@@QAEMABVcPoint3@@@Z) Rendering.obj : error LNK2001: unresolved external symbol "public: float __thiscall cPlane::Func(class cPoint3 const &)" (?Func@cPlane@@QAEMABVcPoint3@@@Z) InitGame.obj : error LNK2001: unresolved external symbol "public: void __thiscall GfxLayer::DrawOneFrame(unsigned long)" (?DrawOneFrame@GfxLayer@@QAEXK@Z) InitGame.obj : error LNK2001: unresolved external symbol "public: void __thiscall GfxLayer::SetRenderStates(void)" (?SetRenderStates@GfxLayer@@QAEXXZ) InitGame.obj : error LNK2001: unresolved external symbol "public: bool __thiscall GfxLayer::CreateBuffers(unsigned int)" (?CreateBuffers@GfxLayer@@QAE_NI@Z) Rendering.obj : error LNK2001: unresolved external symbol "public: bool __thiscall cPart::Transform(class cMatrix4,class cMatrix4,class cVertex *,unsigned int,unsigned int *,class cITriangle *,unsigned int,unsigned int *,class stlport::vectorcIndexArray *,class stlport::allocator > *,class cFrustum *,unsigned int *,unsigned int)" (?Transform@cPart@@QAE_NVcMatrix4@@0PAVcVertex@@IPAIPAVcITriangle@@I2PAV?$vector@PAVcIndexArray@@V?$allocator@PAVcIndexArray@@@stlport@@@s tlport@@PAVcFrustum@@2I@Z) Rendering.obj : error LNK2001: unresolved external symbol "public: bool __thiscall cMatrix4::operator=(class cMatrix4 const &)" (??4cMatrix4@@QAE_NABV0@@Z) Rendering.obj : error LNK2001: unresolved external symbol "class cMatrix4 __cdecl operator*(class cMatrix4 const &,class cMatrix4 const &)" (??D@YA?AVcMatrix4@@ABV0@0@Z) Rendering.obj : error LNK2001: unresolved external symbol "public: class cMatrix4 __thiscall cPoint3::Translate(void)" (?Translate@cPoint3@@QAE?AVcMatrix4@@XZ) Rendering.obj : error LNK2001: unresolved external symbol "public: class cMatrix4 __thiscall cQuaternion::ConvertToMatrix(void)" (?ConvertToMatrix@cQuaternion@@QAE?AVcMatrix4@@XZ) Rendering.obj : error LNK2001: unresolved external symbol "public: bool __thiscall cObject::TestFrustum(class cFrustum *)" (?TestFrustum@cObject@@QAE_NPAVcFrustum@@@Z) Rendering.obj : error LNK2001: unresolved external symbol "public: bool __thiscall cWorldCell::TestFrustum(class cFrustum *)" (?TestFrustum@cWorldCell@@QAE_NPAVcFrustum@@@Z) Rendering.obj : error LNK2001: unresolved external symbol "public: void __thiscall cWorldCell::Cull(class stlport::vector > *,class cFrustum *,class cPoint3 const &,bool)" (?Cull@cWor ldCell@@QAEXPAV?$vector@PAVcIndexArray@@V?$allocator@PAVcIndexArray@@@stlport@@@stlport@@PAVcFrustum@@ABVcPoint3@@_N@Z) UtilMain.obj : error LNK2001: unresolved external symbol "class cPoint3 __cdecl operator*(class cMatrix4 const &,class cPoint3 const &)" (??D@YA?AVcPoint3@@ABVcMatrix4@@ABV0@@Z) UtilMain.obj : error LNK2001: unresolved external symbol "bool __cdecl operator==(class cPoint3 const &,class cPoint3 const &)" (??8@YA_NABVcPoint3@@0@Z) UtilMain.obj : error LNK2001: unresolved external symbol "class cPoint3 __cdecl operator+(class cPoint3 const &,class cPoint3 const &)" (??H@YA?AVcPoint3@@ABV0@0@Z) LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 Debug/MyGame.exe : fatal error LNK1120: 21 unresolved externals Error executing link.exe.

Share this post


Link to post
Share on other sites
i kknew i forgot to mention something... i havent gotten around to winmain just yet... i wanted to compile and see what happenned.. is that causing all these errors or just the ones concerning winmain?
And as for that very obivous remark about the 4-th posting.,. i REALLY need this answered

[edited by - Velochy on September 3, 2002 1:14:51 PM]

Share this post


Link to post
Share on other sites
Make sure you indicate exactly which .lib files you are using. Just pointing to the directory that the .lib files exist on isn''t enough. If you are using Visual C++ 6.0 or similar, you should be able to see which lib files are included under your "project settings".

Share this post


Link to post
Share on other sites
yeah.. i have all i think i need included IN project settings... ah..one question.. where do the functions of math.h get their function bodies... are they defined in math.h or (this is what i think might be the mess) are they in a separate lib file or cpp file which needs to be mentioned?

Share this post


Link to post
Share on other sites
The easiest way is to look up the documentation provided,... or trial-and-error.

[EDIT] ... and beware of the STRICT symbol, some libs are compiled with the STRICT defined, some are not. Linking a STRICT-defined project with a STRICT-undefined lib will have similar problems.... I once got fustrated with the CDX library because of this, heheheh.

[edited by - DerekSaw on September 4, 2002 1:58:43 AM]

Share this post


Link to post
Share on other sites
actually im pretty sure math.h doesnt really need any libs included.. i have compiled stuff with math.h before without ever mentioning any lib files to da project. As for STRICT - I HAVE NO IDEA what you are talking about right about there... im somewhere between beginner and intermediate programmer and have not really met any definitions of STRICT or what it would mean yet

Share this post


Link to post
Share on other sites
This is nothing to do with math.h, so stop worrying about that. The problems are coming from user-supplied classes, not standard ones. Find out where these functions are declared - ie. which header they''re from. Use a search-in-files if you don''t know. That should then give you an idea of what CPP or LIB file you need to include in your project.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites
i can say with all that i possibly know that all the cpp files are there... i only use standard DX lib files and standard windows lib files and nothin more.. cuz i dont need it.
And yeah, me know its weird but yeah.. i just triple checked.. the cpp file needed is in the file view window of the project, it is not excluded and therefor me have o idea why tisPl be happenin.
So please? anyone got any possible ideas of what might be wrong with my project?

[edited by - Velochy on September 4, 2002 4:56:08 PM]

Share this post


Link to post
Share on other sites
quote:
i only use standard DX lib files and standard windows lib files and nothin more.. cuz i dont need it.

Well, you are certainly using more than that. To site a few examples from your error messages:

cQuaternion
cPlane
cGfxLayer
cPart
cPoint3

These do not exist in directX or windows. You are using these in your code, so you must link with the lib or object files that have these classes in them.

Share this post


Link to post
Share on other sites
"#define STRICT" before "#include "windows.h", or add it under Projects Settings... hmm... since u said u didn''t use any other 3rd party libs (except DX)... so the STRICT doesn''t help here. How about u choose the smallest one.h and one.cpp and let us see. ... how about do a Rebuild All and post the ''Build'' output.

Share this post


Link to post
Share on other sites
MathClasses files are probably most sensible thing to post due to the fact that most the funcs it cannot find are from there
if it helps, feel free to use it and test it for all your needs... just about anyone could whip something up quite fast(somewhere along the lines of few hrs for experienced programmers prolly)

here is my MathClasses.cpp

  
#include "MathClasses.h"
#include "3DClasses.h"
#include <math.h>

// cPoint3 stuff


inline float cPoint3::Mag() const
{
return (float)sqrt(x*x+y*y+z*z);
}

inline matrix4 cPoint3::Translate()
{
matrix4 mat;
mat.CreateTranslationMatrix(x, y, z);
return mat;
}

inline point3 operator+(point3 const &a, point3 const &b)
{
return point3(
a.x+b.x,
a.y+b.y,
a.z+b.z);
}

inline point3 operator-(point3 const &a, point3 const &b)
{
return point3(
a.x-b.x,
a.y-b.y,
a.z-b.z);
}

inline point3 operator*(float const &a, point3 const &b)
{
return point3(
b.x*a,
b.y*a,
b.z*a);
}

inline point3 operator*(point3 const &a, float const &b)
{
return b*a;
}

inline point3 operator/(point3 const &a, float const &b)
{
float dv=1.f/b;
return point3(
a.x*dv,
a.y*dv,
a.z*dv);
}

inline bool operator==(point3 const &a, point3 const &b)
{
if (fabs(a.x-b.x)<EPSILON && fabs(a.y-b.y)<EPSILON && fabs(a.z-b.z)<EPSILON)
return true;

return false;
}

inline float operator*(point3 const &a, point3 const &b)
{
return a.x*b.x+a.y*b.y+a.z*b.z;
}

inline point3 operator^(point3 const &a, point3 const &b) // ^ is <alt gr> + ä

{
return point3
(
(a.y*b.z-a.z*b.y),
(a.z*b.x-a.x*b.z),
(a.x*b.y-a.y*b.x)
);
}

inline point3 operator-(point3 const &a)
{
return point3(-a.x, -a.y, -a.z);
}


// cQuarternion stuff


inline void cQuaternion::Normalize()
{
float nm=sqrt(w*w+x*x+y*y+z*z);
w/=nm; x/=nm; y/=nm; z/=nm;
return;
}

inline quaternion cQuaternion::Normalized()
{
float nm=sqrt(w*w+x*x+y*y+z*z);
return cQuaternion(w/nm, x/nm, y/nm, z/nm);
}

inline void cQuaternion::NormalizeAxisAngle()
{
float nm=sqrt(x*x+y*y+z*z);
x/=nm; y/=nm; z/=nm;
return;
}

inline quaternion cQuaternion::NormalizedAxisAngle()
{
float nm=sqrt(x*x+y*y+z*z);
return cQuaternion(w, x/nm, y/nm, z/nm);
}

inline void cQuaternion::Invert() // If quaternions are normalized;

{
*this=-*this;
return;
}

inline class cQuaternion cQuaternion::Inverted() // If quaternions are normalized

{
return -*this;
}

inline matrix4 cQuaternion::ConvertToMatrix()
{
matrix4 mat;

float a, b, c; //buffer values;


a=2*x*x; b=2*y*y; c=2*z*z;

mat.m[0][0]=1-b-c; mat.m[2][2]=1-a-c; mat.m[3][3]=1-a-b;

a=2*x*y; b=2*w*z;

mat.m[0][1]=a-b; mat.m[1][0]=a+b;

a=2*x*z; b=2*w*y;

mat.m[0][2]=a+b; mat.m[2][0]=a-b;

a=2*y*z; b=2*w*x;

mat.m[1][2]=a-b; mat.m[2][1]=a+b;

return mat;
}

// I fail to understand te principles of this too.. so hope it works

inline void cQuaternion::MatrixToQuaternion(const matrix4 &mat)
{
float tr, s, q[4];
int i, j, k;
int nxt[3] = {1, 2, 0};


tr = mat.m[0][0] + mat.m[1][1] + mat.m[2][2];


// check the diagonal

if (tr > 0.0)
{
s = sqrt (tr + 1.0);
w = s / 2.0;
s = 0.5 / s;
x = (mat.m[1][2] - mat.m[2][1]) * s;
y = (mat.m[2][0] - mat.m[0][2]) * s;
z = (mat.m[0][1] - mat.m[1][0]) * s;
}
else
{
// diagonal is negative

i = 0;
if (mat.m[1][1] > mat.m[0][0]) i = 1;
if (mat.m[2][2] > mat.m[i][i]) i = 2;
j = nxt[i];
k = nxt[j];


s = sqrt ((mat.m[i][i] - (mat.m[j][j] + mat.m[k][k])) + 1.0);

q[i] = s * 0.5;

if (s != 0.0) s = 0.5 / s;


q[3] = (mat.m[j][k] - mat.m[k][j]) * s;
q[j] = (mat.m[i][j] + mat.m[j][i]) * s;
q[k] = (mat.m[i][k] + mat.m[k][i]) * s;


x = q[0];
y = q[1];
z = q[2];
w = q[3];
}
return;
}



inline void cQuaternion::EulerToQuaternion(float rx, float ry, float rz)
{
float cr, cp, cy, sr, sp, sy, cpcy, spsy;

// calculate trig identities

cr = cos(rx/2);
cp = cos(ry/2);
cy = cos(rz/2);


sr = sin(rx/2);
sp = sin(ry/2);
sy = sin(rz/2);

cpcy = cp * cy;
spsy = sp * sy;


w = cr * cpcy + sr * spsy;
x = sr * cpcy - cr * spsy;
y = cr * sp * cy + sr * cp * sy;
z = cr * cp * sy - sr * sp * cy;

return;
}

inline matrix4 cQuaternion::ConvertAxisAngleToMatrix()
{
matrix4 mat;
float si=sin(w),co=cos(w),buf=1-co;


mat.m[0][0]=x*x*buf+co; mat.m[0][1]=y*x*buf+z*si; mat.m[0][2]=z*x*buf-y*si;
mat.m[1][0]=x*y*buf-z*si; mat.m[1][1]=y*y*buf+co; mat.m[1][2]=z*y*buf+x*si;
mat.m[2][0]=x*z*buf+y*si; mat.m[2][1]=y*z*buf-x*si; mat.m[2][2]=z*z*buf+co;

return mat;
}

inline void cQuaternion::ConvertToAxisAngle() // Converts the values to fit Axis-Angle rotation w being the angle

{
float scale=x*x+y*y+z*z;

x/=scale; y/=scale; z/=scale;
w=2*acos(w);
return;
}

inline void cQuaternion::ConvertToQuaternion() // Converts Axis-Angle rotation back to Quarterion

{
float buf = sin(w/2);

x*=buf; y*=buf; z*=buf;
w=cos(w/2);
return;
}

inline quaternion cQuaternion::Slerp(quaternion * to, float t)
{
float to1[4];
double omega, cosom, sinom, scale0, scale1;


// calc cosine

cosom = x * to->x + y * to->y + z * to->z
+ w * to->w;


// adjust signs (if necessary)

if ( cosom <0.0 )
{
cosom = -cosom; to1[0] = - to->x;
to1[1] = - to->y;
to1[2] = - to->z;
to1[3] = - to->w;
}
else
{
to1[0] = to->x;
to1[1] = to->y;
to1[2] = to->z;
to1[3] = to->w;
}


// calculate coefficients


if ( (1.0 - cosom) > 0.001 )
{
// standard case (slerp)

omega = acos(cosom);
sinom = sin(omega);
scale0 = sin((1.0 - t) * omega) / sinom;
scale1 = sin(t * omega) / sinom;
}
else
{
// "from" and "to" quaternions are very close

// ... so we can do a linear interpolation

scale0 = 1.0 - t;
scale1 = t;
}

// calculate final values

return quaternion( scale0 * w + scale1 * to1[3],
scale0 * x + scale1 * to1[0],
scale0 * y + scale1 * to1[1],
scale0 * z + scale1 * to1[2]);
}


//saw the complicated thing on net... cant understand it but seems to have less multiplication-division - and optimized it abit:)

inline quaternion operator*(const quaternion &a, const quaternion &b)
{
float A, B, C, D, E, F, G, H;

E = (a.x + a.z)*(b.x + b.y);
F = (a.x - a.z)*(b.x - b.y);
G = (a.w + a.y)*(b.w - b.z);
H = (a.w - a.y)*(b.w + b.z);
A=E-F; B=E+F; C=G+H; D=G-H;


return quaternion( ((a.w + a.x)*(b.w + b.x)) + (-B + C )/2,
((a.w + a.x)*(b.w + b.x)) - ( B + C )/2,
((a.w - a.x)*(b.y + b.z)) + ( A + D )/2,
((a.y + a.z)*(b.w - b.x)) + ( A - C )/2);

}
/*
quaternion c;
c.w = a.w*b.w - a.x*b.x - a.y*b.y - a.z*b.z;
c.x = a.w*b.x + a.x*b.w + a.y*b.z - a.z*b.y;
c.y = a.w*b.y + a.y*b.w + a.z*b.x - a.x*b.z;
c.z = a.w*b.z + a.z*b.w + a.x*b.y - a.y*b.x;
return c;
*/

inline quaternion operator+(const quaternion &a, const quaternion &b)
{
return quaternion(a.w+b.w, a.x+b.x, a.y+b.y, a.z+b.z);
}

inline quaternion operator-(const quaternion &a)
{
return quaternion(a.w, -a.x, -a.y, -a.z);
}

// cPlane stuff

inline void cPlane::Create(const point3 &a, const point3 &b, const point3 &c)
{
n=((b-a)^(c-a));
n.Normalize();
d=-(n*a);
}

inline cPlane::cPlane(const point3 &a, const point3 &b, const point3 &c)
{
n=(b-a)^(c-a);
n.Normalize();
d=-(n*a);
}

inline pLoc cPlane::Test( const point3 & point )
{
float dp = (point * n) + d;

if (dp > EPSILON)
return plFront;
if (dp < -EPSILON)
return plBack;
else
return plCoplanar;
}

/* inline pLoc cPlane::TestPolygon( const class cPolygon & poly )
{
pLoc test=Test(poly.p[0]->p), res;

for(int i=1; i<3 ;i++)
{
res=Test(poly.p[i]->p);
if (test==plCoplanar)
test=res;

if (res!=plCoplanar && res!=test)
return plSplit;
}

return test;
}
*/


inline float cPlane::Func(const point3 & p)
{
return n.x*p.x+n.y*p.y+n.z*p.z-d;
}

inline bool cPlane::Compare(const plane &pl,const float deps,const float peps) //distance and point epsilon; peps is from 0.0 to 2.0

{
if ((pl.d>=d-deps && pl.d<=d+deps) || d<=-1)
{
float dsq=(pl.n-n).MagSquared();
if (dsq>peps*peps)
return true;
}
return false;
}


// cMatrix4 stuff


void cMatrix4::CreateTranslationMatrix(float x, float y, float z)
{
m[3][0]=x; m[3][1]=y; m[3][2]=z;
return;
}

void cMatrix4::ObjectLookAt(const point3 &loc, const point3 &lookAt, const point3 &inUp )
{
point3 View=lookAt-loc;

View= View/View.Mag();

point3 rUp = inUp - ( inUp*View ) * View;

rUp.Normalize();

point3 right = rUp ^ View;

m[0][0]=right.x; m[0][1]=rUp.x; m[0][2]=View.x; m[0][3]=0;
m[1][0]=right.y; m[1][1]=rUp.y; m[1][2]=View.y; m[1][3]=0;
m[2][0]=right.z; m[2][1]=rUp.z; m[2][2]=View.z; m[2][3]=0;
m[3][0]=loc.x; m[3][1]=loc.y; m[3][2]=loc.z; m[3][3]=1;

return;
}

void cMatrix4::CameraLookAt(const point3 &loc, const point3 &lookAt, const point3 &inUp )
{
point3 View=lookAt-loc;

View= View/View.Mag();

point3 rUp = inUp - ( inUp*View ) * View;

rUp.Normalize();

point3 right = rUp ^ View;

m[0][0]=right.x; m[0][1]=rUp.x; m[0][2]=View.x; m[0][3]=0;
m[1][0]=right.y; m[1][1]=rUp.y; m[1][2]=View.y; m[1][3]=0;
m[2][0]=right.z; m[2][1]=rUp.z; m[2][2]=View.z; m[2][3]=0;
m[3][0]=-(loc*right); m[3][1]=-(loc*rUp); m[3][2]=-(loc*View); m[3][3]=1;

return;
}

inline void cMatrix4::Invert()
{
matrix4 a;
point3 p= point3(_41,_42,_43);
float x=p*point3(_11,_21,_31);
float y=p*point3(_12,_22,_32);
float z=p*point3(_13,_23,_33);

*this=matrix4( _11, _21, _31, _14,
_12, _22, _32, _24,
_13, _23, _33, _34,
-x, -y, -z, _44);

return;
}

inline matrix4 cMatrix4::Inverted()
{
matrix4 a;
point3 p= point3(_41,_42,_43);
float x=p*point3(_11,_21,_31);
float y=p*point3(_12,_22,_32);
float z=p*point3(_13,_23,_33);

return matrix4( _11, _21, _31, _14,
_12, _22, _32, _24,
_13, _23, _33, _34,
-x, -y, -z, _44);
}

inline matrix4 cMatrix4::Rotation()
{
return cMatrix4(_11, _12, _13, 0.f,
_21, _22, _23, 0.f,
_31, _32, _33, 0.f,
0.f, 0.f, 0.f, 1.f );
}

inline matrix4 operator*(const matrix4 &a, const matrix4 &b)
{
matrix4 c;
int i, k;
for(i=0;i<4;i++)
for(k=0;k<4;k++)
c.m[i][k]=a.m[i][0]*b.m[0][k]+a.m[i][1]*b.m[1][k]+a.m[i][2]*b.m[2][k]+a.m[i][3]*b.m[3][k];

return c;
}

inline point3 operator*(const matrix4 &a, const point3 &b)
{
float w=a.m[3][0]*b.x+a.m[3][1]*b.y+a.m[3][2]*b.z+a.m[3][3];
return point3(a.m[0][0]*b.x+a.m[0][1]*b.y+a.m[0][2]*b.z+a.m[0][3],
a.m[1][0]*b.x+a.m[1][1]*b.y+a.m[1][2]*b.z+a.m[1][3],
a.m[2][0]*b.x+a.m[2][1]*b.y+a.m[2][2]*b.z+a.m[2][3])/w;
}


inline point4 operator*(const matrix4 &a, const point4 &b)
{
return point4(a.m[0][0]*b.x+a.m[0][1]*b.y+a.m[0][2]*b.z+a.m[0][3]*b.w,
a.m[1][0]*b.x+a.m[1][1]*b.y+a.m[1][2]*b.z+a.m[1][3]*b.w,
a.m[2][0]*b.x+a.m[2][1]*b.y+a.m[2][2]*b.z+a.m[2][3]*b.w,
a.m[3][0]*b.x+a.m[3][1]*b.y+a.m[3][2]*b.z+a.m[3][3]*b.w);
}


and its H file

  
#ifndef MATHCLASSES_H
#define MATHCLASSES_H

#define EPSILON 0.001f
#define PI 3.141592654f
#define SQRT_TWO 1.414213562f

class cMatrix4;

typedef enum ePlaneLocation
{
plFront,
plBack,
plCoplanar,
plSplit // Not used when testing points;

} pLoc;

/*typedef class cPoint2 // Mostly for checking what to render and all sorts of AI stuff(alto AI has to check the altitude (or the Y in x-y-z configuration)
{
public:
float x, y, z;

cPoint3()
{}

cPoint3(float X, float Y, float Z):
x(X), y(Y), z(Z)
{
}

inline void Assign(float X, float Y, float Z)
{
x=X; y=Y; z=Z;
}

inline float Mag() const;

inline float MagSquared() const
{
return (x*x+y*y+z*z);
}

inline void Normalize()
{
float p=1/Mag();
x*=p;
y*=p;
z*=p;
return;
}

inline cPoint3 Normalized()
{
float p=1/Mag();
return cPoint3(x*p,y*p,z*p);
}

inline float Dist(class cPoint3 const &a, const class cPoint3 &b)
{
cPoint3 n;
n.x=b.x-a.x; n.y=b.y-a.y; n.z=b.z-a.z;
return n.Mag();
}

inline class cMatrix4 Translate();

inline bool operator=(cPoint3 const &a)
{
x=a.x;
y=a.y;
z=a.z;
return true;
}

} point2;
*/

typedef class cPoint3
{
public:
float x, y, z;

cPoint3()
{}

cPoint3(float X, float Y, float Z):
x(X), y(Y), z(Z)
{
}

inline void Assign(float X, float Y, float Z)
{
x=X; y=Y; z=Z;
}

inline float Mag() const;

inline float MagSquared() const
{
return (x*x+y*y+z*z);
}

inline void Normalize()
{
float p=1/Mag();
x*=p;
y*=p;
z*=p;
return;
}

inline cPoint3 Normalized()
{
float p=1/Mag();
return cPoint3(x*p,y*p,z*p);
}

inline float Dist(class cPoint3 const &a, const class cPoint3 &b)
{
cPoint3 n;
n.x=b.x-a.x; n.y=b.y-a.y; n.z=b.z-a.z;
return n.Mag();
}

inline class cMatrix4 Translate();

inline bool operator=(cPoint3 const &a)
{
x=a.x;
y=a.y;
z=a.z;
return true;
}

} point3;

inline point3 operator+(point3 const &a, point3 const &b);

inline point3 operator-(point3 const &a, point3 const &b);

inline point3 operator*(float const &a, point3 const &b);

inline point3 operator*(point3 const &a, float const &b);

inline point3 operator*(point3 const &a, float const &b);

inline point3 operator/(point3 const &a, float const &b);

inline bool operator==(point3 const &a, point3 const &b);

inline float operator*(point3 const &a, point3 const &b);

inline point3 operator^(point3 const &a, point3 const &b);

inline point3 operator-(point3 const &a);



typedef class cPoint4
{
public:
float x, y, z, w;

cPoint4(float X, float Y, float Z, float W):
x(X), y(Y), z(Z), w(W)
{
}

} point4;

typedef class cMatrix4
{
public:
union
{
float m[4][4];
struct
{
float _11, _12, _13, _14,
_21, _22, _23, _24,
_31, _32, _33, _34,
_41, _42, _43, _44;
};
};

cMatrix4( float n11,float n12,float n13,float n14,
float n21,float n22,float n23,float n24,
float n31,float n32,float n33,float n34,
float n41,float n42,float n43,float n44)
{
m[0][0]=n11; m[0][1]=n12; m[0][2]=n13; m[0][3]=n14;
m[1][0]=n21; m[1][1]=n22; m[1][2]=n23; m[1][3]=n24;
m[2][0]=n31; m[2][1]=n32; m[2][2]=n33; m[2][3]=n34;
m[3][0]=n41; m[3][1]=n42; m[3][2]=n43; m[3][3]=n44;
}

cMatrix4( const float n[4][4] )
{
m[0][0]=n[0][0]; m[0][1]=n[0][1]; m[0][2]=n[0][2]; m[0][3]=n[0][3];
m[1][0]=n[1][0]; m[1][1]=n[1][1]; m[1][2]=n[1][2]; m[1][3]=n[1][3];
m[2][0]=n[2][0]; m[2][1]=n[2][1]; m[2][2]=n[2][2]; m[2][3]=n[2][3];
m[3][0]=n[3][0]; m[3][1]=n[3][1]; m[3][2]=n[3][2]; m[3][3]=n[3][3];
}

cMatrix4( const class cMatrix4 &a )
{
m[0][0]=a._11; m[0][1]=a._12; m[0][2]=a._13; m[0][3]=a._14;
m[1][0]=a._21; m[1][1]=a._22; m[1][2]=a._23; m[1][3]=a._24;
m[2][0]=a._31; m[2][1]=a._32; m[2][2]=a._33; m[2][3]=a._34;
m[3][0]=a._41; m[3][1]=a._42; m[3][2]=a._43; m[3][3]=a._44;
}

inline void Empty()
{
m[0][0]=1.f; m[0][1]=0.f; m[0][2]=0.f; m[0][3]=0.f;
m[1][0]=0.f; m[1][1]=1.f; m[1][2]=0.f; m[1][3]=0.f;
m[2][0]=0.f; m[2][1]=0.f; m[2][2]=1.f; m[2][3]=0.f;
m[3][0]=0.f; m[3][1]=0.f; m[3][2]=0.f; m[3][3]=1.f;
return;
}

cMatrix4()
{
Empty();
}

inline void Invert();

inline class cMatrix4 Inverted();

inline class cMatrix4 Rotation();

void CreateTranslationMatrix(float x, float y,float z);

void ObjectLookAt(const point3 &loc, const point3 &lookAt, const point3 &inUp );

void CameraLookAt(const point3 &loc, const point3 &lookAt, const point3 &inUp );

inline bool operator=(const class cMatrix4 & b);

} matrix4;

inline matrix4 operator-(const matrix4 & mat)
{
matrix4 a = mat;
a.Invert();
return a;
}


inline matrix4 operator*(const matrix4 &a, const matrix4 &b);

inline point3 operator*(const matrix4 &a, const point3 &b);

inline point4 operator*(const matrix4 &a, const point4 &b);



// Looks same as Point4, but you can throw vertex math rules out the window for this one

typedef class cQuaternion
{
public:
float w, x, y, z;
cQuaternion(float W, float X, float Y, float Z ) :
w(W), x(X), y(Y), z(Z)
{
}

inline void Empty()
{
w=1.f; x=y=z=0.f;
}

cQuaternion( )
{
Empty();
}

inline void Normalize();

inline class cQuaternion Normalized();

inline void NormalizeAxisAngle();

inline class cQuaternion NormalizedAxisAngle();

inline void Invert();

inline class cQuaternion Inverted();

inline matrix4 ConvertToMatrix();

inline void MatrixToQuaternion(const matrix4 &mat);

inline void EulerToQuaternion(float rx, float ry, float rz);

inline matrix4 ConvertAxisAngleToMatrix();

inline void ConvertToAxisAngle(); // Converts the values to fit Axis-Angle rotation w being the angle


inline void ConvertToQuaternion(); // Converts Axis-Angle rotation back to Quarterion


inline class cQuaternion Slerp(class cQuaternion * to, float t); // Spherical Linear intERPolation


} quaternion;

inline quaternion operator*(const quaternion &a, const quaternion &b);

inline quaternion operator+(const quaternion &a, const quaternion &b);

inline quaternion operator-(const quaternion &a);


typedef class cLine
{
public:
point3 org, dir;
float len;

cLine(point3 a, point3 b)
{
org=a;
dir=b-a;
len=dir.Mag();
dir.Normalize();
}

cLine(point3 start,point3 norm,float dist)
{
org=start;dir=norm;len=dist;
}

cLine() {}

} Line;


typedef class cPlane
{
public:
union
{
float p[4]; // For DX clipping planes;

struct
{
point3 n;
float d;
};
};

cPlane(const point3 &N, float D) :
d( D ), n( N )
{
}

cPlane(float nX, float nY, float nZ, float D)
{
n.x=nX; n.y=nY; n.z=nZ; d=D;
}

inline cPlane(const point3 &a, const point3 &b, const point3 &c);

inline cPlane(const point3 &N, const point3 &P) : // Create plane from normal and point on plane

n( N ), d( -(N*P))
{
}

inline cPlane() {}

inline void Create(const point3 &a, const point3 &b, const point3 &c);

inline pLoc Test(const point3 &point);

inline pLoc TestPolygon(const class cPolygon &poly);

inline float TestLine(const Line &ln, float *dist) //returns the distance, dist is the starting point distance from the plane

{
*dist=Func(ln.org); //The same side the origin is on

return (d - ln.org*n)/(ln.dir*n);
}

inline float Func(const point3 &p);

inline bool Compare(const class cPlane &pl, const float deps, const float peps); //distance and point epsilon; peps is from 0.0 to 2.0


} plane;

#endif


[edited by - Velochy on September 5, 2002 5:34:21 AM]

Share this post


Link to post
Share on other sites
inline functions need to be defined in the .h file if they''re used in other modules. inline implies static, meaning those symbols aren''t exported from the translation unit. Move the inline definitions into the .h file, and it looks like it''s only inline functions in your .cpp file so you can kill it.

Share this post


Link to post
Share on other sites
okay... i have posted this 4 times and gotten nothing but rubbish until that last statement. WHY DIDNT ANYONE TELL ME THAT SOONER??????????

Never mind.. thank you all, especially Stoffel, and i believe i have the problem under control now

Share this post


Link to post
Share on other sites
quote:
Original post by Velochy
okay... i have posted this 4 times and gotten nothing but rubbish until that last statement. WHY DIDNT ANYONE TELL ME THAT SOONER??????????

Never mind.. thank you all, especially Stoffel, and i believe i have the problem under control now

Glad your problem got under control. Sometimes, it is good to have inline function body defined in the class itself so that all *these* won''t happen :

class Abc
{
public:
void SomeFunc()
{
// this is inlined
}
};

Share this post


Link to post
Share on other sites