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 / What is this vector3 thing?

Author
Message
CPPP
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 5th Dec 2008 14:06
Taking a look inside the "documentation" for GDK(Which is extremely sparse". Vector3 is something that is part of many functions, but nor real explanation of what it does is given. The one that try to tell something says this:

"dbMakeVector3
This command will create a VECTOR3 data item. Unlike the datatypes you are used to, these datatypes are stored internally and referenced by an index value. The VECTOR3 datatype contains three float values representing X, Y and Z. This datatype is typically used to store 3D world space coordinates.

Syntax
int dbMakeVector3 ( int Vector )"

Aha?
Isn't 3d world space coordinates used all the time for many objects (camera, player object etc)? What does this provide?
No examples of use.
IS there any kind of real documentation for GDK? It's to the point of being useless if it's like this!
FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 5th Dec 2008 14:59
Easy ,a vector3 in DarkGDK is like an internal array for storing 3 items. (XYZ)
CPPP
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 5th Dec 2008 15:20
And that says it all!

Seriously what can it be used for? No examples! Goggling it says nothing.
I could create an array for storing three items. Why is this "internal"(internal, why? for what?) array so special.
What is the magic with it being "internal" compared to me making an array like that?

No examples or talk about what it is good for in the extremely poor GDK help. Hell, even the good 'ol quick basic(back in the days) had small programing examples for every command.
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 5th Dec 2008 18:07
It is a data type that holds 3 floating point numbers.

To fully appreciate the significance of "these datatypes are stored internally and referenced by an index value. " one has to look at machine code programming, especially "index addressing".
It is a mode of accessing a memory location by having a pointer to the start of a block of memory, and provide an offset value to that start address, to get to the data that is required.

Basically it is a VERY FAST WAY to get to data that is stored in that type of data structure.

If you want very fast processing speed when dealing with world X,Y,Z values, then this type of data structure should be one of your first choices.

About the only faster type of storage that I can think of would be if you used the "register" storage class for your X,Y,Z variables, but most programmers do not have a good enough understanding of the internal register structure for the CPU that they are programming for, to be able to use the "register" storage class effectively.

It is all a matter of speed of execution.
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 5th Dec 2008 18:19
You could use an array but this command saves you the trouble of creating one.
More importantly, once you have created more than one vector you can use other db vector commands to add them together, multiply them and so on.
e.g every object in your game might have a vector3 to store its velocity, X velocity, Y velocity and Z velocity.
Lets say one object collides with another you can add one vector to the other and your object will come out with its own X velocity + the other X velocity and so on, so it does three calculations in one command.
CPPP
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 5th Dec 2008 19:59
Matty Helewood:
Thanks, that's really some helpful information about the usage of it!
Three calculations in one command sound like serious some speed advantages.

sydbod
What you are describing it as, sounds to me very much like creating a linked list, ie creating a class, where you have "nextpointers" (*next) inside the class that points to the next object in the list(and if it's doubly linked "prevpointers". And then create a starting pointer and an endpointer when that list is being created. After all every object in such a list is like a memblock, and the offset really is like the size of all the datatypes inside that class. Am I wrong here? And is this vector3 type done like that where it is like a class of such a linked list?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Dec 2008 21:18
Why is everyone talking about storage, and no-one talking about usage? Who cares how it's represented? It's more important to understand what it's used for.

A vector represents an offset from an origin. Given a vector and an appropriately generated matrix, you can get another vector from the first that has been rotated or offset in almost any way imaginable.

Now, the real magic is in the matrix, not the vector. Starting with an identity matrix, you can multiply it by one of many rotation matrices or translation matrices, and due to the magic of matrices , all of those operations can be carried out with a single operation on the vector simply by multiplying the two.

I don't have code converted to the GDK, but you can probably convert this DBPro code if you spend a little time:


The function uses matrix/vector maths to calculate the position of a single vertex of an object into its final world coordinate.

chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 5th Dec 2008 21:55
here it is converted to gdk with the wonderfull dba to c++ converter.

Although it crashes and i can`t see why.



nvidia geforce 8600gt + amd athlon 64
windows xp pro.

Login to post a reply

Server time is: 2024-11-25 07:25:11
Your offset time is: 2024-11-25 07:25:11