NCF参数化建筑论坛
标题:
Wii chuck+Ardunio+Processing
[打印本页]
作者:
panhao1
时间:
2010-12-28 23:51
标题:
Wii chuck+Ardunio+Processing
本帖最后由 panhao1 于 2010-12-29 00:10 编辑
这个是在南方三校工作营做的一个东西 是在无比辛苦的评图结束之后的一个新建筑设计技术展示 是给3院长来体验加速传感器控制造型的设计方式 是多一些东西来调试参数 包括鼠标和操纵杆 陀螺仪 等输入设备 其实还可以加上其他元件 如压力传感器 光敏电阻等 [attach]13433[/attach] 基本的原理
http://hi.baidu.com/processingqx/blog/item/954879ee85dc161ffcfa3c05.html
先看代码 主要是张拉膜结构的设计 这里参考了之前某哥们发的simonG particle的例子 这个类库是开源的 但是木有说明 所以看源代码凑合着运用吧 平台依旧是eclipse,介绍详见sky视屏教程 public class MeshImport { ParticleSystem ps; public ArrayList
point=new ArrayList
(); public ArrayList
line=new ArrayList
(); public ArrayList
fixindex=new ArrayList
(); public MeshImport(ParticleSystem pst) { ps=pst; } public void read(String txt){ try { FileReader read = new FileReader(txt); BufferedReader br = new BufferedReader(read); String row; while((row = br.readLine())!=null){ String[] p=row.split(" "); if (p.length==4){ float x=Float.parseFloat(p[1]); float y=Float.parseFloat(p[3]); float z=Float.parseFloat(p[2]); Particle pa=new Particle( this.ps, x, y, z); pa.visible=false; point.add(pa); } else if(p.length==3){ int p1=Integer.parseInt(p[1]); int p2=Integer.parseInt(p[2]); Spring sp=new Spring(point.get(p1), point.get(p2)); sp.setRestToActualLength(); line.add( sp ); } else if(p.length==2){ int fix=Integer.parseInt(p[1]); fixindex.add(fix); this.point.get(fix).fix(); } } }catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e){ e.printStackTrace(); } } //////////// } public class t2 extends PApplet { private static final long serialVersionUID = 1L; PeasyCam cam; Serial myPort; int ax=0; int ay=0; int az=0; boolean b1=false; boolean b2=false; int mx=0; int my=0; ParticleSystem ps; MeshImport mesh; int move; Particle p; //////////////////////////////////////////////////////// public void setup(){ size(800,600,OPENGL); ps=new ParticleSystem(this); ps.setGravity(-1); ps.defaultMass = 0.5f; ps.defaultSpringStrength = 1f; ps.defaultSpringDamping = 0.1f; cam = new PeasyCam(this, 200); cam.setMinimumDistance(50); cam.setMaximumDistance(5000); strokeWeight(1); stroke(255,50); mesh=new MeshImport(ps); mesh.read("F:/my.txt"); move=0; int i =mesh.fixindex.get(move); p=mesh.point.get(i); /////////////////////////////// println(Serial.list()); myPort = new Serial(this, Serial.list()[12], 115200); myPort.clear() } boolean sign1=false; boolean sign2=false; float x,y; public void draw(){ background(0); //////////////////////////////// if (b1){ move+=1; if (move>mesh.fixindex.size()-1) move=0; int i =mesh.fixindex.get(move); p=mesh.point.get(i); } if (b2){ if (ax>85){ax=ax-85;} if (ay>65){ay=ay-65;} if (az>63){az=az-63;} p.pos[2]=x+ax; p.pos[0]=y+ay; p.pos[1]=p.pos[1]+az; }else{x=p.pos[2];y=p.pos[0]; if (mx>150){ p.pos[2]-=(mx-150)/50; } if (mx<130){ p.pos[2]+=(130-mx)/50; } if (my<120){ p.pos[0]+=(130-my)/50; } if (my>140){ p.pos[0]-=(my-140)/50; } } ///////////////////////////////////////// pushMatrix(); translate(p.pos[0],p.pos[1],p.pos[2]); box(1); popMatrix(); ps.draw(); } public void serialEvent(Serial myPort) { String myString = myPort.; if (myString != null) { myString = trim(myString); String strs[]=myString.split(","); ax=Integer.parseInt(strs[0]); ay=Integer.parseInt(strs[1]); az=Integer.parseInt(strs[2]); b1=true;b2=true; if(Integer.parseInt(strs[3])==0)b1=false; if(Integer.parseInt(strs[4])==0)b2=false; mx=Integer.parseInt(strs[5]); my=Integer.parseInt(strs[6]); } } //////////////////////////////////////////////////////////////////////////// }
作者:
panhao1
时间:
2010-12-28 23:52
本帖最后由 panhao1 于 2010-12-29 00:11 编辑
再看图吧 1 在犀牛里面画上线line(或是网格mesh),吧要固定的地方画上点point [attach]13430[/attach] 2然后用gh输出相应文件file 格式通过代码可以反推的 我就懒得具体写了 以鼓励大家练习代码。图片放大也能看到文件格式 [attach]13431[/attach] 3最后直接运行eclipse 的Project [attach]13432[/attach] 白色的点可以通过陀螺仪和其它元件控制移动 当时给各3学校院长试用了一番 反馈相当不错,稳定性比那个不给力的投影仪好多了
作者:
panhao1
时间:
2010-12-29 00:06
本帖最后由 panhao1 于 2010-12-29 18:19 编辑
wii chuck 的代码是网上下载的 主要是我不知道模拟信号输出的上下限 大家可以根据自己的手柄具体调试 这个网站上面的代码是可以用的 自己写也不难 delay(20);就够了
http://blog.booksforce.com/2008/ ... %e9%85%8d%e5%99%a8/
附上现场照片
作者:
yanhui314
时间:
2010-12-29 00:30
一个字,望尘莫及
作者:
没碗
时间:
2010-12-29 01:02
四个字,好
作者:
Line
时间:
2010-12-29 01:24
三个字,厉害
作者:
f(x)
时间:
2010-12-29 01:57
对于我这种小学数学不好的人来说,四个字:牛!
作者:
Lee200403100
时间:
2010-12-29 05:21
给力!感觉还蛮难的,膜拜一下
作者:
SDK
时间:
2010-12-29 07:57
两个字:学不会呀
作者:
wyx10022
时间:
2010-12-29 08:54
一团迷雾ing………………
作者:
skywoolf
时间:
2010-12-29 09:18
五个字,很犀利而且很给力~{:3_51:}看完感觉北面这边设备有些贫瘠了=3
作者:
holonking
时间:
2010-12-29 10:05
顶起顶起!
作者:
musofan
时间:
2010-12-29 10:07
提示:
作者被禁止或删除 内容自动屏蔽
作者:
TG123
时间:
2010-12-29 11:20
三个字:...
作者:
gzblake
时间:
2010-12-29 11:35
提示:
作者被禁止或删除 内容自动屏蔽
作者:
sunjiaxi0525
时间:
2010-12-29 11:50
够够够。。。。。。。。。力
作者:
elevenyao
时间:
2010-12-29 14:08
这个。。。相当给力。。。。虽然看不懂。 也许看不懂才给力吧。。。。。
作者:
weiwei
时间:
2010-12-29 14:55
挺一個 棒透了
作者:
panhao1
时间:
2010-12-29 18:11
19#
lawlignt
木有视屏 因为是实时操作的 补几张图片吧
作者:
claudemit
时间:
2010-12-29 19:34
100个字,仰望!
作者:
seraphseraph
时间:
2010-12-29 20:48
膜拜之~此处省略N个字。。
作者:
尹英壁
时间:
2010-12-29 20:57
只能说:太给力了……望尘莫及!
作者:
小新同学
时间:
2010-12-31 13:42
什么都没看出来
作者:
miniorange
时间:
2010-12-31 21:39
可以用兩個手把玩呀XDD 之前我接了4隻,但是USB供電怪怪的,差點把板子燒爛
作者:
董羽天
时间:
2010-12-31 23:33
{:3_52:}O(∩_∩)O哈哈哈~很有意思
作者:
panhao1
时间:
2011-1-1 01:53
26#
miniorange
电脑USB不怎么给力 我的台式机勉强可以接4个ccd
作者:
zhengzongliang
时间:
2011-1-1 03:18
好东西谢谢分享
作者:
nic8828
时间:
2011-1-6 15:23
高端 看不明白
作者:
bxsqrym
时间:
2011-5-24 13:51
泪奔~~~泪奔
作者:
yinlu1320
时间:
2011-11-2 17:15
。。。。。。。。。。。嗯。。这里省略一万个字
作者:
s.k.
时间:
2012-5-18 19:38
{:3_68:}一个字,强大无比(以下省略1000字)。。
作者:
benemorphy
时间:
2012-6-13 15:52
一个字,好!两个字,给力!
作者:
mysanaa
时间:
2014-8-5 19:38
有种没有必要的感觉
作者:
mysanaa
时间:
2014-8-10 19:37
panhao1 发表于 2010-12-29 00:06
登录/注册后可看大图
wii chuck 的代码是网上下载的 主要是我不知道模拟信号输出的上下限
大家可以根据自己的手柄具体调试
环境真好 很少有地方有这样的平台吧
欢迎光临 NCF参数化建筑论坛 (http://bbs.ncf-china.com/)
Powered by Discuz! X3.2