Pages:
1
2 |
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Complicated mode 8 question...
Hi all you gals n pals :D
So I've been getting a little carried away in mode 8... again.
I initially programmed something called "Basic Mode 8 Viewer" which was essentially just a way to walk around a mode 8 world with standard modern day
FPS sort of functions - mouse look, run, walk, jump and crouch, as well as footstep sound effects and automatically stepping up and down steps.
However, since then, it's grown a little bit - I'm now making a full suite of processes to flesh out a mode 8 world. Invisible walls, automatically
opening doors, wall switches that can be tied to other processes, lifts, raising and lowering bars, horizontally sliding doors and even an extending
bridge to get you across a large gap between two sectors. (They're all tied to processes, so provided you have the information you need - for example,
which sectors will be used to trigger an automatic door, which sector will be the door, and how far the door should go up - then you can just call the
process and it'll sit in the background, managing that one door. ) Through all
these, I'm now rather confident with Set_point_m8.
However, there's one thing which I'd really like to do, but I have NO idea how to go about doing it, and it's not because of set_point_m8. Basically,
I want to see if I can be able to make a swinging open door, using set_point_m8, in mode 8. I really just have... no idea where to begin.
I included a diagram to show you what I mean - I know that only three of the four points of the sector would have to move, but that's literally all I
know. I don't have even the slightest idea how I'd calculate the arc and all that, or how I'd somehow plot it in DivDX - not exactly a maths person
here :p
If anyone could help out with some advice, that'd be fantastic! I'd really like to add this feature in, in the future I may give out all these as code
snippets in the subforum so anyone can make their own awesome mode 8 worlds :D
- BC
[Edited on 21-11-2016 by BreadCaster]
~*~ Princess of Pies and Pastries ~*~
|
|
Peter
Loyalty card holder
Posts: 14
Registered: 18-8-2016
Member Is Offline
|
|
Have you thought about using sliding doors instead of revolving doors?
If you use revolving doors, you have to take into account the space that is needed for the player if he/she is standing on the other side of the door.
I'm referring to the blue area in the first picture. (That's assuming the door only rotates one way, and not both ways. (see the diagram for this)
If you decide on using sliding doors, then you have two options (see diagram, second & third picture)
picture 2) a door that consists of one piece that slides back and forth (think Star Trek)
OR
picture 3) a door that consists of two pieces that slide back and forth.... away from & to each other.
However if you really really really want to use revolving doors, I may have some code lying around. I'll do my best to track it down, it may take some
time though . Ok?
What do you call a bull that sleeps?
A Bull-dozer!
|
|
Peter
Loyalty card holder
Posts: 14
Registered: 18-8-2016
Member Is Offline
|
|
Yo,
Just had an idea...
Can't you just...
1) place a pivot at the base of the door and
2) parent the points of the doors to that process (using father... son... )
This way you only have to rotate the pivot and not the door.
I'll keep looking btw.
What do you call a bull that sleeps?
A Bull-dozer!
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Quote: Originally posted by Peter | Yo,
Just had an idea...
Can't you just...
1) place a pivot at the base of the door and
2) parent the points of the doors to that process (using father... son... )
This way you only have to rotate the pivot and not the door.
I'll keep looking btw. |
Thank you PEader!! Yeah I'd like that very much - provided you can explain how it basically works so I'm not just fumbling around with it haha
I don't understand what you mean about a "pivot" - do you mean a rectangular process and somehow tracking three control points in it? :S
By the way, I already have sliding doors in the program! :D You can either use two or one in conjunction to have a single sliding door or two sliding
doors like in Star Trek
~*~ Princess of Pies and Pastries ~*~
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
Hi BreadCaster,
What you need it is a formula to rotate and translare the vertices to form an opening/closing arc.
Have you tried to look at the examples of GET_DISTX and SET_POINT_M8 functions ? are very similar to each other, especially the first, if you look
carefully, moving with the LEFT and RIGHT keys, the triangle turns forming arches in the background circle, and uses her as a pivot point for turning
(control point 0), you should apply a similar formula for each vertex of the door to be moved using the SET_POINT_M8 function, try to do some
experiments.
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Quote: Originally posted by CicTec | Hi BreadCaster,
What you need it is a formula to rotate and translare the vertices to form an opening/closing arc.
Have you tried to look at the examples of GET_DISTX and SET_POINT_M8 functions ? are very similar to each other, especially the first, if you look
carefully, moving with the LEFT and RIGHT keys, the triangle turns forming arches in the background circle, and uses her as a pivot point for turning
(control point 0), you should apply a similar formula for each vertex of the door to be moved using the SET_POINT_M8 function, try to do some
experiments. |
Hah, actually I DO remember those now... wow, it's been a long time, thanks for the reccomendation Cictec I'll have a look!!!
~*~ Princess of Pies and Pastries ~*~
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
it is a pleasure, keep us informed of the test results etc..
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Hmm, I can't seem to get it working. What I'd been trying to do is get all the vertexes cordinates and put them into vert_x[0..3] and vert_y[0..3]
then use set_m8_point and get_dist_x(dooropenangle, distance between two vertexes)
but all I keep getting is crashes and really long warped sectors. Guh! I can't seem to translate the get_distx example into something that changes all
four vertexes of a sector...
~*~ Princess of Pies and Pastries ~*~
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
You have a small example to be able to try? it would be useful to see if the formula that you want to apply it correctly, or need to add some features
to engine to get this.
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
get_point_m8(vert_0, OFFSET vert_x[0], OFFSET vert_y[0]);
get_point_m8(vert_1, OFFSET vert_x[1], OFFSET vert_y[1]);
get_point_m8(vert_2, OFFSET vert_x[2], OFFSET vert_y[2]);
get_point_m8(vert_3, OFFSET vert_x[3], OFFSET vert_y[3]);
...
angle+=500;
pivot_x=vert_x[0]+get_distx(angle, open_speed);
pivot_y=vert_y[0]+get_disty(angle, open_speed);
set_point_m8(vert_0, vert_x[0], vert_y[0]);
set_point_m8(vert_1, vert_x[1]+pivot_x, vert_y[1]+pivot_y);
set_point_m8(vert_2, vert_x[2]+pivot_x, vert_y[2]+pivot_y);
set_point_m8(vert_3, vert_x[3]+pivot_x, vert_y[3]+pivot_y);
That's the current version, not working well. lol. Everything goes sort of black and weird like it's a huge sector, walking into it makes the game
crash. I can mess around with the variables and adding pivot_x and pivot_y to all of the vertices, but then I just get a sector that gently spins in
circles (not actually spinning, but moving in a circle, haha).
[Edited on 28-11-2016 by BreadCaster]
~*~ Princess of Pies and Pastries ~*~
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
it is difficult to test the code without an exmple, you have a small wld + assets + prg that you can send to verify the problems ?
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Okay sure, here you go! I just slapped this together for you.
Attachment: swingdoorexample.zip (1010kB) This file has been downloaded 2998 times
~*~ Princess of Pies and Pastries ~*~
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
Thanks, I shall examine it in the coming days to see possible solutions.
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Thanks Cictec. I've tried playing around with it more but to no avail, the closest I can get is the door sector kind of hinging open too far one way
and not enough the other way, kind of spinning in a circle again =(
~*~ Princess of Pies and Pastries ~*~
|
|
dom cook
Div Pro
Posts: 387
Registered: 4-3-2016
Member Is Offline
|
|
I've just had a quick look at your code and as far as I can tell you're not doing the maths, as it were.
I don't know if it's the only way but I would use 2d rotation transformations.
For that you need the relative x and y rest co-ordinates of the points you want to rotate with respect to the axis. (dx and dy)
Then you can calculate the new coordinates relative to the rotation angle like this.
x1=x0+dx*cos(angle)+dy*sin(angle)
y1=y0+dx*sin(angle)-dy*cos(angle)
sin and cos correspond to get_dist x() and get_dist y() or the m8 versions thereof.
Beware: if you use sin/cos you need to make a correction for the fact that it will give you the value*1000:
I'm sure this will work.
[Edited on 30-11-2016 by dom cook]
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Quote: Originally posted by dom cook | I've just had a quick look at your code and as far as I can tell you're not doing the maths, as it were.
I don't know if it's the only way but I would use 2d rotation transformations.
For that you need the relative x and y rest co-ordinates of the points you want to rotate with respect to the axis. (dx and dy)
Then you can calculate the new coordinates relative to the rotation angle like this.
x1=x0+dx*cos(angle)+dy*sin(angle)
y1=y0+dx*sin(angle)-dy*cos(angle)
sin and cos correspond to get_dist x() and get_dist y() or the m8 versions thereof.
Beware: if you use sin/cos you need to make a correction for the fact that it will give you the value*1000:
|
Bloody hell dom, thanks a lot! I actually haven't used sin and cos since secondary school, so as far as I know sin is what goes on on a particularly
good Saturday night out and COS is a high street clothing shop. :P
When you say will give the value * 1000, you mean I should simply stick a /1000 behind the formula (so it'd be
x1=x0+(dx*cos(angle)+dy*sin(angle))/1000 ) ?
[Edited on 30-11-2016 by BreadCaster]
~*~ Princess of Pies and Pastries ~*~
|
|
dom cook
Div Pro
Posts: 387
Registered: 4-3-2016
Member Is Offline
|
|
There you go Mister.
I've stripped down what you had and have made a struct to hold the necessary data.
Press 'e' to see the door swinging in all its glory.
Attachment: swingdoordemo.PRG (2kB) This file has been downloaded 2979 times
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Quote: Originally posted by dom cook | There you go Mister.
I've stripped down what you had and have made a struct to hold the necessary data.
Press 'e' to see the door swinging in all its glory. |
Ahhh fantastic, thanks a lot dom. I wasn't expecting this solved for me but I'm very grateful, I generally stand no chance with math problems. I'll
stick your name in the credits when this demo is up and running =)
~*~ Princess of Pies and Pastries ~*~
|
|
dom cook
Div Pro
Posts: 387
Registered: 4-3-2016
Member Is Offline
|
|
I couldn't resist the challenge. You seem to be having so much fun with Mode 8 that you've got me wanting to play with it too.
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Quote: Originally posted by dom cook | I couldn't resist the challenge. You seem to be having so much fun with Mode 8 that you've got me wanting to play with it too.
|
Well once I've finished this program here I'll send it to mike and we can all have a look at it in an online demo, hopefully :D
~*~ Princess of Pies and Pastries ~*~
|
|
MikeDX
|
|
Dom is a bit of a genius when it comes to this it seems
|
|
dom cook
Div Pro
Posts: 387
Registered: 4-3-2016
Member Is Offline
|
|
Hardly. but thanks for the compliment.
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
Well done dom cook.
[Edited on 30-11-2016 by CicTec]
|
|
dom cook
Div Pro
Posts: 387
Registered: 4-3-2016
Member Is Offline
|
|
There's actually a mistake in that code.
The lines about vert(i)=vert_i; should say vert(i).v=vert_i; It doesn't seem to affect the prog but I think that's because v happens to be the
first value in the vert struct so vert(i)=vert(i).v anyway. (Just in case you want to add more stuff)
(*square brackets of course)
Another thing that occurred to me was that one could probably have achieved the same results by getting the initial angle from each vert to the pivot
and then rotating them by this angle plus the door angle i.e x1=get_distx(door_angle+angle0,dx); That would make the code simpler.
[Edited on 1-12-2016 by dom cook]
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Can't say I see what you mean there Dom - I did search for vert[ i ]=vert_i and DivDX found nothing. I've modified the code a bit since but that's
just nesting it inside other things to make a more user friendly and flexible door process, are you sure that's what you meant? Or am I a bit dense?
:S
[Edited on 1-12-2016 by BreadCaster]
~*~ Princess of Pies and Pastries ~*~
|
|
Pages:
1
2 |