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 / Rotate from current Orientation

Author
Message
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Jun 2013 19:41 Edited at: 1st Jun 2013 19:41
I am making the hidden paths for a race track. I have made the inside paths for lane 1. I figured that all of the other lanes can be rotated 90deg from the first lane. But the rotations are not working around the corners. The rotations remain fixed even though I am pointing the object towards the bend. Here is the code.



Here is the image showing that the rotation is still turning 90deg from its original rotation, and not its new rotation. Basically I want to point an object in a new direction around a bend, and then rotate it 90deg from its new angle. It's not working. The paths thin out around the bend...



James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Jun 2013 23:15 Edited at: 1st Jun 2013 23:16
How sure are you that objects "399 + n" are correctly orientated? We can`t see any work prior to input of the array data so it strikes me that perhaps somewhere in the code the "399 + n" objects are put back at 0,0,0 rotation after you retained the positional data for the array from them - or perhaps you only used one object to find the positions then placed "399 + n" objects accordingly without actually rotating them at all?
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 1st Jun 2013 23:41
@Pincho - I know the cubes in the screen shot are quite small to make anything from, but they do look like they are all at the same orientation. ie. not turning around the the track.

If you're going from one point to another then grabbing the orientation after a 'Point Object' may work. If you know what I mean. Or another way of getting the angle between two points.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Jun 2013 23:49 Edited at: 1st Jun 2013 23:51
They are all rotating around the bend. This is the code that points each object towards the next object...



Here is an image closer to the bend, and you can see the cubes rotating to match the grass on the bend. But the move command is still using the old rotation...



James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Jun 2013 00:15 Edited at: 2nd Jun 2013 00:16
Have you any need to fix their pivot point(399 + n objects)? To me it looks like fixing their pivot keeps their current orientation while it also resets their current rotational values as 0,0,0, try remming that line out -> "fix object pivot 399 + n" hence why the other objects retain 0,0,0 when orientated to match them
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 00:27 Edited at: 2nd Jun 2013 00:35
I added that line because it didn't work. It was an attempt at a fix. It doesn't work with it, or without it.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Jun 2013 01:18
Hi there.
We can not point an object to another and fix object pivot...what we have to do, is point our object to another, to get its actual angle and just:


yrotate object 1,object angle y(1):fix object pivot 1

so, if we have 169 objects and we want fix their y angle...could be something like:

for n= 1 to 169
yrotate object n,object angle y(n):fix object pivot n
next n


I hope that help

Cheers.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 01:20 Edited at: 2nd Jun 2013 01:24
OK thanks,I'll try it out.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 01:43 Edited at: 2nd Jun 2013 01:44
I put this line in, and it nearly works. They rotate properly, but now I have a strange problem...
yrotate object counter2,wrapvalue(object angle y(399+n) + 90)



Now I get missing paths...



chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Jun 2013 01:52
I'm not sure where the problem is, as I don't know exactly the method you are using to place the waypoints

I'm not a grumpy grandpa
James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Jun 2013 02:04
@pincho consider how long you have waited for responses here and how we seem to be going around in circles so to speak, what would be best at this stage would be for you to provide a nice medialess snippet that shows just the cubes in their positions and rotations(either upload your array or provide the code that creates the array also), along with simple camera movement. In short it will be quicker for folk here to identify where things go wrong and why if we can compile code that replicates the issues. I believe what your attempting to achieve is quite simple, for my own preference I would have used a single dummy object to do the whole thing.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 02:06
I place the first lane of 170 cubes.

I point each cube towards the next cube which turns them around the bends.

Then for lanes 2 to 7 I position new cubes on top of the ones in lane 1.

Then I rotate the new cubes 90deg + the point object angle.

Then I move the cubes by distance 1.

That turns them around the bends, and creates new lanes.



But I don't see how any could be missing?

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 02:12
Quote: "what would be best at this stage would be for you to provide a nice medialess snippet that shows just the cubes in their positions and rotations(either upload your array or provide the code that creates the array also), along with simple camera movement. In short it will be quicker for folk here to identify where things go wrong and why if we can compile code that replicates the issues. I believe what your attempting to achieve is quite simple, for my own preference I would have used a single dummy object to do the whole thing. "


I'm not that good at programming. It would probably take me hours to figure out how to make a midialess demo.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Jun 2013 02:21
Quote: "I'm not that good at programming. It would probably take me hours to figure out how to make a midialess demo."


As our friend James H says, you could gives just an example with just the first line of waypoints just to figure out how to make clones of the main path...I'm not a good programmer at all, but that is not the point...perhaps we could help you somehow if we have more information.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 02:30
OK I have made a demo... Try this out DOWNLOAD

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Jun 2013 02:49
Thanks for your demo...I will test it as soon as I can and I will give you an answer.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 03:04
OK thanks!

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Jun 2013 03:22
@Pincho

I made some code a while ago that demonstrated a method of making a spring out of cubes. The cubes are rotated to "point at" the next node based on their position in the spring. I think the principal can be applied to lining up and rotating your cubes as the cubes in the spring follow a curved path. Your track wouldn't be as uniform as a spring, but the idea should be able to be applied (it's DBC code - but should still apply):



Enjoy your day.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 03:51
It's very similar. If I switch turn object right for rotate object y it is the same apart from I need to fix the object pivot. I get the missing blocks still.

You have a lot of other code that uses maths. I point my objects at each other to avoid any maths. I'm a bit of a cheat.

James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Jun 2013 03:51 Edited at: 2nd Jun 2013 04:00
ok took a quick look, and based on what you expect to see you aren`t doing anything wrong persay, has everything to do with how dbp works behind the scenes where angles are concerned, I normally would turn to EZ rotate plugin at this stage, however there is a cheap workaround without it - cloning. (If you dont have EZ rotate it I think theres a free version somewhere,I THINK). There are some odd positions in your array however, to prove this I color the clones seperate to the source objects;

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 04:04
That's exactly right thanks!!! Yeah my paths are a bit strange in places. I used a model with limbs to make the first set of paths, and that was stored in the array. The model might have been a bit out. It have written some code to smooth out tweens with an editor. But it doesn't matter all that much, because the dogs use smooth turns towards the paths, and so will smooth out the bad path locations. By the time a dog reaches the bad location it will have passed that path without having time to completely turn towards it.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Jun 2013 12:30 Edited at: 2nd Jun 2013 12:48
Hi there
@Pincho Paxton
I nearly got it working...it needs more adjustments...I just change a positive value to negative. We still have something wrong with curves but close to the floor looks better.

yrotate object counter2,wrapvalue(object angle y(399+n) -90)




RE-EDITED
While watching carefully your code, I noticed that the problem starts at the first line of waypoints, where you place the first path...it looks like you made the road with small bends even on the straights, as some of the waypoint of this first line, point as I commented .

Cheers.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jun 2013 16:09 Edited at: 2nd Jun 2013 16:36
-90 puts the waypoints on the grass. It's not a bad fix if I were to start from the outside lane with a new array.

Thanks for the help anyway. I would have probably started from the outside if I didn't have another fix that uses cloned objects.

Login to post a reply

Server time is: 2026-07-07 07:36:13
Your offset time is: 2026-07-07 07:36:13