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 / positioning and rotations of objects/points without media

Author
Message
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 2nd Oct 2013 16:35 Edited at: 2nd Oct 2013 16:38
Hey everybody,

My game can start in "dedicated mode" (Just a text console) to be able to host servers, without playing the game (and running any media).

I'm currently writing player movement. Normal clients with (a player hosted) server is working, but for 'dedicated mode' I need to replace the objects with pure data for all movement, position, angles and collision stuff.

I'm not a master in maths, so my question is if there is a way if I could replace the objects (make object/load object) with something else, pure code, without content/media but with the same abilities/properties regarding positioning and rotation...?

Lol, I hope I make sense here...

Any help is welcome!

Edit:
I have a feeling I'm probably asking something quite obvious... something I tend to miss

Regards Sph!nx
www.mental-image.net
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Oct 2013 17:11
Um... I look at entities as information about a point in space. That point has a position, angle and etc... then we give that point a physical body, mesh or object so we can actually see it. So in theory all you'd need to do is make an entity without giving it a object. All movement would just be added to the position and orientation. What's tricky is to do non-object collision where collision is handled full by calculations.

I think this is what you mean.

"Get in the Van!" - Van B
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 2nd Oct 2013 17:25 Edited at: 2nd Oct 2013 17:26
I got the calculation for collision covered.

Yes, I need such an entity/point you speak of, I use to in the past with other languages but since I work with DB I directly apply stuff to the object, like most do with DBP I guess. What kind of 'entity' could I use for that? Is there such a thing native in db as command, or would I need to create a "blanc" object, with a single limb/bone, without mesh or something?

Regards Sph!nx
www.mental-image.net
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Oct 2013 17:40 Edited at: 2nd Oct 2013 17:40
An entity if just information, so...

type Entity
Name
Position
Angle
...
endtype

And stored in arrays, ultimately you don't want to apply stuff directly to objects and move to properties manipulation to update objects.

"Get in the Van!" - Van B
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 2nd Oct 2013 18:14 Edited at: 2nd Oct 2013 18:14
Thanks mate,

I feel so embarrassed... I already have that setup... but data was coming from the object and added to the type... got it reversed now.

Quote: "I have a feeling I'm probably asking something quite obvious... something I tend to miss"



Regards Sph!nx
www.mental-image.net
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Oct 2013 18:17
Quote: ""I have a feeling I'm probably asking something quite obvious... something I tend to miss""


You think that's bad. Not too long ago I asked how do I scroll text? Talk about feeling stupid

"Get in the Van!" - Van B
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 2nd Oct 2013 18:45 Edited at: 2nd Oct 2013 19:08
Lol, missing things is human!

I did encounter a problem.

With an object I can change angle, move forward and get positions. How would I calculate a new position out of data, with angles in mind?

Example: I have these coordinates with these angles...


Now I wish to move the "object"/Entity 100 units 'forward' based on it's angles. How would I do that?

Edit:
Found something!

This will work, no?

Regards Sph!nx
www.mental-image.net
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Oct 2013 19:35 Edited at: 2nd Oct 2013 19:50
To move an object forward based on it's angle you'd scale it's Look vector.

The Look vector is the forward direction the object is facing, same for Up and Right Vectors which are the up and right directions.

Here's how you'd work out these vectors: Google for more information


Then you scale a position to move something, for example moving forward:


Example of this by moving an object in front of another:


By combining all three it works exactly the same as offset limb.

Edit: Better example of moving:


"Get in the Van!" - Van B
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Oct 2013 20:34 Edited at: 2nd Oct 2013 20:35

Hows this...

Or simply..



Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Oct 2013 21:03
@Mobiius - He can't use objects and using NewXYZValue would be difficult to account for every angle XYZ, hence why using a look vector is better.

Move Object = Scale Look Vector

"Get in the Van!" - Van B
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 2nd Oct 2013 22:09
Thanks for the input guys!

Well, I've got this currently working:


Does what I want it to do.

@ Sasuke
Wow, thanks for the examples! Will give those a go and see what's the difference.

Regards Sph!nx
www.mental-image.net
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Oct 2013 22:41
Booyaa! lol

Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 3rd Oct 2013 14:33
Well, I am very grateful for the calculations Sasuke provided. Thanks again!

Basically, if I understand the docs right, the newxvalue() command does those calculation for me. Still, having these calculation are important to since I'm no maths genius, but still like to understand.

Regards Sph!nx
www.mental-image.net
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Oct 2013 15:31
Quote: "Well, I am very grateful for the calculations Sasuke provided. Thanks again!"


No problem. Admittedly when you said move forward and you gave those angles I thought you meant move forward in the direction your pointing which newXYZvalue would be difficult to use. But moving on say the Y plane (so moving along a flat surface no matter where your pointing at) then their perfect for that.

"Get in the Van!" - Van B
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 3rd Oct 2013 17:39
I use all three:


I update those every loop and they work great in all directions. Whenever the angles of the player change, so does the direction of the movement. I can influence the speed by increasing/decreasing it's step and perform strafe by (temporarily) altering the desired angles.

Wrapping up the networking part and it will work for multiplayer. Then I can continue on the 'block/voxel' engine. Collision will then later be decided by the server, who simply checks for positions and sizes.

Regards Sph!nx
www.mental-image.net
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Oct 2013 18:07
I don't think you understand what I mean. Best way to show you:

Press shift to change between mine and your methods
Press space to reset everything
Press return key to move forward



In this example it shows the difference in moving forward. The green box is where the player object should move to if it's correctly moving forward. As you can see, using newXYZvalue doesn't work. The reason for this is newX/Y or Zvalues don't take into account the other axises.

"Get in the Van!" - Van B
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 3rd Oct 2013 18:56 Edited at: 3rd Oct 2013 19:09
Your efforts are greatly appreciated and I'm sorry for my ignorance, but I don't get it.

I've compiled the code, and both methods have exactly the same results. No matter what direction the cube is facing, the red cube is on the side of the white cube, that is facing the green cube (thus facing the right way, correct?). Both are the same for me.


Edit:
Now I see. You are right! I have did this myself like this:
Part of my (preliminary) player code:


The angles are based on mouse input. Even-tough your example shows what you mean, in my own app, I have it completely working. As you can see, I had to switch the x and y when I set angles for the object and camera. Dunno why, in the actual positioning (newxvalue()) it works normal. It really does work good so far.

Regards Sph!nx
www.mental-image.net
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Oct 2013 20:28
Yeah, your method only works for moving along the y plain. But if you wanted to move forward at any angle then you wouldn't beable to using newXYZvalue. That's the point I was making... I think... kind of forget! Oh well, glad everything is working.

"Get in the Van!" - Van B
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 3rd Oct 2013 20:49 Edited at: 3rd Oct 2013 23:21
Indeed, thanks a lot!

EDIT:
After more testing with different clients I did notice faults in my setup. I've used your calculations. Thanks again!!

Regards Sph!nx
www.mental-image.net
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 5th Oct 2013 00:16
Thinking about it. What type of movement you looking for so we can tailor the code to your specifics eliminating unnecessary calculations?

"Get in the Van!" - Van B
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 5th Oct 2013 14:46
You are awesome but I got it all covered!

It was exactly what I needed but I had to put the roll value to 0 to prevent certain angles the player should not perform.

It works 100% and all due to this thread. If you ever need help with something, send me mail or something!

Regards Sph!nx
www.mental-image.net

Login to post a reply

Server time is: 2026-07-06 10:36:00
Your offset time is: 2026-07-06 10:36:00