Phun's Forum. Interventi di vario tipo
Qui sono disponibili tutti i miei interventi nel forum di Phun a partire dal marzo 2008.
Here you find alla my post I wrote on Phun's Forum from March 2008.
How to perfect align many boxes! (8 marzo)
Il Tutorial in Italiano e Inglese è disponibile qui: http://www.alessandrodesimone.net/Phun/index.htm
Here you can see the English text only.
Irregular horizontal alignment
If you want create many equal objects, you can clone them (equal dimension), overlap them (falling down on a base-box or plane) but it’s difficult an horizontal alignment (see figure below). If you examine the scene file (PHN suffix) with an ASCII text editor (NotePad is good, WordPad or Word is’nt good) you can see there are homogeneous line groups. The left alignment parameter is the first Pos value (see the figure below). The values are lightly different indeed.

Now set equal all the first Pos values (see the figure below) writing a credible value (next to existing values). Then save the PHN file and reload it in Phun program. The result is a perfect horizontal alignment.

How to create a library of modular objects (11 marzo)
Con un po' di pazienza è possibile creare un archivio di oggetti scalabili (vedi mio precedente Tutorial) utili in moltissime occasioni. L'esempio che segue (che potete comunque scaricare dal mio sito www.alessandrodesimone.net) rappresenta una banalissima automobile, costituita da una carrozzeria, uno sportello e due ruote. Le molle tengono insieme lo sportello, ma non in caso di urti violenti: la barra posta in basso allo sportello permette appunto di limitare i casi in cui la fuoriuscita dalla sede sarebbe inevitabile. Divertitevi a modificare i vertici e magari a ricavare spazi in cui inserire paraurti, fanali, tettuccio eccetera.
(EN) Let's create a database of scalable (see my previous Tutorial) objects! The sample refers to a body-car and door-car (download them form my website). It's possibile to join objects with (strong) spring, so in case of collision the door stay in place. Enjoy to change and add vertex to car and publish them in Forum space!
Carrozzeria - Body
version = 1;
{
angle = 0.0;
body = 7;
collide = true;
color = [0.0, 1.0, 0.0];
density = 2.0;
friction = 0.5;
id = 8;
pos = [0.0, 0.0];
restitution = 0.5;
type = "polygon";
vecs =
[[0.00, 0.05], [0.20, 0.05], [0.20, 0.10], [0.40, 0.10], [0.40, 0.05], [0.90, 0.05], [0.90, 0.10], [1.10, 0.10], [1.10, 0.05], [1.30, 0.05], [1.30, 0.15], [1.10, 0.30], [0.75, 0.30], [0.75, 0.1], [0.45, 0.1], [0.45, 0.30], [0.30, 0.30], [0.50, 0.50], [0.45, 0.50], [0.25, 0.30], [0.00, 0.20], [0.00, 0.05]]
}
Sportello - Door
version = 1;
{
angle = 0.0;
body = 7;
collide = true;
color = [1.0, 0.0, 0.0];
density = 2.0;
friction = 0.5;
id = 8;
pos = [0.0, 0.0];
restitution = 0.5;
type = "polygon";
vecs =
[[0.00, 0.00], [0.00, 0.20], [0.28, 0.20], [0.28, 0.00], [0.00, 0.00]]
}

How to easly create a simple brick (12 marzo)
(IT) Supponiamo di aver scritto una scena costituita da un semplice mattoncino (vedi miei precedenti Tutorial):
(EN) Let's imagine we wrote a scene where there's a simple "Brick" (please, see my previous Tutorial):
Code
version = 1;
{
angle = 0.0;
body = 7;
collide = true;
color = [0.0, 1.0, 0.0];
density = 2.0;
friction = 0.5;
id = 8;
pos = [0.0, 0.0];
restitution = 0.5;
type = "polygon";
vecs =
[[-3.0, 2.0], [-3.0, -2.0], [-2.0, -2.0], [-2.0, -1.0], [-1.0, -1.0], [-1.0, -2.0], [0.0, -2.0], [0.0, -1.0], [1.0, -1.0], [1.0, -2.0], [2.0, -2.0], [2.0, 2.0], [1.0, 2.0], [1.0, 1.0], [0.0, 1.0], [0.0, 2.0], [-1.0, 2.0], [-1.0, 1.0], [-2.0, 1.0], [-2.0, 2.0]]
}
(IT) Se vogliamo ottenere lo stesso mattoncino, ma in scala 1/10 oppure 1/100, è sufficiente dividere per 10 o per 100 ogni valore delle coordinate dei vertici. Esempio: -3.0 diventa -0.30. Per la scala 1/100, invece, -3.0 diventa -0.03 e così via. Volendo, è possibile effettuare le modifiche usando - con accortezza - la funzione Sostituisci del text editor. Nella figura che segue l'area verde a sinistra è la parte superiore del dente del mattoncino in scala 1:1!
(EN) If we want to obtain the same brick, but in scale 1/10 and 1/100, it's enough to change any value adding a "0.".
Example: -3.0 becomes -0.30 and so on. For 1/100 scale -3.0 becomes -0.03 and so on. You can use [i]Search and Reply[/i] text editor's feature.
In the figure below, the green area is the upper left teeth of 1:1 scene!

How to create a bomb (12 marzo)
Just now available ENGLISH and Italian Tutorial n. 6: Let's create modular objects!
Il Tutorial in Italiano e Inglese (file PDF perfettamente impaginato) è disponibile qui: http://www.alessandrodesimone.net/Phun/index.htm
Here you can see the English text only.
-----------------------------------------------------------------------
How a bomb “works”
When a bomb explodes, many objects squirts anywhere in direction from the middle of bomb to surrounding ambient. Create some couple of circles and join them two-by-two with far springs. Now design an empty envelope, except a little cleft. Move the couples of circles inside the envelope, compressing springs. Around the envelope put many different objects. Now use Brush tool to delete the envelope: the bomb will explode!
![]() |
![]() |
![]() |
How to simulate a earthquake (13 marzo)
Just now available ENGLISH (Earthquake simulation) and Italian (SIMULAZIONE DI UN TERREMOTO) Tutorial n. 7
Il Tutorial in Italiano e Inglese (file PDF perfettamente impaginato) è disponibile qui: http://www.alessandrodesimone.net/Phun/index.htm
Here you can see the English text only.
-----------------------------------------------------------------------
How an earthquake “works”
An earthquake is an earth movement. It can be undulatory (left / right) and / or wincer (up / down).

My simulation is undulatory only (download from my website file Heartquake_1.PHN), and is based on two opposed motors. The spring is useful to well simulate impact.

Caution!
Phun needs many resources. Be aware to overheat your PC system!

I worked a little more. With a new "brick"...

...i made a new skyscraper. Then I joined two brick with a spring, then putting the compressed group on the right and on the left.

The left-right compressed bricks sustain the building and simulate elastic join. The brick's form allows little movements. I think I got a realistic scenery.

You can download the ZIP file (brick and skycraper) from my westite.
Please, let me know what do you thynk about my work.
Good! I "moved" my skyscraper to your scene (download ZIP-file from 7 Simulazione terremoto - Earthquake simulation mywebsite : http://www.alessandrodesimone.net/Phun/index.htm). You'll see that springs try to capture building. You can modify oscillations changing bricks' weight and / or spring strenght.

How to quickly change coordinates (14 marzo)
Do you remember my post (http://phun.cs.umu.se/forum/viewtopic.php?id=137) on how to create mirror for modular objects?
Well, I wrote a Visual Basic 5 Program: you can download from my zip-file on my website (www.alessandrodesimone.net).
When to use Vertex Phun Sign Inverter (V. 1.1).EXE
When in Phun you design a figure, it's simple to get mirror and / or reversed vertex, but it's very hard if the figure is too complex or "strange" as the figure below:

There are hundreds of couple of vertex coordinates! You get crazy if you try to change signs...
How tu use Vertex Phun Sign Inverter (V. 1.1).EXE

Download from my website the ZIP file and extract Vertex Phun Sign Inverter (V. 1.1).EXE. I verified it with anti-virus: please, control again with your antivirus...
By default, in the left text-box there is the "car" I designed in a previous Tutorial. Click on File/Start menu and you'll get the three possible converted codes in the right side text-boxes. Clicking on one of them, the content will be copied in Windows-Standard-Clipboard.
In previous case ("complex" figure) see wath you have to do:

Open Phun and design a "strange" object. Use my program and look at the final result:

Useful? Useless? Please let me know
Jelmerholland wrote:
...i have another problem.. (etc) ...
It's more, more simple tha you can suspect reading following instructions
1) Open Phun
2) Clear scene from previous work (menu File/Clear scene).
3) Design only one object (in your first experiments, not too complex...)
4) Save scene (menu File/Save scene) with name "MyTest"
5) Reduce Phun to icon (so you have more space on screen)
6) Open Notepad (or another text edito. Note NOT word processor, but a really simple TEXT EDITOR!)
7) Open MyTest.PHN
8) Find the part where start with vecs= See sample:
Code:
vecs =
[[0.00, 0.05], [0.20, 0.05], [0.20, 0.10], [0.40, 0.10], [0.40, 0.05], [0.90, 0.05], [0.90, 0.10], [1.10, 0.10], [1.10, 0.05], [1.30, 0.05], [1.30, 0.15], [1.10, 0.30], [0.75, 0.30], [0.75, 0.1], [0.45, 0.1], [0.45, 0.30], [0.30, 0.30], [0.50, 0.50], [0.45, 0.50], [0.25, 0.30], [0.00, 0.20], [0.00, 0.05]]
}
9) Select and copy only from the second bracket to penultimate. See code:
Code:
[0.00, 0.05], [0.20, 0.05], [0.20, 0.10], [0.40, 0.10], [0.40, 0.05], [0.90, 0.05], [0.90, 0.10], [1.10, 0.10], [1.10, 0.05], [1.30, 0.05], [1.30, 0.15], [1.10, 0.30], [0.75, 0.30], [0.75, 0.1], [0.45, 0.1], [0.45, 0.30], [0.30, 0.30], [0.50, 0.50], [0.45, 0.50], [0.25, 0.30], [0.00, 0.20], [0.00, 0.05]
10) Reduce NotePad to icon
11) Open my program Vertex Phun Sign Inverter (V. 1.1).EXE.
12) Clear the left text-box
13) Paste the code
14) Click on File/Start menu
15) click on the text-box coverted code you want
16) Enlarge Notepad
17) Paste the new code exactly in the old position
18) Save the updated file MyTest.PHN
19) Enlarge Phun
20) Click on File/Import scene
21 Enjoy!
How to create mirror for modular objects (15 marzo)
(IT) In un precedente tutorial (http://phun.cs.umu.se/forum/viewtopic.php?id=124) ho descritto come creare semplici oggetti. Grazie a un semplice trucco stavolta vedremo non solo come creare immagini speculari degli stessi, ma anche come posizionarli perfettamente in verticale.
Ogni vertice di una qualunque figura consta di due coordinate, X e Y che in Phun sono racchiuse da una coppia di parentesi quadre aperte e chuse e separate da una virgola. Per ottenere l'immagine speculare destra / sinistra, basterà cambiare il segno di tutte le coordinate X. Ciò significa che se la coordinata X di un vertice è negativa, deve diventare positiva (o meglio, il segno meno va cancellato); se invece è positiva (cioè in assenza di segno) occorre mettere il segno meno. Per ottenere l'immagine speculare sopra / sotto bisogna fare le stesse operazioni, ma per i valori delle coordinate Y. Tutto qui

Per rendere perfettamente verticale una qualsiasi figura - e ovviamente per evitare di adattare a mano con il mouse - basterà assegnare il valore angle = 1.570796327;. Se, invece, si vuol fare ruotare l'oggetto al contrario bisogna assegnare angle = - 1.570796327; Questo numero decimale rappresenta un valore suffcientemente approssimato di pigreco (3.1415...).
Nelle figure che vedete è possibile esaminare meglio quanto esposto. Come al solito, collegandovi al mio sito potetre scaricare il file ZIP contenente tutti gli esempi finora sviluppati.

(EN) In a previous tutorial (http://phun.cs.umu.se/forum/viewtopic.php?id=124) I wrote how to create a simple objects. If you want its mirror left / right it's enough to invert sign of any X coordinates in vecs values. If you want a mirror up / down you have to do the same, but to Y coordinates. To verticalize any object, change angle = 1.570796327; (clockwise) or angle = -1.570796327; on the contrary. The value is half pigreco (3.1415...).
How to create modular objects (15 marzo)
Just now available ENGLISH and Italian Tutorial n. 5: Let's create modular objects!
Il Tutorial in Italiano e Inglese (file PDF perfettamente impaginato) è disponibile qui: http://www.alessandrodesimone.net/Phun/index.htm
Here you can see the English text only.
-----------------------------------------------------------------------
Modular objects
In n. 4 Tutorial (Perfect Geometries) we saw how you can create any shape-object typing the correct value in Phun’s PHN file. In figure below you can see an example.

If you want create many objects, you can easily clone it; afterwards you’ll clone a couple of them and so on until you’ll get complex structure. Remember that the first couple of coordinates is for the first vertex. The last couple of coordinates must be the penultimate vertex. Sometimes happens (I don’t know the why...) that if the first and the last are identical (like in previous figure), Phun will delete the scene!
Press Control Key to select many objects at same moment. Enjoy to clone-and-realize-and-fit very complex structures! Press Play button to fall down the structure to a fixed box to compact the structure.

Simulation
Here is an example of simulation: the structure seems to be elastic!

How to quickly change object's scale (15 marzo)
Do you remember my previous program (Vertex Phun Sign Inverter (V. 1.1).EXE?
Well, forget it
I just wrote a new one which can:
a) Change sign
b) Change scale
Its use is more, more simple tha you can suspect reading following instructions

1) Open Phun
2) Clear scene from previous work (menu File/Clear scene).
3) Design only one object (in your first experiments, not too complex...)
4) Save scene (menu File/Save scene) with name, i.e. , "MyTest"
5) Reduce Phun to icon (so you have more space on screen)
6) Open Notepad (or different text editor. Note NOT word processor, but a really simple TEXT EDITOR!)
7) Open MyTest.PHN
8) Find the part where start with vecs= See sample:
Code:
vecs =
[[0.00, 0.05], [0.20, 0.05], [0.20, 0.10], [0.40, 0.10], [0.40, 0.05], [0.90, 0.05], [0.90, 0.10], [1.10, 0.10], [1.10, 0.05], [1.30, 0.05], [1.30, 0.15], [1.10, 0.30], [0.75, 0.30], [0.75, 0.1], [0.45, 0.1], [0.45, 0.30], [0.30, 0.30], [0.50, 0.50], [0.45, 0.50], [0.25, 0.30], [0.00, 0.20], [0.00, 0.05]]
}
9) Select and copy only from the second bracket to penultimate. See code:
Code:
[0.00, 0.05], [0.20, 0.05], [0.20, 0.10], [0.40, 0.10], [0.40, 0.05], [0.90, 0.05], [0.90, 0.10], [1.10, 0.10], [1.10, 0.05], [1.30, 0.05], [1.30, 0.15], [1.10, 0.30], [0.75, 0.30], [0.75, 0.1], [0.45, 0.1], [0.45, 0.30], [0.30, 0.30], [0.50, 0.50], [0.45, 0.50], [0.25, 0.30], [0.00, 0.20], [0.00, 0.05]
10) Open a new window of NotePad, paste in the code and save (no matter which name).
11) Open my program Phun_Change_Scale_1.EXE.
12) Click on File/Open and load the text file you saved in step 10.
13) Select X factor and / or Y factor Multiply (to enlarge object) or Divide (to reduce)
14) Type the value for each one (may be negative).
15) Click on File/Run menu: the code will be pasted in right text box and in Windows' clipboard too.
16) Paste the new code exactly in the old position of PHN file you copied from (see step 9).
17) Save the updated file with different name from original.
18) Load Phun
19) Click on File/Import scene
20) Enjoy!
Sample:

How to create perfect geometric figures (16 marzo)
Just now available ENGLISH and Italian Tutorial n. 4: Let's create perfect geometric figures!
Il Tutorial in Italiano e Inglese è disponibile qui: http://www.alessandrodesimone.net/Phun/index.htm
Here you can see the English text only.
-----------------------------------------------------------------------
Phun’s codes
Phun’s objects are a simple “group” of codes. Try to design a rectangle and a circle and save the scene with name Box_Circle.PHN. If you examine the file with an ASCII text editor (like NotePad) you’ll se something like this:

It’s easy to detect the two “blocks” inside the { } parenthesis. According to the specific scene file there are different codes:
Code Value Comment
Angle Decimal value (pos./neg.) Rotation angle
Body Entire positive value ???
Collide True / False Collision capability
Color Three decimal positive values RGB values (Red, Green, Blue)
Density Decimal positive value Weigh
Friction Decimal positive value
id Entire positive value N. object (???)
Pos Couple decimal values (pos./neg.) Object’s origin coordinates
Restitution Decimal positive value ???
Type Polygon / Circe / Spring … Object typology
Vecs Decimal values (pos./neg.) Vertex’s object coordinates
Radius Decimal positive value Only for circles
The mean of some codes (see three question marks “???”) is unknown (for me...). Anyway it’s possible change file’s values.
Too many parameters
Looking at the previous figure, you can see that the circle has two parameters (origin coordinates and radius) but the rectangle has much more parameters than the origin and four vertexes’ coordinates. Anyway you can modify any value. Look at the following figure:

You can see the differences between the vertexes’ box at design-time (right) and the box generated by typing values in PHN file (left).

New horizons
Typing directly values inside the PHN file allows you to realize geometric figures, like triangles. Furthermore, you can perfectly position any figure everywhere you want. Look at the figure below, where two triangle are perfectly positioned inside a box and the circle has the same diameter as the box’s height and is strictly tangent to it.

But more! The design’s symmetry pose the objects in perfect balance: try to move objects like in figure below, than press play. The triangles fall down, but they don’t rotate and stay equilibrate on inferior vertex!

How to create object writing X,Y coords (FREE program for Phun's users) (16 marzo)
Well, I wrote a program which can be useful to create any geometric object. You have only to write the object on a paper, then use my program:

Then load the created object in Phun. Example:

Remember that I put all my "works" about PHUN's program into the ZIP file (often updated) you can find on my website (http://www.alessandrodesimone.net/Phun/index.htm) clicking on the link Click here to dowload all Tutorial's Phun (*.PHN) files.
Anyway, you'll find these instructions in program (menu Help):
1) Design your object with a pencil on a small-square copybook-paper.
2) Design around the object the X and the Y axis and write the coordinates (1, 2, 3...) on them.
3) Open my program and - for each of your vertex' object - type the X and the Y coords pressing Return key.
4) Click on the wrong coords, if any, and press Delete coord button.
5) Click on the coord. where you want to enter a forgotten coords, if any, then type X and Y coords and press Insert coord button.
6) Click on menu "File/Past on clipboard" to paste the entire object-code (from "Version=1;" to " } " ) in the Windows' clipboard.
7) Open a TextEditor (like Notepad) and Paste into the code.
8) Save the code typing the .PHN suffix on the end of filename.
9) Open Phun program and load /menu File/Import Scene)the scene in.
Remember the ID value is 4. If necessary, change it.
How to perfectly align many boxes (part 2) (17 marzo)
I wrote a Tutorial - and Cheesemoo replied (http://phun.cs.umu.se/forum/viewtopic.php?id=40) - a method to perfectly align many boxes.
Cheesemoo's method is good, but I think it's difficult to rotate again to a perfecly horizontal position.
I found a new method:

What do you think about?
just shift+rotate! it rotates each 15 degrees
Good to know. I didn't know. But...
...but if you have a box just rotated (i.e. 10 degrees), when you rotate it pressing shift key, the object rotates addig +15 degrees to the original position.
In other words: first step (10 + 15) 25; second step (25 + 15), 40 etc.
How to design couple of cogwheels (19 marzo)
It' very difficult to design perfect cogwheels. But if you want only to play...
1) Using my program (please, refer to http://phun.cs.umu.se/forum/viewtopic.php?id=176) you can design a single tooth, then reduce it with another program of mine (http://phun.cs.umu.se/forum/viewtopic.php?id=152). If you don't want to work, copy the following final single-tooth code:
Code:
[ 0, 0] , [ 0.5, 0] , [ 0.5, 0.7] , [ 0.45, 0.9] , [ 0.3, 1.2] , [ 0.2, 1.2] , [ 0.05, 0.9] , [ 0, 0.7] , [ 0, 0]
2) Import the tooth object file in Phun:

3) Pressing shift key, it's possibile to rotate any object exactly 15 degrees at a time (please refer to discussion http://phun.cs.umu.se/forum/viewtopic.php?id=69.) Create a circle (enough big) then you clone and rotate 12 teeth. Fix any tooth to circle's border (be rigorous!), then add a hinge-motor in center. Select the whole wheel, clone it and separate.

4) It's easy to put tooth on circle: the line must be tangent to internal border:

Example:

What to do if you need a cogwheels in 1:2 ratio.
1) The minor wheel must have 1/2 bigger's diameter. Of course, the number of teeth must be half (6 in little, 12 in the big one).
2) The form and dimensions of theet must be the same (of course in Phun. In "real" mechanics there are some differences...)
3) The degree's difference from one tooth to next must be identical. In the figure below the big wheel has a space between teeth of 15 degrees; the little one, 30 degrees.
4) The "curvature" of teeth (big and little wheels) are identical.
5) Change the position's theeth, respect the center of circle, if the teeth collide (and stop or inhibit the rotation) or don't engage (and the rotation doesn't start).

For different ratio (1:3, 2:5 etc) it's obviously necessary to divide 360 degree in identical part. It's very hard to make it by hand.
So I wrote a program (please, refer to my website) to create any degree you want:

How to customize Clouds (21 marzo)
1) Open the folder Phun\Data\Textures\background
2) Make a security-copy of a (any) cloud.
3) Open a graphic program which can manage PNG images and open the cloud (in the following example is cloud4.png).
4) Open a photo (or a design) with the dimension a little bit less than cloud.
5) Make a merge; if you want, change the image as you want.

6) Save the processed image. Be sure the format is PNG !
7) Open Phun, be sure Options/Draw clouds is checked and enjoy!

8) Repeat for other clouds: preserve original Phun's clouds! Remember to restart Phun after change.
How to customize Circle (21 marzo)
1) Open the folder Phun\Data\Textures[/b]
2) Make a security-copy for the file wheel.png
3) Open a graphic program which can manage PNG images and open [i]wheel.png file.
4) Open a photo (or a design) with the dimension a little bit less than circle inside wheel. Beware: don't overwrite transparent border of original file!
5) Make a merge; if you want, change the image as you want.

6) Save the processed image. Be sure the format is PNG !
7) Open Phun and be sure Options/Enable shaders is uncheched.
8) Draw circles, change color (if you like) and enjoy!

Preserve original Phun's files! Remember to restart Phun after change.
...uhmm... I've no time, but it's possible scan Euros and...

Another idea:
1) Get a copy of original wheel.png file.
2) Open wheel.png file and delete the circle: the whoole image's "color" must be transparent (refer to your graphic program's instructions for references).
3) Choose and open you desidered photo. It can be a JPG or any different format.
4) Cut and reduce image's dimension so it's about wheel.png dimension. Cut-out border around your image: the background must be transparent.
5) Copy the image and paste it into the wheel.png's area. Save it.

6) Remember the new wheel.png will be the image for all circles in Phun.

Suggestion for EMIL:
In next Phun's version add a parameter to circle. Example:
NOW:
Code:
{
angle = 0.0;
body = 98;
collide = true;
..... ..... ......
pos = [2.683584451675415, -3.698863983154297];
radius = 0.3015430271625519;
restitution = 0.5;
type = "circle"
};
SUGGESTION:
Code:
{
angle = 0.0;
.... .... ....
type = "circle"
image = "wheel"
};
{
angle = 0.0;
.... .... ....
type = "circle"
image = "personal_1"
};
{
angle = 0.0;
.... .... ....
type = "circle"
image = "personal_2"
};
(etc)
Parole chiave (sezione per motori di ricerca):
Tutorial - Phun - Processore fisico virtuale - Phun http://www.acc.umu.se/~emilk/ - Clonazione - Colonazione multipla - Fixate - Strutture complesse - Mattone - Strutture modulari - crare una bomba - simulazione terremoto - phun earthquake simulation - Brick