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.

DarkBASIC Professional Discussion / Add Subtract Vector3 working?

Author
Message
Zero G Scott
18
Years of Service
User Offline
Joined: 14th Dec 2007
Location: California, USA, Earth, Sol Sys
Posted: 24th May 2014 22:34 Edited at: 24th May 2014 22:37
Is Add Vector3 working correctly? Shouldn't the length of Vector c be 1? Am I not understanding something here? Subtract Vector3 seams to have the same problem. Anyone else get a 1 result for the length of Vector c? I'm using DBPro version U77. Just a tad confused here, any help would be appreciated. Matrox1 Addon required, I just realized.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th May 2014 00:22
Quote: "Am I not understanding something here?"


Yes. These lines all return the same vector ID so you only have one vector.



Since you haven't created any vectors the free vector id won't change. If you'd printed out the vector id's you'd have spotted the problem immediately.

You might also like to check these lines (unrelated to present issue I guess):





Powered by Free Banners
Zero G Scott
18
Years of Service
User Offline
Joined: 14th Dec 2007
Location: California, USA, Earth, Sol Sys
Posted: 25th May 2014 00:43
Thank you GG! That second issue is only slightly less embarrassing then the first considering its a PROCEDURAL based programming language. Guess I gotta meet my derp derp post quota still for the month! Thanks again for spending your time on this though. Appreciate it!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th May 2014 01:44
No problem. We all do it from time to time.



Powered by Free Banners
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th May 2014 18:49
@Zero G Scott,
If you take a further look at the help files, you'll find a function named FIND FREE VECTOR - that actually does removed the returned vector id from the list of free vectors, and allows you to continue arranging your code as per your original post.

A better alternative is to use the NEW VECTOR3 function to allocate an id and create the vector3 in one step.

Zero G Scott
18
Years of Service
User Offline
Joined: 14th Dec 2007
Location: California, USA, Earth, Sol Sys
Posted: 26th May 2014 22:36
Thank you IanM, that's incredibly helpful. I do go through the help file a lot to see whats available while working on my code, in this case I was so preoccupied with using vectors for the first time that I overlooked some setup procedures. Good to know there's alternatives though to help not fall into that trap again. Though I'm pretty sure I won't forget now.

Also on the subject of vectors is there a truncate command somewhere perchance? Just some way to limit a vectors to a specific length. I've seen a few examples in general steering tutorials that truncate a vector and was just curious if its just too trivial to bother with setting up a command. Maybe a way to normalize to a specific length or something. Just curious is all. Normalize then scale it to the limit would do it but I would have to add a check to be sure the vector is at the max length already. Petty stuff really.

Thanks for the tip IanM!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th May 2014 23:42
@IanM

I don't understand your post.

The original post already uses the function find free vector() and that does not update the vector IDs as a simple test shows - you need to create the vector after finding each free id.

It's easy to check that by printing out the returned IDs.



Powered by Free Banners
Zero G Scott
18
Years of Service
User Offline
Joined: 14th Dec 2007
Location: California, USA, Earth, Sol Sys
Posted: 26th May 2014 23:59
Sounds like he meant RESERVE FREE VECTOR, according to the help file that would do what he's explaining.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th May 2014 01:35
It certainly does - IanM usually knows what he's talking about even when he gets it wrong.

Sounds like just what you want.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-06 11:06:26
Your offset time is: 2026-07-06 11:06:26