programm for perspective-grid
hey guys
i am looking for a program to create perspective-grids to draw skyscrapers, houses etc. in perspective.heres a sample. http://www.perspectivegrid.com/index.php?page=9^0^0 thanks and greetings zenbo zenbo |
I don't know if I understand your request, but Blender is great for setting up 3d scenes which you can then render as a picture or film with a moving camera. It's free. I've been playing with it for years. You can make anything from buildings to people, etc.
|
I wasn't sure what a "perspective-grid" was either. Then I did a quick search. If i understand correctly, it's just a 2D projection of squares/rectangles as they diminish to a fixed vanishing point.
Anyway, my terminology notwithstanding, I did see a link to a You Tube video that purports to show how to create perspective grids in GIMP (which should be included in virtually every Linux distribution). Here's the link: GIMP: How to Create Perspective Grids with the Path Tool |
Quote:
heres what i mean, those grids are for artists to draw houses etc. over them: http://www.perspectivegrid.com/index.php?page=9^0^0 |
Well, I was bored and struck by inspiration. So I wrote a script to generate some basic perspective grids using gnuplot.
This probably won't do everything you want it to do. However, it shows that with some scripting, you can modify it and get the features you want. To use it, you will need to have gnuplot and bc installed. Almost every distribution has bc. So the only thing you might need to install would be gnuplot. The way it works is, you specify vanishing point coordinates on the command line. You can specify as many as you like, but I've never seen more than two. You also specify an angle increment for each vanishing point. For each vanishing point, a horizontal line is drawn. Then an angled line is drawn through each vanishing point at each angle increment specified. For instance, you could run the script like so: Code:
<script_name> -point 10 7 -angle 5 -point 1 7 -angle 10 The coordinates are in "inches" and the origin would be the bottom-left of the image produced. The script defaults to creating an image for a plain 8.5 x 11 sheet of paper in landscape. The visible coordinates are restricted to the paper size. For instance, using the defaults, x-values from 0 to 11 would be visible and y-values from 0 to 8.5 would be visible. There is no restriction on the placement of the vanishing points--they need not be placed within the viewable area. Some caveats: (1) Because gnuplot is used as the drawing workhorse, it is not a simple matter to have it draw a vertical line. It's not impossible to do (there are directives to manually draw non-function related lines), but I didn't look into it much. Besides, manually drawing one vertical line per vanishing point ain't a lot of inconvenience. (2) Currently, the angle increment(s) must be integers and they should divide into 180 degrees evenly. If they do not divide into 180 evenly, the radial lines will be "unbalanced." (3) While this script cannot create the image shown on the website you linked to, it is feasible to use the script two or more times and piece the resulting images together. For instance, to create the "floor" of the image on that webpage, you could run the script once with a few vanishing points (e.g. "<script_name> -point 5.5 8.5 -angle 5 -point 5.5 8 -angle 180 -point 5.5 7 -angle 180 -point 5.5 5 -angle 180"). By placing the first point at the upper limit of the viewing area, you "cut off" the top half of the radial lines. The subsequent points are horizontal lines because their angle increment is 180. You repeat the process for the "roof" by creating another plot, but this time putting the first vanishing point at the bottom of the viewing area and placing the horizontal lines above. You might also use image manipulation software to do some scaling. Though, it is possible to do that directly through gnuplot. I did not add that into the script, but it could be done. In all, it's passable and decent (in my opinion) for a few hours of hacking. If you want to try it out, make sure you read the script's comments regarding options it recognizes (e.g. -point, -angle, -dpi, -paperwidth, -paperheight, -output). There is NO nice "usage" help message. Copy the script into a text editor, save it, make it executable (chmod u+x <script_name>), and then give it a try if you like. Here's the script Code:
#!/bin/bash |
wow!!!!!
thanks alot, i hope i get this thing running!! thanks mate, i appreciate it!!!!!!! greetings zenbo |
im quite a newb, i will download that program, and see if i can run your script, maybe ill need some help, and you happen to have time to check this thread, ill keep ya informed.
thanks and greetings zenbo |
Well, I'm actually working on improving it a bit.
I'm trying to add angle start/stop for the radial lines, give the alternative option of saying "I want X radial lines spaced equally between the start-stop angles," and allow for floating-point angle values. And I'm looking at changing the drawing mechanism from functions to two-point line segments--which would allow for vertical lines easily enough. Though, I need to look at the gnuplot docs just to make sure what I'm thinking is possible. I'll post a revised script with what I get working. I may not get everything I want added, but I'll get some. |
ok, first prob, i downloaded gnuplot, but cant find it, its not where the other progs are...
also i pasted the script into the terminal, and pressed enter, after that the terminal desapeared.. |
You'll be using this from the command line. You won't ever actually manually open gnuplot--the script takes care of that.
So, open a terminal: if you're using Ubuntu or something Debian-based, there should be an Applications->Accessories->Terminal menu item (or something similar). That will get you to a command prompt. Save the script somewhere. And then, in the terminal, issue "cd <path>" where <path> is the directory to where you saved the script. Once in the same directory (you can confirm by typing "ls -l" at the terminal, and you should see the filename of the script you saved), then issue the command "chmod u+x <filename>" where <filename> is whatever you named your local copy of the script. To run it, the type "./<filename> <options>" where <options> are whatever switches you want to give the script. It should print some info, and if all is successful, there will be a new PNG file in the same directory. You can use whatever image-viewing utility you like to look at it. Just navigate to it with whatever file manager you use and double-click. EDIT: Quote:
The reason the terminal disappeared was because pasting it directly caused the terminal to try and execute the script then and there. There are some "exit" statements that would have caused the terminal to close. It's not a big deal. Like I said, just save it as a file, and you'll launch it from the terminal a little later. EDIT2: And to make sure that gnuplot is installed, type "which gnuplot" at the terminal. If it doesn't spit out anything but another prompt, then gnuplot has not been installed. You should see something like this: Code:
user@localhost:~$ which gnuplot |
Quote:
you dont mean typing it in, right? did you mean alt+F2 , (run application) ? |
You don't necessarily need to use that specific method. In an earlier reply, you mentioned that you had pasted the script directly into the terminal and the terminal disappeared.
However you opened that previous terminal is fine--just so long as you can get to a command line. |
Quote:
|
Quote:
Other options: 1. Navigate through your programs menu (or whatever Mint refers to it as) and look for any subgroup that has an entry for "terminal" or "command line." And start it from there. 2. You can use the alt+f2 shortcut if you like and run "gnome-terminal" or "xterm" or "konsole" or whatever terminal emulator you have installed. |
Quote:
|
Quote:
|
Quote:
1. Copy the script into a text editor. 2. Save the script to a file. Name it "perspective_grid.bash" -- take note of the directory the file is saved in (e.g. /home/<username>/Documents) 3. Open a terminal (e.g. alt+f2 and type "gnome-terminal" in the prompt) - you should get a new window that allows you to type commands 4. Verify that gnuplot is installed by typing "which gnuplot" as a command in the new terminal window. You should see output similar to what I showed at the end of one of my earlier replies. 5. Type "cd /home/<username>/Documents" as a command in the new terminal window -- this is the same directory mentioned in step #2 and <username> should be replaced with whatever you saw previously. Also, just in case, directory names in Linux are case-sensitive. In other words "documents" is not the same as "Documents" 6. Type "ls -l" as a command in the terminal window. You should see a text listing of all the files in the directory. Confirm that "perspective_grid.bash" is listed 7. Type "chmod u+x perspective_grid.bash" as a command in the terminal window. You won't see any output--just another prompt. 8. Type "./perspective_grid.bash -point 4 4" as a command in the terminal window. The script will print some information, and if all goes well, a new file should be created called "perspective_grid.png" 9. Use a graphical file manager to view your Documents directory. Double-click the icon for "perspective_grid.png" and it should open in your default image viewer program. You should be able to print/shrink/stretch/whatever through that program's tools. 10. To create another image, go back to the terminal and type "./perspective_grid.bash <options>" where <options> is replaced by the sequence of items you want (e.g. different vanishing points, angles, paper dimensions, etc.)--as described by the comments in the script. 11. Once you think the script can handle what you need, then we can talk about getting it so you can run it straight from the alt+f2 prompt. |
sounds good, but what is a text editor? where do i find it?
|
Look through your programs menu. Look for an "accessories" sub group. There should be an entry titled "gedit Text Editor" or something similar.
Alternatively, you can use alt+f2 again. If you use alt+f2, then type "gedit" as the command. A new window should open that will allow you to type or copy-paste text into a new document and save it. |
Quote:
reply to which gnupol is :"/usr/bin/gnuplot" then i dont get:"cd /home/<username>/Dokumente" , whats the username? the documents name? my name? do i write these ">" as well? |
Quote:
I only use the '<' and '>' to help signify that a specific portion of the instructions should be replaced with whatever matches your setup. You would not type them as part of the command. EDIT: But again, I used that as an example of what is normal on systems I have used. The main thing is, it should match the directory that you saved the script to. If you have trouble finding the file, go to the terminal window and type exactly this (you should be able to copy-paste it into your terminal): Code:
cd $( dirname $( find ${HOME} -name "perspective_grid.bash" | head -n 1 ) ) |
Quote:
(_)-(_) wallride@wallride-MXC062 ~ $ which gnuplot /usr/bin/gnuplot wallride@wallride-MXC062 ~ $ cd /home/rob/Documents bash: cd: /home/rob/Documents: No such file or directory wallride@wallride-MXC062 ~ $ cd /home/rob/Dokumente bash: cd: /home/rob/Dokumente: No such file or directory wallride@wallride-MXC062 ~ $ cd /home/ROB/Dokumente bash: cd: /home/ROB/Dokumente: No such file or directory wallride@wallride-MXC062 ~ $ cd /home/ROB/Documents bash: cd: /home/ROB/Documents: No such fi |
ok, made it so far:
(__)\ )\/\ ||----w | || || wallride@wallride-MXC062 ~ $ which gnuplot /usr/bin/gnuplot wallride@wallride-MXC062 ~ $ cd /home/wallride/Dokumente wallride@wallride-MXC062 ~/Dokumente $ Is -I Is: command not found wallride@wallride-MXC062 ~/Dokumente $ IS-I IS-I: command not found wallride@wallride-MXC062 ~/Dokumente $ ls -l total 8 -rw-r--r-- 1 wallride wallride 6326 2011-12-15 23:35 grid wallride@wallride-MXC062 ~/Dokumente $ chmod u+x grid wallride@wallride-MXC062 ~/Dokumente $ ./grid -point 4 4 Perspective point: ( 4, 4) Line every 5 degrees GNUPlot exited cleanly. See "perspective_grid.png" for image wallride@wallride-MXC062 ~/Dokumente $ whats that:"graphical file manager"? |
1 Attachment(s)
yoew!!
|
Made it through I see.
So now you can play around with it some. For instance, try this: Code:
./grid -point 12 5 -angle 1 -point -2 5 -angle 1 I've already improved the script to allow vertical lines and start/stop angles. I'll post the updated script once I work out one or two more bugs. |
Quote:
there are 1,2 and 3 point perspectives, 1 and 2 point perspectives are placed on the horizont line, the third point is placed above ( or under the horizont-line ). allright mate,im off to sleep, i wish you a good evening, and greetings from central europe. tomorow were suposed to have storms here. later dude, and thamks a lot! zenbo ps. ill be back tomorow |
i guess ill have more questions to you, hopefully i ll see ya tomorow or soon back online!!
|
I'm pasting the revised script. Just open up your text editor again, copy-paste it, etc. like before.
If you overwrite the previous copy, you shouldn't need to do the chmod command again. Code:
#!/bin/bash To draw a two-point perspective grid of a "floor" you could do this (with the revised script): Code:
./grid -point 1 4.5 -radials 30 -anglestart 180 -point 10 4.5 -radials 30 -anglestart 180 |
Quote:
Because if it is to draw skyscrapers, houses etc. in perspective, as you say, fire up Blender, build the skyscrapers, houses etc., place the camera at the angle you need to get the perspective you want and take a picture (render the scene). You can make your buildings as complicated or as simple as you want. If it's for a presentation, you can go professional polish all the way. You can make your buildings of futuristic metal, plastic or alien goo, in any color you want. Or you can just pop some cubes on a plane. There is no limit to what you can do in Blender. And the best thing is that Blender does all the perspective calculations for you. But then maybe that is not the end purpose of your need. |
Quote:
|
Quote:
see you later |
Quote:
Here's the high-level view of how the script works--what it's actually doing. Gnuplot is what draws the image. The script simply creates the data files that tell gnuplot what to draw. Because gnuplot is more-or-less a tool designed to plot functions, the data files contain information in the form of coordinates and offsets. So, that is why the script requires vanishing points be given with coordinates. The script tries to simplify using coordinates by treating gnuplot's center-point/origin at the bottom left of the produced image. That way, the user will always be entering positive coordinates--no worrying about negatives (except for specific reasons). If you use the defaults, you can visualize this by drawing a graph-paper-grid on a sheet of paper (in landscape--i.e. longest dimension horizontal) with the grid lines 1 inch apart. That's the coordinate system. When you specify a point to the script, you're giving the coordinate for a vanishing point. By default, a vanishing point is illustrated by drawing radial lines extending from the point you specify. If you take all the defaults, a radial will be drawn at 0 degrees (a horizontal line extending to the right) and additional radial lines will be drawn every 5 degrees counter-clockwise for a full rotation (i.e. all the way back to 0 degrees). In a nutshell, that's it. That's all the script does. It calculates the coordinates needed for gnuplot to draw the radials. It gives you options to control how many radials are drawn, but it's all just a variation on the process above. For two vanishing points to share a horizontal line: specify two points to the script with both points having the same y-coordinate (e.g. (1, 5) and (10, 5) --or-- (2, 7) and (7, 7)) Example command: Code:
./grid -point 1 5 -point 10 5 Example command: Code:
./grid -point 1 5 -anglestart 180 -point 10 5 You can add as many points as you like: Code:
./grid -point 1 3 -anglestart 180 -point 10 3 -anglestart 180 -point 5.5 7 Some "tricks": To draw a horizontal line, include this as part of the script's options: Code:
./grid -point 1 4 -radials 1 To have a vanishing point have more radials at certain degrees. Try this: Code:
./grid -point 4 4 -anglestop 45 -radials 50 -point 4 4 -anglestart 45 -anglestop 135 -radials 50 -point 4 4 -anglestart 135 -anglestop 180 -radials 50 |
And, rather than add an edit to the previous post, here's a sample command that creates something sort of like the bottom half of the image from the original web page you linked to.
Code:
./grid -point 5.5 3.5 -radials 40 -anglestart 180 -point 0 3.25 -radials 1 -point 0 3 -radials 1 -point 0 2.5 -radials 1 -point 0 1.5 -radials 1 Something similar to the top half of the original image could be created by swapping things around. For instance: Code:
./grid -point 5.5 5.5 -radials 40 -anglestop 180 -point 0 5.75 -radials 1 -point 0 6 -radials 1 -point 0 6.5 -radials 1 -point 0 7.5 -radials 1 Code:
./grid -point 5.5 3.5 -radials 40 -anglestart 180 -point 0 3.25 -radials 1 -point 0 3 -radials 1 -point 0 2.5 -radials 1 -point 0 1.5 -radials 1 -point 5.5 5.5 -radials 40 -anglestop 180 -point 0 5.75 -radials 1 -point 0 6 -radials 1 -point 0 6.5 -radials 1 -point 0 7.5 -radials 1 |
dark helmet
i installed the script, it works fine, im trying all the options you includet, ill get back to you if i have more questions. most of all i wanna say thank you for your effort, this was really cool of you, im having a buddy helping me, who is better on computers than me. again thanks alot, ill let you know what i think of it. catch you later. zenbo |
No problem. I hope it works for you.
Every so often I get a "programming itch." It just so happened that I had one right around the time you posted your original message and it dawned on me that the process could be automated (somewhat) with gnuplot. So, as crazy as it might sound, I was entertained by the challenge of it. In addition to having entertained me, I hope it's ends up being useful for you :) |
Quote:
|
In all honesty, that script is not much of a programming feat, but I appreciate the compliment :)
As to your other questions, I've programmed here and there for a long time. Some in grade school, some in my university degree program, some professionally, and some just as a personal hobby. Though, I would not classify myself as a "professional" programmer. The work I did professionally was not the "software development" that most people think of. And yes, programming languages are computer-independent. A computer language just specifies the "vocabulary and grammar" to use when programming. Any computer can then interpret that code as long as the computer has a compiler--a translator of sorts (keeping with the analogy). If you ever decide to get into programming, you'll notice that there may be some cosmetic differences, but almost all programming languages support some core "features." Once you're proficient with one language, you probably won't need much time to become "competent" in another language. |
All times are GMT -5. The time now is 10:26 AM. |