Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Small Vector3 class with plenty of features

Author
Message
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 5th Dec 2008 00:03 Edited at: 5th Dec 2008 22:07
Simple and easy to use Vector3 class, by Zuka
Tested, it does work!

Please report any errors you discover to me.

Features include:
Quote: "
- Addition,
- Subtraction,
- Scalar multiplication,
- Multiplication,
- Division,
- Scalar division,
- Unit,
- Dot product,
- Cross product,
- Full Intellisense support.
"


Note that if you do #define Vector3_DEBUG (before #include "Vector3.h"), you will be able to use OutputVector3(Vector3) to print the x,y,z values of the Vector3 using std::cout.

Vector3.h


Vector3.cpp


I don't really care what you do with it as long as you leave my name on it.

I'm currently using it in my new particle system. I really don't like the GDK's, it doesn't really suit my purposes well, and it doesn't collide with 3D objects, does it?

I'll then, later, build a full-scale physics engine off of it. Full Newtonian physics, with point gravity sources and ragdolls and everything. I think I might even use Hugo Elias's inverse-kinematics article, so I can make the ragdolls walk on their own.
Bachmann
15
Years of Service
User Offline
Joined: 5th Dec 2008
Location:
Posted: 5th Dec 2008 07:29
Hey,

that's looking pretty good. How about you make it a template so you can specify different types of vectors (integers, floats, etc..)?

Also, it's always great to have a function that returns the vector length squared. Saves valuable cpu time!

Just some thougths..

Bachmann
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Dec 2008 14:50
DirectX already has vector and matrix types defined. Take a look at your d3dx9math.h and d3dx9math.inl files.

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 5th Dec 2008 22:03
I don't really like those a whole lot. I prefer to use my own coding style because I'm familiar with it.
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 6th Dec 2008 03:32
I agree with Zuka, I like my own, so I wrote my own.

Login to post a reply

Server time is: 2024-09-30 11:35:39
Your offset time is: 2024-09-30 11:35:39