Skip to content

Commit a224793

Browse files
authored
Add files via upload
1 parent 34dcf72 commit a224793

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

mapmap_processing_example.mmp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE mapmap>
3+
<project version="0.5.1">
4+
<paints>
5+
<paint className="Image" locked="false" name="to_mapmap_9.jpg" id="1">
6+
<opacity>1</opacity>
7+
<uri>/tmp/to_mapmap_9.jpg</uri>
8+
<rate>1</rate>
9+
<x>370.5</x>
10+
<y>24</y>
11+
</paint>
12+
</paints>
13+
<mappings>
14+
<mapping className="TextureMapping" locked="false" visible="true" name="" paintId="1" id="1" solo="false" depth="1">
15+
<opacity>1</opacity>
16+
<destination className="Mesh">
17+
<locked>false</locked>
18+
<nColumns>2</nColumns>
19+
<nRows>2</nRows>
20+
<vertices>
21+
<vertex x="370.5" y="24"/>
22+
<vertex x="690.5" y="24"/>
23+
<vertex x="370.5" y="264"/>
24+
<vertex x="690.5" y="264"/>
25+
</vertices>
26+
</destination>
27+
<source className="Mesh">
28+
<locked>false</locked>
29+
<nColumns>2</nColumns>
30+
<nRows>2</nRows>
31+
<vertices>
32+
<vertex x="370.5" y="24"/>
33+
<vertex x="690.5" y="24"/>
34+
<vertex x="370.5" y="264"/>
35+
<vertex x="690.5" y="264"/>
36+
</vertices>
37+
</source>
38+
</mapping>
39+
</mappings>
40+
</project>

processing_mapmap_example.pde

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* Saves the rendering of this Processing sketch and sends an OSC message to MapMap.
3+
*
4+
* Usage:
5+
* Press 's' to enable/disable frame saving to MapMap
6+
*/
7+
8+
// CONFIGURATION:
9+
static final int MAPMAP_OSC_RECEIVE_PORT = 12345; // MapMap's default OSC receive port.
10+
static final String OSC_ADDR_SEND_HOST = "localhost";
11+
static final String URI_PREFIX = "file://";
12+
static final int MAPMAP_MEDIA_ID = 1; // The source in MapMap
13+
static final int FPS = 24;
14+
15+
// imports
16+
import netP5.*;
17+
import oscP5.*;
18+
19+
// business logic variables
20+
boolean save_to_mapmap_enabled = true; // let's enable it by default
21+
int current_frame_number = 0;
22+
static final int OSC_ADDR_RECV_PORT = 18939; // useless
23+
OscP5 oscP5;
24+
NetAddress address_to_send_to;
25+
26+
void setup()
27+
{
28+
size(320, 240, P3D);
29+
frameRate(FPS);
30+
oscP5 = new OscP5(this, OSC_ADDR_RECV_PORT);
31+
address_to_send_to = new NetAddress(OSC_ADDR_SEND_HOST, MAPMAP_OSC_RECEIVE_PORT);
32+
}
33+
34+
String make_frame_file_name()
35+
{
36+
current_frame_number = (current_frame_number + 1) % 10;
37+
return "/tmp/to_mapmap_" + current_frame_number + ".jpg";
38+
}
39+
40+
String make_uri_file(String file_name)
41+
{
42+
return "file://" + file_name;
43+
}
44+
45+
void draw()
46+
{
47+
background(0, 127, 0);
48+
fill(0, 255, 0);
49+
ellipse(mouseX, mouseY, 75, 75);
50+
51+
if (save_to_mapmap_enabled)
52+
{
53+
String file_name = make_frame_file_name();
54+
saveFrame(file_name);
55+
send_mapmap_paint_uri(MAPMAP_MEDIA_ID, file_name);
56+
}
57+
}
58+
59+
void send_mapmap_paint_uri(int media_id, String file_name)
60+
{
61+
OscMessage myMessage = new OscMessage("/mapmap/paint/uri");
62+
myMessage.add(media_id);
63+
myMessage.add(make_uri_file(file_name));
64+
oscP5.send(myMessage, address_to_send_to);
65+
}
66+
67+
void toggle_save_to_mapmap()
68+
{
69+
save_to_mapmap_enabled = ! save_to_mapmap_enabled;
70+
}
71+
72+
void keyPressed()
73+
{
74+
switch(key)
75+
{
76+
case 's':
77+
toggle_save_to_mapmap();
78+
break;
79+
}
80+
}

0 commit comments

Comments
 (0)