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 / A command like Point Object, but with Up Vector.

Author
Message
ReElectro
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location:
Posted: 23rd Apr 2012 08:18
Hay, is there such thing as command where you point an object not only at a specific XYZ location, but also the UP's XYZ location as well... sort of like a LookAt for 3d Objects.

It would of made my life a little easier if there was such thing.

There was a thread about this a long time ago but it had little replies.
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 23rd Apr 2012 09:48
I think my eXtendet Rotation plugin can help you . There is a command called XROT ROTATE TO result_mat, object_mat, target_vec, angle, axis

Here is the description off this command:
XROT ROTATE TO(xrotMatResult, xrotMatObject, xrotVector, Angle#, Axis)
XROT ROTATE TO xrotMatResult, xrotMatObject, xrotVector, Angle#, Axis

Rotate a matrix (xrotMatObject) to a Point in Space (xrotVector) by Angle# degrees. Axis discribes the Axis wich pointing to the coordinate. Valid Values are 1=Right (X-Axis), 2=Up (Y-Axis), 3=Front (Z-Axis). The result is stored in xrotMatResult. The function with braces returns the variable xrotMatResult.

If you wish a complete rotation to your target at once, then you must leave the param Angle# with 180.0 degree.

I hope this can help you.

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
ReElectro
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location:
Posted: 23rd Apr 2012 19:00
I've tried your plugin previously and I ended up getting an Application Error message dialog box, something that was different than the error in the DB Code. So that was the reason why I posted here.

The version I use is probably the latest release candidate version of 77.
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 23rd Apr 2012 20:48
I need more information.
What message have you get?
May be a code snippet?

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 23rd Apr 2012 22:39
I don't understand the opening post, but there is a point camera command, if that's what you mean.

ReElectro
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location:
Posted: 23rd Apr 2012 23:28
I already know about point camera.

Just that a modified version to add the UP X, Y ,Z parameter is what I'm looking for. Sort of like a LookAt for a matrix but with an object.

Ok, so I run the program and I get a "Visual Studio Just-In-Time Debugger" dialog box with a message saying "An unhandled win32 exception has occurred in Application.exe [3072]" with a list of possible debuggers below.

Here's the pieces of the code, it sort of took me a while to come up with.

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 24th Apr 2012 09:18 Edited at: 24th Apr 2012 10:48
Ok, i understand.

First, eXtendet Rotation chose another way to handle id's. You can't use static id's. Every function gives a id back when no one is given. The id's what you get are only C/C++ - Pointers as unsigned integer.

Second, don't mix DBPro-Commands with Extendet Roation-Commands.

here is the one-to-one translation of your code.


With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 25th Apr 2012 10:13 Edited at: 25th Apr 2012 11:14
vector 3 = x, y, z
vl = lenght vector 3 (vector)
normalized x = x/vl
normalized y = y/vl
normalized z = z/vl
lookat_X=(180*x+180*z)
lookat_Y=(180*y+180*z)
lookat_Z=(180*x+180*y)
rotate object (x,y,z)


edit: z is vertical rotation axis as in 3ds max, so in DB it will be like (x,z,y)
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Apr 2012 10:34
I think that's not what ReElectro want. I mean he wants a rotation around the current up vector. Corrected me if I'm wrong.

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 25th Apr 2012 11:06 Edited at: 25th Apr 2012 11:06
what is an up vector?
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Apr 2012 11:28
The look-vector (front-vector) is in direction of the Z-Axis. Without rotation: vector(0, 0, 1).

The up-vector is in direction of the Y-Axis. Without rotation: vector(0, 1, 0).

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Apr 2012 13:40 Edited at: 25th Apr 2012 13:42
All you do is point Camera at an hidden object, and move the object Up, and Down. No need for all this complex maths.

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Apr 2012 14:10
So far i know the camera will not point the object over the transformed y-axis. And what is when he want point an object to object?
I think further that the work with hidden objects claimed more performance than the direct calculation. (for example a cube has 8 points every point take a completely transform process. Whether visible or not).

slay me if this is not true.

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Apr 2012 14:25
You put an invisible object inside what you are pointing at, then move the invisible object UP, and point at that. There is no performance loss with an invisible cube.

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Apr 2012 15:23
That what you do is a rotation (pointing) over the X-Axis (left/right-vector). I know, you can put your invisible object sideways. But roll your camera for example 45 degrees and than point your object than the rotation of the camera is no longer over the local y-axis.

And with the performance, show this example. For Comparsion uncomment the for next loop.



With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Apr 2012 15:39 Edited at: 25th Apr 2012 15:49
You only need 1 cube. You move it. If you rotate the camera, and rotate the cube the Y axis is the same as the camera, and if you don't rotate the cube you still have the original y axis. It was fast in DB Classic so it will be very fast in DBPro.

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 25th Apr 2012 17:07 Edited at: 25th Apr 2012 17:19




if it is not what you are asking for, then aaargh...
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 25th Apr 2012 17:07
Hi guys, what actually is this is for? Meaning in a game if I was to imagine it in action what would be happening?

It's like me saying I want an object to point toward the camera but rotate and move around it's direction vector or in other words Axis Aligned Billboarding. Believe me, far easier to say than create without being able to imagine it.

When it comes to rotation, dump Eular cause Quaternion is your real friend.


Join or Support!
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Apr 2012 21:23
@mrHandy:
This is almost correct. Now turn the cone around the z-axis by about 45 degree and just pointing around the y-axis.

@Pincho Paxton:
I am open to conviction.
can you achieve with your method the same thing as mrHandy and my changes or what makes my code?
Below is a download for the executable


With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Apr 2012 22:43 Edited at: 25th Apr 2012 22:59
I don't know, I can't understand it. I haven't been able to follow this thread very well. But when someone posted LookAt then that is point camera, and when someone posted UP. then that is point camera at a box moving up. But that was why I said just move a box object, it is easier. But watching your spinning box, it isn't pointing at anything, so I have no idea what you are all trying to do.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 25th Apr 2012 23:23 Edited at: 25th Apr 2012 23:23
Quote: "so I have no idea what you are all trying to do."


I would like to know as well


Join or Support!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Apr 2012 23:30
So would I. I'm totally baffled.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 25th Apr 2012 23:45
he wants this but for an object


The object needs to be pointed at "look at point" and be rotated around z axis. THe rotations needs to be set up with a "up vector"

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Apr 2012 00:14
That's what baffles me. For given object and camera positions the "up" direction has to be confined to a plane orthogonal to the line of sight. For example, if the camera is pointing downwards then the camera's "up" direction cannot be vertically up.
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 26th Apr 2012 01:01
Quote: "For example, if the camera is pointing downwards then the camera's "up" direction cannot be vertically up. "

exactly, the transformd local up-vector is then vector(0, 0, 1). Provided the camera/objectis not rotated over the local z-axis.

For example, a tank aligned on the ground of a uneven terrain have never the local up-vector (0,1,0). now you want to head a waypoint. you can`t head the way point directly, because you will drive in the terain. So you can only heading over the local y-axis.

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Apr 2012 01:21
Still don't really know what the problem is exactly.
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 26th Apr 2012 01:32
I've no problem. i've only say that the method what pincho paxton describe not work.

And i hope that is what the thread owner want. A rotation to head a arbitrary point over the local y-axis.

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Apr 2012 01:37 Edited at: 26th Apr 2012 01:39
It still sounds like you move a hidden box, and head towards it. Which means that my idea is very easy to do. You have point camera, and you have point object to object. So combined that is going to give you a new line to travel towards.

Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 26th Apr 2012 01:53
The look at function looks like this (java code):

where x0,y0,z1 are camera positions
x1,y1,z1 are look at point coordinates
Vx,Vy,Vz are components of the look up vector
m_view is the matrix that holds the rotation data of the camera
At the end all you have to do is convert this matrix to euler angles and rotate the object
(of course you'll need to convert the above code to dbpro)

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 26th Apr 2012 04:11
Brendy boy, would you say it's the same as Axis Aligned Billboards then? Cause I'm still lost on what the owner actually wants.


Join or Support!
ReElectro
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location:
Posted: 26th Apr 2012 08:58
I was actually surprised to see that there was a lot of replies to this thread.

What I ultimately wanted was to set the object's rotation that's specified by the at vector, and the up vector because the object already represents the eye vector.

As I said, it's like the "POINT OBJECT" command with an XYZ, but with an addition of the up vector that determines how much the object rolls. If the up vector is center left to the object(like 30,0,0), then the object rolls just about 90 degrees.

I could also look in to converting a built lookat matrix(with already specified vertices) into the object's actual rotation where it not only points, but also rolls at a specified XYZ location.

The reason why I am asking this? Is for rotation interpolation.
I thought using the eye, up and at vectors would be a good idea to do this mainly because it doesn't contain any jitterness compared to using eulers.
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 26th Apr 2012 09:08 Edited at: 26th Apr 2012 09:19
This one???


After all, my second post!?!

Or if you wish pointing your Object how Pincho paxton describe and than pitch your object 90 degrees.

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 26th Apr 2012 09:26 Edited at: 26th Apr 2012 09:39
See attachment

If it's wrong again, then I call this thread a troll-thread

edit : updated attachment for teh great justice.
edit2 : "ball target" is now "plain target"

p.s. who can tell me, why my .x's lighting looks so ugly? I've tried all "set object ..." settings.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Apr 2012 14:12 Edited at: 26th Apr 2012 14:30
Quote: "As I said, it's like the "POINT OBJECT" command with an XYZ, but with an addition of the up vector that determines how much the object rolls. If the up vector is center left to the object(like 30,0,0), then the object rolls just about 90 degrees."


But point object already rotates the object....



And if you make an invisible cube like I said then you can have a roll to an invisible target above the original target.



mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 26th Apr 2012 16:01
GUYS!!! I figured out what ReElectro wants!

Remember Speed tree technology? When all planes on tree pointed at camera PLUS they're rolling left'n'right like by wind!

I think it's an interesting and useful.
Any snippets?..
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Apr 2012 16:06 Edited at: 26th Apr 2012 16:09
It's the same, just left/right cube. Whatever the circumstance it will be cube to point at. You can do banking, wind, LookAt, Freeflight, Vertical Takeoff. All the same way.

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 26th Apr 2012 16:11
Yes, it's the same as my code, just a lil simplier.

But you have 2 working axes, and we need all 3 INDEPENDENTLY.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Apr 2012 16:26 Edited at: 26th Apr 2012 16:27
Roll is the final vector. I don't see why roll would need to point at anything. If an aircraft turns to chase another plane it watches the plane, but the wings do not watch the ground. So you just use roll. So are you sure that the OP wants two point objects at the same time?

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 26th Apr 2012 23:16 Edited at: 26th Apr 2012 23:18
Erm, roll don't want to work with rotating. Just add roll to my demo and you'll see mess.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th Apr 2012 00:02
This works... use left/right keys....



mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 27th Apr 2012 09:20 Edited at: 27th Apr 2012 09:22
DBP has a point object command?! Iam an idiot...
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 27th Apr 2012 14:29
This thing is getting annoying now. Just tell me is it either one of these then I'll code it. Btw, none of them can be done with point object.

1. Axis Aligned billboard: A billboard that rotates about an axis (x, y, z). The up vector for the billboard is along that axis.

2. Axis billboard: A billboard that is aligned along an arbitrary axis, this can include axis aligned billboards. The up vector for the billboard is along the arbitrary axis.

More info: The axis-aligned (AA) billboards always have one local axis that is aligned with a global axis, and they are rotated about that axis to face the user. The arbitrary axis billboards are rotated about any axis to face the user.


Join or Support!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th Apr 2012 14:35 Edited at: 27th Apr 2012 15:03
Quote: "Btw, none of them can be done with point object."


You can point the trees at a location level with their plane. So it is still the same code as I posted. Say you use the camera position for X/Z, but use the tree position for Y, it's the same code.

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 27th Apr 2012 14:53 Edited at: 27th Apr 2012 14:54
That's what we need to do: 100% correct billboard in perspective.

Just bend the billboard to viewvector length!

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th Apr 2012 15:05 Edited at: 27th Apr 2012 15:07
Like I said, it's the same code just different X/Y/Z positions for point object. Camera X/Z... Tree Y. But nobody mentioned trees in the OP, so I think all of these different explanations have nothing to do with an eye looking up.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 27th Apr 2012 15:24 Edited at: 27th Apr 2012 15:25
Axis Aligned Billboards:



Join or Support!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th Apr 2012 15:30 Edited at: 27th Apr 2012 15:38
Quote: "Axis Aligned Billboards:"


Surely...

point object tree,camera position x(),object position y(tree),Camera position z()

... is Ok.

If it's slightly too far back, you can still put an invisible box in front of the camera.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 27th Apr 2012 15:39 Edited at: 27th Apr 2012 15:43
No cause it limits the rotation of the object to one axis, exactly (0,1,0) up vector. With axis aligned billboards you could define the up vector to whatever you want.

Axis aligned billboards are mostly found in particles. Like lasers or beams, or particle that the direction changes but requires the billboard to face the camera.

I could probably simplify the code. Wrote it quick.


Join or Support!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th Apr 2012 15:46
So does my code. The Y axis is the tree axis.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 27th Apr 2012 15:56 Edited at: 27th Apr 2012 15:58
But your code doesn't allow for transformed up vector or axis, which I believe he asked for when talking about roll. In my code, change axis to this:



Also I don't know why your talking about trees when this has nothing to do with trees or tree billboards (point sprites).

The problem with this thread is ReElectro hasn't explained what he wants very well. He stated "I thought using the eye, up and at vectors would be a good idea to do this mainly because it doesn't contain any jitterness compared to using eulers." The question I pose is how would he know that. He would have to create it with eulars to know that. I would like to see that example then we'd know exactly what he wanted.


Join or Support!

Login to post a reply

Server time is: 2026-07-07 22:20:52
Your offset time is: 2026-07-07 22:20:52