3D vector line graphics

Hi,

I’ve been playing about trying to create a 3D vector game along the lines of the original atari star wars game.  I’m using display.newLine to create the lines, but need a way of detecting say 100 points along the line, maybe using the start and end points and some math calculation but I’m not too experienced with the math code.

Has anybody done this before or know of a way to detect the points?

Cheers

Assuming a simplified scenario, e.g. fixed camera looking down the z-axis, it’s common to have a front and back plane. Stuff in front of the front pane (the screen) or behind the back one aren’t shown. Typically these are normalized to [0, 1], so you can check for less than 0 or more than 1 to do the filtering. Then you can calculate this normalized z as:

(z = 0 is the camera itself, Front > 0, Back > Front)

z01 = (z - Front) / (Back - Front)

You’ll want some reference, probably the front pane, where objects are the “true” size, and usually they’ll be centered around the middle of the screen (or at least all the projections will operate on them that way). The normalized z will come into play in finding the x and y positions at given depths…

Anyhow, that will be the idea, if your “100 points along the line” is trying to figure out where, depth-wise, a given point would be, for collisions and so on. Am I on the right track? I could give you a bunch of this math, but don’t want to type it all up if it’s not what you’re asking after. :slight_smile:

Thanks, the camera isn’t in a fixed position, as you can move up down left and right going down the trench on the screen the camera has to move to give the right perspective. I’ve got the lines of the trench moving well, but yes the points are needed to allow me to move objects down the screen while looking like the correct perspective. I was thinking maybe getting the start and end points of the line and then having a point marker every 10 pixels or so. but I’m not sure there’s enough time in a frame etc to have it smoothly.

This is a quick video of what I have so far.  I need to be able to have objects come towards you and vertical lines go down the sides to make it appear you are moving forwards. Is it possible with corona or is this too much?

Excuse the crude guns to show the ship

https://www.youtube.com/watch?v=WNyxCvMnZlM&list=UUWmVS0MFoJBmWen3ylnl9zg

Hi.

Camera-wise, the strafing isn’t such an issue so long as the z-axis stays the same.

I think you’re more than okay on available resources / being able to do this. I vaguely recall this game (or something like it) from the arcades… I may have even played it and failed terribly.  :smiley:

A few years back I did write up some notes for a slightly different (and, I think, more relevant) perspective scheme, which may be useful:

http://love2d.org/forums/viewtopic.php?t=549&p=5198

It would be a total fluke if I still had the code handy, though. (That having been LOVE 0.4 or 0.5, I wouldn’t give it good odds of still working in any event.)

Looks like the image links on the first page are down, but it was this sort of grid: http://en.wikipedia.org/wiki/File:Shadowrun-Matrix.png

yes it was the early 80’s arcade game, I had it on my cpm 464I think.  Thanks for the link, but I think the math might be over my understanding.  I’ll have a go at seeing if I can get it though.

I’m probably trying to do it the wrong way.  This is what I have for the markers to show the position of the lines, but I can’t get them spaced evenly when moving about.  As I say, I’m not really great with the math for the z axis. I might have to just throw in the towel on this one.

https://www.youtube.com/watch?v=puqj5m78pdU&feature=youtu.be

I just checked a video of shadow run, I can do that style of 3d, but moving the camera adjusts where lines start and end in the x and y planes, it’s that which I’m having the issues with. Fixed perspective I’ve got working quite well, but the effect doesn’t really work for a first person camera view

I took a look at a video. It’s a little more 3D than I thought.  :slight_smile: I didn’t realize it turned when you strafed. I’ll have to take another look to see if some of the obstacles (trenches, towers) actually blocked other objects from view. The way some of the towers grow into view I suspect some kind of raycasting-type rendering approach, but then the ship does a barrel roll too…

Are you going to leave the trench? (Or whatever it may be, since you said it was only “along the lines of” Star Wars.) That is, how general would your scenery end up being? Just sort of trying to get an idea of how you might do level progression and such.

On that line of thought, is updating object positions in 3D fairly intuitive to you? If I were doing this, I think I’d just maintain all the objects’ true positions and everything that way, then every frame convert all the “nearby” objects from 3D to 2D. A lot of the logic logic seems like it would fall under one function for updating a camera and another that would convert the point or line segment. (There’s a slight learning curve to the relevant math, but it’s hardly magic, and I could explain what it’s doing.) Relatively speaking you won’t be doing all that much, versus in a non-vector program with depth-buffering and shaded surfaces.

To be honest I haven’t really got a full game idea planned yet, more a proof of concept to see if I can develop it into something, but I was thinking having open space segments which would e easier as no sides etc, I’ve used the starwars trench as a starter as it gave me something to compare to. I’m not really rendering with the z axis at the mo. I’m adjusting the x and y positions of the lines dependent on values called currentx and currenty to represent the player positions. I was thinking to try a method using snapshots to render a 2d image into 3d but I used the feature before. Or change it to 3rd person view, but I don’t like giving up easy. thanks for the replies.

I meant haven’t used the 2.5d snapshot method before

Thanks for the advice, I have managed to get it working to a point that I can now stop thinking how to do it every waking minute!

http://youtu.be/do21e6oEvvA

Good to hear, and I know exactly how that “can’t stop thinking about it” thing goes!

Assuming a simplified scenario, e.g. fixed camera looking down the z-axis, it’s common to have a front and back plane. Stuff in front of the front pane (the screen) or behind the back one aren’t shown. Typically these are normalized to [0, 1], so you can check for less than 0 or more than 1 to do the filtering. Then you can calculate this normalized z as:

(z = 0 is the camera itself, Front > 0, Back > Front)

z01 = (z - Front) / (Back - Front)

You’ll want some reference, probably the front pane, where objects are the “true” size, and usually they’ll be centered around the middle of the screen (or at least all the projections will operate on them that way). The normalized z will come into play in finding the x and y positions at given depths…

Anyhow, that will be the idea, if your “100 points along the line” is trying to figure out where, depth-wise, a given point would be, for collisions and so on. Am I on the right track? I could give you a bunch of this math, but don’t want to type it all up if it’s not what you’re asking after. :slight_smile:

Thanks, the camera isn’t in a fixed position, as you can move up down left and right going down the trench on the screen the camera has to move to give the right perspective. I’ve got the lines of the trench moving well, but yes the points are needed to allow me to move objects down the screen while looking like the correct perspective. I was thinking maybe getting the start and end points of the line and then having a point marker every 10 pixels or so. but I’m not sure there’s enough time in a frame etc to have it smoothly.

This is a quick video of what I have so far.  I need to be able to have objects come towards you and vertical lines go down the sides to make it appear you are moving forwards. Is it possible with corona or is this too much?

Excuse the crude guns to show the ship

https://www.youtube.com/watch?v=WNyxCvMnZlM&list=UUWmVS0MFoJBmWen3ylnl9zg

Hi.

Camera-wise, the strafing isn’t such an issue so long as the z-axis stays the same.

I think you’re more than okay on available resources / being able to do this. I vaguely recall this game (or something like it) from the arcades… I may have even played it and failed terribly.  :smiley:

A few years back I did write up some notes for a slightly different (and, I think, more relevant) perspective scheme, which may be useful:

http://love2d.org/forums/viewtopic.php?t=549&p=5198

It would be a total fluke if I still had the code handy, though. (That having been LOVE 0.4 or 0.5, I wouldn’t give it good odds of still working in any event.)

Looks like the image links on the first page are down, but it was this sort of grid: http://en.wikipedia.org/wiki/File:Shadowrun-Matrix.png

yes it was the early 80’s arcade game, I had it on my cpm 464I think.  Thanks for the link, but I think the math might be over my understanding.  I’ll have a go at seeing if I can get it though.

I’m probably trying to do it the wrong way.  This is what I have for the markers to show the position of the lines, but I can’t get them spaced evenly when moving about.  As I say, I’m not really great with the math for the z axis. I might have to just throw in the towel on this one.

https://www.youtube.com/watch?v=puqj5m78pdU&feature=youtu.be

I just checked a video of shadow run, I can do that style of 3d, but moving the camera adjusts where lines start and end in the x and y planes, it’s that which I’m having the issues with. Fixed perspective I’ve got working quite well, but the effect doesn’t really work for a first person camera view

I took a look at a video. It’s a little more 3D than I thought.  :slight_smile: I didn’t realize it turned when you strafed. I’ll have to take another look to see if some of the obstacles (trenches, towers) actually blocked other objects from view. The way some of the towers grow into view I suspect some kind of raycasting-type rendering approach, but then the ship does a barrel roll too…

Are you going to leave the trench? (Or whatever it may be, since you said it was only “along the lines of” Star Wars.) That is, how general would your scenery end up being? Just sort of trying to get an idea of how you might do level progression and such.

On that line of thought, is updating object positions in 3D fairly intuitive to you? If I were doing this, I think I’d just maintain all the objects’ true positions and everything that way, then every frame convert all the “nearby” objects from 3D to 2D. A lot of the logic logic seems like it would fall under one function for updating a camera and another that would convert the point or line segment. (There’s a slight learning curve to the relevant math, but it’s hardly magic, and I could explain what it’s doing.) Relatively speaking you won’t be doing all that much, versus in a non-vector program with depth-buffering and shaded surfaces.

To be honest I haven’t really got a full game idea planned yet, more a proof of concept to see if I can develop it into something, but I was thinking having open space segments which would e easier as no sides etc, I’ve used the starwars trench as a starter as it gave me something to compare to. I’m not really rendering with the z axis at the mo. I’m adjusting the x and y positions of the lines dependent on values called currentx and currenty to represent the player positions. I was thinking to try a method using snapshots to render a 2d image into 3d but I used the feature before. Or change it to 3rd person view, but I don’t like giving up easy. thanks for the replies.