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 Discussion / Orienting an object toward another... why doesn't it work?

Author
Message
Video Boy
22
Years of Service
User Offline
Joined: 21st Mar 2004
Location:
Posted: 20th May 2006 14:34 Edited at: 20th May 2006 14:35
I wrote a function to orient an object (positioned under the camera) toward another, but it does not work.
In theory, it should calculate the horizontal and vertical angle between objects A and B, then rotate object A around its axes so that it points at object B. Instead, the object is rotated in seemingly random directions!
As a test, I added lines to MOVE the object according to the angle it is facing... and its movement is PERFECTLY RIGHT! It moves straight from the camera to object B, as it should! What am I doing wrong? Whuat do I need to change?

I wrote a program with this function and uploaded it to http://devilmaster.supereva.it/sentinel.zip (don't use download managers to download it). When you run it, you will see an object in front of the camera: this is what I call "the sentinel" in the code. You can move around the 3D space with your mouse and the arrows: when the camera is in front of the sentinel, the function activates and a cone appears. Note how the cone will always move from under the camera toward the sentinel. However, its orientation is wrong: its point should face the sentinel, but it does not! Why?
RUCCUS
21
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 20th May 2006 17:15
Just seeing the program isnt going to help us much, if you want an answer we're most likely going to need some code.

Not sure if you're recoding an already available command for practise, or just didnt know the command existed, but there's a POINT OBJECT command that will point any object towards a given coordinate.

Dont try to reinvent the wheel blah blah blah

- RUC'

Video Boy
22
Years of Service
User Offline
Joined: 21st Mar 2004
Location:
Posted: 20th May 2006 22:17
I did insert the code in the zip file!
Just unpack everything in the same directory.
Video Boy
22
Years of Service
User Offline
Joined: 21st Mar 2004
Location:
Posted: 21st May 2006 11:06 Edited at: 21st May 2006 11:07
P.S. I tried the Point Object command, but it doesn't work right either. You can see it by replacing the line:

ORIENT(CONENUMBER,NS)

with:

Point Object CONENUMBER,Object Position X(NS),Object Position Y(NS)+65.0,Object Position Z(NS)

I don't know if there's a problem with my code or with my model...
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 21st May 2006 17:30
Maybe your model is facing the wrong way. Models face the direction of the origin that is saved in the modelling package. You can usually just load the model into a modelling package and spin it around, and save it again.

SFSW
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 22nd May 2006 06:49
One thing to check:

- Make sure you use the command SET OBJECT ROTATION ZYX [num] for any object you want to use the POINT OBJECT command with. Otherwise, you're results will look strange when you try to match rotations or point one object at another. It's a good idea to use this command for every object you create, unless you need an exception.

Video Boy
22
Years of Service
User Offline
Joined: 21st Mar 2004
Location:
Posted: 18th Jun 2006 12:30 Edited at: 18th Jun 2006 14:04
Quote: "- Make sure you use the command SET OBJECT ROTATION ZYX [num] for any object you want to use the POINT OBJECT command with"

I tried that, and there is no difference.
Quote: "Maybe your model is facing the wrong way."

I thought that too, only... I can't figure out what the right way should be. I tried to rotate it in various ways, all to no avail.

Can anyone please look at that object and tell me what is wrong with it?
SFSW
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 26th Jun 2006 03:17
If you want to post it here, I'll take a look. There's definately a ways to get the orientation of the object the way you want through the use of commands like Fix Object Pivot and Set Camera Rotation.

Video Boy
22
Years of Service
User Offline
Joined: 21st Mar 2004
Location:
Posted: 5th Jul 2006 22:58
I put everything online at http://devilmaster.supereva.it/sentinel.zip.
SFSW
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 6th Jul 2006 08:54 Edited at: 6th Jul 2006 08:54
Ok, if I understand what it is you're trying to do (which I may not be here is the revised code. I've altered it to point the cone tip directly at the 'sentinel' during your 'firing' routine when the camera passes into the trigger zone. I did this by orienting the cone object so the point is the front, fixing the orientation, then changing your scaling routine to adapt to the new orientation. Is that what you needed?

Login to post a reply

Server time is: 2026-07-07 06:02:35
Your offset time is: 2026-07-07 06:02:35