UE4

買ってみた。

https://images-na.ssl-images-amazon.com/images/I/519Erig0BtL._SX386_BO1,204,203,200_.jpg

ガラスのマテリアルを当てた内観
f:id:ysok_na:20161113185022p:plain

水のブループリント
f:id:ysok_na:20161113185033p:plain

shell 3d print by replicator mini

球をインフィルを下げ、1層のシェルで3Dプリントテスト

元データ
f:id:ysok_na:20161027191505j:plain

replicator mini + maker bot desktop

quality : standard

raft : on
support : on
shell : 1
infill : 0%
layer resolution : 0.3



途中でもじゃった
f:id:ysok_na:20161027192044j:plain
f:id:ysok_na:20161028135357j:plain
f:id:ysok_na:20161028135400j:plainf:id:ysok_na:20161028135358j:plain


Pythonでのパネリング

RhinoScriptSyntax.AddLine(PtA , PtB)
Rhino.Geometry.Line(PtA , PtB)
たぶん同じ結果??

# input type - unum , vnum : int

import Rhino.Geometry as rg

a = []
b = []

for i in range(unum):
    for j in range(vnum):
        
        pt11 = surf.PointAt(i/unum, j/vnum)
        pt12 = surf.PointAt((i+1)/unum, j/vnum)
        pt22 = surf.PointAt((i+1)/unum, (j+1)/vnum)
        pt21 = surf.PointAt(i/unum, (j+1)/vnum)
        
        # line1 = rs.AddLine(pt11,pt22)
        # line2 = rs.AddLine(pt12,pt21)

        line1 = rg.Line(pt11,pt22)
        line2 = rg.Line(pt12,pt21)
        
        a.append(line1)
        b.append(line2)
Remove all ads

Python vs C#

”重い処理は、C#で書くと軽くなって処理が早い”
kuma事務所からの噂を、50x50x50の点オブジェクトを作る処理で実験。

grasshopperとghPythonとC#など

f:id:ysok_na:20161022195610j:plain


写真上から
grasshopper : 330ms (2%)

ghPython : 10.9s (85%)

C# : 1.2s (9%)

(grasshopperのところは他にもseriesなどのコンポーネントもあるので、もう少しかかる(ほぼゼロに近いが))



結果として、今回の作業だと、C#は、Pythonよりもはやいが、
grasshopperのコンポーネントで直接やったほうが早かった。


以下、そーす

Python

import rhinoscriptsyntax as rs

a = []

for i in range(x):
    for j in range(x):
        for k in range(x):
            point = rs.AddPoint(i,j,k)
            a.append(point)

C#

  private void RunScript(int x, ref object A)
  {
    List<Point3d> pts = new List<Point3d>();

    for (int i = 0; i < x; i++){
      for (int j = 0; j < x; j++){
        for (int k = 0; k < x; k++){
          Point3d tempPt = new Point3d(i, j, k);
          pts.Add(tempPt);
        }
      }
    }
    A = pts;
  }
Remove all ads

how to use UP Plus2

connect usb

3d print > initialize

file > open
open STL file

Move
Scale
Rotate

Auto Placement!!!

(3d print > table heat)

3d print > print > ok

Remove all ads

pushMatrix() / popMatrix()

pushMatirx()
pushMatrix() \ Language (API) \ Processing 2+
popMatrix()
popMatrix() \ Language (API) \ Processing 2+

record (0,0) and pull (0,0)Understanding pushMatrix() and popMatrix() requires understanding the concept of a matrix stack.

pushMatrix() function saves the current coordinate system to the stack
popMatrix() restores the prior coordinate system.

pushMatrix() and popMatrix() are used in conjuction
with the other transformation functions
and may be embedded to control the scope of the transformations.

background(255);
line(0,10,width,10);
line(10,0,10,height);
noStroke();
translate(10,10);

fill(255,0,0,127);
rect(0,0,50,50); // red


pushMatrix(); // record (0,0)

translate(30,30);
fill(0,255,0,127); // green
rect(0,0,50,50);

popMatrix(); // pull (0,0)


fill(0,0,255,127);
rect(2,2,50,50); // blue
Remove all ads

lights()

lights()
lights() \ Language (API) \ Processing 2+
Sets the default ambient light,directional light, falloff, and specular values.

The defaults are ambientLight(128, 128, 128) and directionalLight(128, 128, 128, 0, 0, -1), lightFalloff(1, 0, 0), and lightSpecular(0, 0, 0).

Lights need to be included in the draw() to remain persistent in a looping program.

Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop.

size(100,100,P3D);
background(0);
noStroke();

// sets the default ambient
// and directonnal light
lights();

translate(20,50,0);
sphere(30);

translate(60,0,0);
sphere(30);
void setup(){
  size(100,100,P3D);
  background(0);
  noStroke();
}

void draw(){
  // Include lights() at the beginning
  // of draw() to keep them persisitent
  
  lights();
  translate(20,50,0);
  sphere(30);
  translate(60,0,0);
  sphere(30);
}
Remove all ads

Rotate camera with mouse Dragging

マウス操作によるカメラ移動 with Processing : 東京工業大学 ロボット技術研究会

class MouseCamera {
  
  float eyeX, eyeY, eyeZ;
  float centerX, centerY, centerZ;
  float upX, upY, upZ;
  float radius;
  float[][] matrix;
  PVector preVector;
  
  MouseCamera(float radius) {
    this(radius, width/2.0, height/2.0, (height/2.0)/tan(PI*30.0/180.0), width/2.0, height/2.0, 0, 0, 1, 0);
  }
  MouseCamera(float radius,
              float eyeX, float eyeY, float eyeZ,
              float centerX, float centerY, float centerZ,
              float upX, float upY, float upZ) {
    this.radius = radius;
    this.eyeX = eyeX;
    this.eyeY = eyeY;
    this.eyeZ = eyeZ;
    this.centerX = centerX;
    this.centerY = centerY;
    this.centerZ = centerZ;
    this.upX = upX;
    this.upY = upY;
    this.upZ = upZ;
    matrix = getIdentityMatrix();
  }
  
  void update() {
    beginCamera();
    camera(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
    
    applyMatrix(matrix[0][0], matrix[0][1], matrix[0][2], matrix[0][3], 
                matrix[1][0], matrix[1][1], matrix[1][2], matrix[1][3], 
                matrix[2][0], matrix[2][1], matrix[2][2], matrix[2][3], 
                matrix[3][0], matrix[3][1], matrix[3][2], matrix[3][3]);
    endCamera();
  }
  
  void mousePressed() {
    switch(mouseButton) {
      case RIGHT:{
        matrix = getIdentityMatrix();
      }
      break;
      
      case LEFT: {
        preVector = mouseOnSphere(mouseX-width/2, mouseY-height/2);
      } 
      break;
      
      case CENTER: {
        preVector = new PVector(mouseX-width/2, mouseY-height/2);
      } 
      break;
    }
  }

  void mouseDragged() {
    switch(mouseButton) {
      
      case LEFT: {
        PVector v = mouseOnSphere(mouseX-width/2, mouseY-height/2);
        matrix = mult(getRotationMatrix(preVector, v), matrix);
        preVector = v;
      } 
      break;
      
      case CENTER: {
        PVector v = new PVector(mouseX-width/2, mouseY-height/2);
        matrix = mult(getTranslationMatrix(preVector, v), matrix);
        preVector = v;
      } 
      break;
    }
  }
  
  void mouseWheel(MouseEvent event) {
    matrix = mult(getScaleMatrix(event.getCount()), matrix);
  }
  
  float[][] getIdentityMatrix() {
    return new float[][] { {1.0, 0.0, 0.0, 0.0}, 
                           {0.0, 1.0, 0.0, 0.0},
                           {0.0, 0.0, 1.0, 0.0},
                           {0.0, 0.0, 0.0, 1.0} };
  }
  
  float[][] getRotationMatrix(PVector v1, PVector v2) {
    PVector v = v1.cross(v2);
    v.normalize();
    v.mult(8.0);
    float c = v1.dot(v2); // cos
    float s = v1.cross(v2).mag(); // sin
    return new float[][] { {c + v.x*v.x*(1-c), v.x*v.y*(1-c) - v.z*s, v.x*v.z*(1-c) + v.y*s, 0.0}, 
                           {v.y*v.x*(1-c) + v.z*s, c + v.y*v.y*(1-c), v.y*v.z*(1-c) - v.x*s, 0.0}, 
                           {v.z*v.x*(1-c) - v.y*s, v.z*v.y*(1-c) + v.x*s, c + v.z*v.z*(1-c), 0.0}, 
                           {0.0, 0.0, 0.0, 1.0}};
  }
  
  float[][] getTranslationMatrix(PVector v1, PVector v2) {
    return new float[][] { {1.0, 0.0, 0.0, v2.x-v1.x}, 
                           {0.0, 1.0, 0.0, v2.y-v1.y}, 
                           {0.0, 0.0, 1.0, v2.z-v1.z}, 
                           {0.0, 0.0, 0.0, 1.0} };
  }
  
  
  float[][] getScaleMatrix(float wheelCount) {
    float temp = 10.0;
    return new float[][] { {exp(-wheelCount/temp), 0.0, 0.0, 0.0},
                           {0.0, exp(-wheelCount/temp), 0.0, 0.0},
                           {0.0, 0.0, exp(-wheelCount/temp), 0.0},
                           {0.0, 0.0, 0.0, 1.0} };
  }


  PVector mouseOnSphere(float x, float y) {
    float _x = x/radius;
    float _y = y/radius;
    PVector res = new PVector(_x, _y, 0.0);
    if (_x*_x + _y*_y > 1.0) {
      res.normalize();
    }
    
    else {
      res.z = sqrt(1.0 - _x*_x - _y*_y);
    }
    return res;
  }

  float[][] mult(float[][] m1, float[][] m2) {
    assert(m1[0].length == m2.length);
    float[][] res = new float[m1.length][m2[0].length];
    for (int i=0; i<m1.length; i++) {
      for (int j=0; j<m2[0].length; j++) {
        float sum = 0;
        for (int k=0; k<m1[0].length; k++) {
          sum += m1[i][k]*m2[k][j];
        }
        res[i][j] = sum;
      }
    }
    return res;
  }
}
//sphere + torus

import processing.opengl.*;
MouseCamera mouseCamera;

void setup() {
  size(800, 800,OPENGL);
  mouseCamera = new MouseCamera
  (800.0, 0, 0, (height/2.0)/tan(PI*30.0/180.0), 0, 0, 0, 0, 1, 0);
}

void draw() {
  mouseCamera.update();
  background(200);
  noFill();
  stroke(0);
  strokeWeight(0.5);
  sphere(100);
  torus(250, 50, 60, 30);
  
  // origin
  strokeWeight(1);
  stroke(0,0,0);
  fill(255);
  box(25);
  
  // x
  // red
  stroke(255,0,0);
  line(0,0,0,200,0,0);
  
  // y
  // green
  stroke(0,255,0);
  line(0,0,0,0,200,0);
  
  // z
  // blue
  stroke(0,0,255);
  line(0,0,0,0,0,200);
}


void torus(float R, float r, int countS, int countT) {
  for (int s=0; s<countS; s++) {
    float theta1 = map(s, 0, countS, 0, 2*PI);
    float theta2 = map(s+1, 0, countS, 0, 2*PI);
    beginShape(TRIANGLE_STRIP);
    // beginShape(QUAD_STRIP);
    
    for (int t=0; t<=countT; t++) {
      float phi = map(t, 0, countT, 0, 2*PI);
      vertex((R+r*cos(phi))*cos(theta1), (R+r*cos(phi))*sin(theta1), r*sin(phi));
      vertex((R+r*cos(phi))*cos(theta2), (R+r*cos(phi))*sin(theta2), r*sin(phi));
    }
    endShape();
  }
}


void mousePressed() {
  mouseCamera.mousePressed();
}
void mouseDragged() {
  mouseCamera.mouseDragged();
}
void mouseWheel(MouseEvent event) {
  mouseCamera.mouseWheel(event);
}
Remove all ads

Rotate camera with mouse location

import processing.opengl.*;

void setup(){
  size(600,600,OPENGL);
  smooth();
}

void draw(){
  background(200);
  
  translate(width*0.5,height*0.5,0);
  rotateY(map(mouseX,0,width,-PI,PI));
  rotateX((map(mouseY,0,height,-PI,PI))*(-1));
  
  // origin
  stroke(0,0,0);
  box(25);
  
  // x
  // red
  stroke(255,0,0);
  line(0,0,0,100,0,0);
  
  // y
  // green
  stroke(0,255,0);
  line(0,0,0,0,100,0);
  
  // z
  // blue
  stroke(0,0,255);
  line(0,0,0,0,0,100);
}
Remove all ads

sphere()

sphere()
sphere() \ Language (API) \ Processing 2+

create sphere on center
centerMode

sphere(radius)

size(100,100,P3D);

noStroke();
lights();
translate(width*0.25,height*0.5,0);
sphere(30);

translate(width*0.5,0,0);
sphere(20);
Remove all ads

「建築の形態言語」ウィリアムミチェル

https://images-na.ssl-images-amazon.com/images/I/51S5f8xghHL._SX358_BO1,204,203,200_.jpg



第1章 建築の記述
第2章 建築形態
第3章 デザイン体系
第4章 批評言語
第5章 デザインにおける推論
第6章 タイプとボキャブラリー
第7章 デザイン演算
第8章 建築の形態言語
第9章 機能
第10章 機能的動機を持つデザイン

Remove all ads

processing AR

processing AR

augmented reality
拡張現実 - Wikipedia
Augmented reality - Wikipedia, the free encyclopedia

cf.
セカイカメラ
セカイカメラ - Wikipedia

AR三兄弟
トルク with AR三兄弟
AR三兄弟 - Wikipedia



library
nyar4psg + controlP5
NyAR4psg - NyARToolkit
processing GUI, controlP5

import processing.video.*;
import jp.nyatla.nyar4psg.*;

import controlP5.*;

Capture cam;
MultiMarker nya;

ControlP5 cp5;

int Red = 0;
int Green = 127;
int Blue = 255;

int W = 40;
int H = 40;
int D = 40;

void setup() {
  size(640, 480, P3D);
  colorMode(RGB);
  println(MultiMarker.VERSION);
  
  int ss = 12; // SliderSize
  
  cam=new Capture(this, 640, 480);
  nya=new MultiMarker(this, width, height, "camera_para.dat", NyAR4PsgConfig.CONFIG_PSG);
  nya.addARMarker("patt.hiro", 80);
  cam.start();

  cp5 = new ControlP5(this);
  
  // color slider
  cp5.addSlider("Red").setPosition(20, 20).setSize(256, ss).setRange(0, 255);
  cp5.addSlider("Green").setPosition(20, 35).setSize(256, ss).setRange(0, 255);
  cp5.addSlider("Blue").setPosition(20, 50).setSize(256, ss).setRange(0, 255);
  
  // box slider
  cp5.addSlider("W").setPosition(20,75).setSize(100,ss).setRange(1,200);
  cp5.addSlider("H").setPosition(20,90).setSize(100,ss).setRange(1,200);
  cp5.addSlider("D").setPosition(20,105).setSize(100,ss).setRange(1,200);
  
}

void draw()
{
  if (cam.available() !=true) {
    return;
  }
  cam.read();
  nya.detect(cam);
  background(0);
  nya.drawBackground(cam);
  
  strokeWeight(2);
  stroke(255);
  fill(Red, Green, Blue);
  rect(320,20,42,42);
  
  if ((!nya.isExistMarker(0))) {
    return;
  }
  nya.beginTransform(0);
  stroke(0);
  strokeWeight(1);
  translate(0, 0, D*0.5);
  box(W,H,D);
  nya.endTransform();
}
Remove all ads

box()

box()
box() \ Language (API) \ Processing 2+

create box on center
box width is width
centerMode

size(100,100,P3D);
translate(50,50,0);
rotateY(0);
noFill();

box(40);
box(40,20,50);

fill(255,0,0);
ellipse(0,0,5,5); // red

fill(0,255,0);
ellipse(40,0,5,5); // green
Remove all ads

int() / byte() / float()

int()
int() \ Language (API) \ Processing 2+

convert
primitive datatype to integer

float f = 65.0;
int i = int(f);
println(f+" : " +i);
// console: 65.0 : 65

char c = 'E';
i = int(c);
println(c+ " : " +i);
// console: E : 69


byte()
byte() \ Language (API) \ Processing 2+

convert
primitive datatype to byte

char c = 'E';
byte b = byte(c);
println(c+" : "+b);

int i = 130;
b = byte(i);
println(i+" : "+b);


float()
float() \ Language (API) \ Processing 2+

convert
primitive type to float

int i = 65;
float f = float(i);

println(i+" : "+f);
// console: 65 : 65.0
Remove all ads

sq() / sprt() / pow()

sq()
sq() \ Language (API) \ Processing 2+

squares a number (multiplies a number by itself)
the result is always a positive number
return float

noStroke();

float a = sq(1);
float b = sq(-5);
float c = sq(9);

rect(0,25,a,10);
rect(0,45,b,10);
rect(0,65,c,10);
// rect(startX,startY,width,height)

print(a,b,c);
// console: 1.0, 25.0, 81.0

sqrt()
sqrt() \ Language (API) \ Processing 2+

calculate the square root of number
rerurn float

float a = sqrt(6561);
float b = sqrt(625);
float c = sqrt(1);

rect(0,25,a,10);
rect(0,45,b,10);
rect(0,65,c,10);
// rect(startX,startY,width,height)

print(a,b,c);
// console: 81.0 25.0 1.0


pow()
pow() \ Language (API) \ Processing 2+

function is an efficient way of multiplying numbers
return float

float a = pow(1,3);
// "a" to 1*1*1 = 1

float b = pow(3,5);
// "b" to 3*3*3*3*3 = 243

float c = pow(3,-5);
// "c" to 1 / (3*3*3*3*3) = 1/243 = 0.0041

float d = pow(-3,5);
// "d" to -3*-3*-3*-3*-3 = -243

print(a, b, c, d);
// console: 1.0 243.0 0.004115226 -243.0
Remove all ads

「dust eyes, dust architecture」 dNA

https://images-na.ssl-images-amazon.com/images/I/51E7y%2BhcmzL._SX350_BO1,204,203,200_.jpg


double Negatives Architecture
doubleNegatives Architecture Ltd. | architectural design



Do the limits of the architecture's language mean the limits of the architecture?

00 introduction
01 notation
02 spatial notation
03 retaining dimensions
04 from where to where
05 things that are hard to draw
06 the alien viewpoint
07 smooth compound eyes
08 super eyes
09 subjective / polar coordinates
10 depth to skin
11 the center of the world
12 corpora
13 structure as network of viewpoint
14 flocks
15 autonomy and the problem of quantity
16 augmenting human spatial perception
17 inner viewpoints
18 local decisions
19 condensation
20 life is complex
21 smart dust
22 corpora / site / sight
23 architectual nervous systems
24 reflecting the environment
25 final rendering
26 inheritance
27 freezing / freeing
28 wacthdogs
29 dust eyes

Remove all ads