Difference between revisions of "Wiring"

From Constructive Labs
Jump to navigation Jump to search
Line 49: Line 49:
 
remember this also applies to composites - you can always add stuff to a composite, offset the "satellite" from center and rotate the composite.  then both the planet and the satellite rotate.
 
remember this also applies to composites - you can always add stuff to a composite, offset the "satellite" from center and rotate the composite.  then both the planet and the satellite rotate.
  
 +
===rotation inputs===
 
<code><pre>
 
<code><pre>
@Input(menu = "input/rotation")
+
menu = "input/rotation"
 
@ParmTypes(value = { @ParmType(name = "rotation", defaultValue="0,90,0"), @ParmType(name = "time", defaultValue="1000")})
 
@ParmTypes(value = { @ParmType(name = "rotation", defaultValue="0,90,0"), @ParmType(name = "time", defaultValue="1000")})
 
public void rotateBy(Euler rotation, int time) {
 
public void rotateBy(Euler rotation, int time) {
  if (rotation != null) {
 
    Quat4f r = rotation.toQuat();
 
    r.mul(getRotation().toQuat());
 
    rotateTo(new Euler(r), time);
 
  }
 
}
 
  
@Input(menu = "input/rotation")
+
menu = "input/rotation"
 
@ParmTypes(value = { @ParmType(name = "rotation", defaultValue="90"), @ParmType(name = "time", defaultValue="1000")})
 
@ParmTypes(value = { @ParmType(name = "rotation", defaultValue="90"), @ParmType(name = "time", defaultValue="1000")})
 
public void rotateAroundYAxisBy(float rotation, int time) {
 
public void rotateAroundYAxisBy(float rotation, int time) {
  if (getRotation() != null) {
 
    AngleAxis angleAxis = new AngleAxis();
 
    angleAxis.rkAxis = getRotation().toQuat().yAxis();
 
    angleAxis.rfAngle = rotation * (float)Math.PI / 180;
 
    Quat4f quat = new Quat4f();
 
    quat.fromAxisAngle(angleAxis);
 
    rotateBy(new Euler(quat), time);
 
  }
 
}
 
  
@Override
+
menu="input/rotation"
@Input(menu="input/rotation")
 
 
@ParmTypes(value = { @ParmType(name="rotation", defaultValue="0,0,0")})
 
@ParmTypes(value = { @ParmType(name="rotation", defaultValue="0,0,0")})
 
public void setRotation(Euler rotation) {
 
public void setRotation(Euler rotation) {
  if (node != null) node.changed(PropertySymbols.RotationSymbol);
+
 
    this.rotation = rotation;
 
  }
 
}
 
 
</pre>
 
</pre>
 
</code>
 
</code>

Revision as of 11:09, 26 May 2021

You can go into WIRE mode by choosing the WIRE/CODE menu item

Wiring1.png

When you are in wire mode, you get the wiring diagram for anything you click on, just like with properties.The wiring looks like dark green balls connected by green lines, sort of like a chemistry molecular model.

For example, click on the sphere

Wiring2.png

You see a little wiring diagram (balls and connectors) above the wrist menu. You can drag it around like anything else Hover the ray over it to see a label saying what it is

Wiring3.png

if you ray, click and release with the right controller trigger, that will bring up a menu of items you can use to wire objects together

Parameters:

if a wire is red it needs parameters. but you can't put them inside the wire, you have to get them from another object for now


The + button adds something to the wiring, for example another object: the cube.

Wiring4.png

For example, click on another another object such as the cube and a new ball appears for that object

Wiring5.png

Click on the ball and you can access the messages that object can Output (send). In this case: one of the events: mouseDown.

Wiring6.png

Now we are going to connect that wire to the cube’s input, visibility, toggle. This will make the visibility property of the cube toggle on and off when the sphere is clicked on.

Wiring7.png

Point at the wire to see what it does:

Wiring8.png

Rotation Example

these are the 3 wirable inputs for rotation

If you wanted to rotate a planet around the sun, you could wire to one of these. You will need some parameter nodes of the appropriate type (Euler, float) to wiring to the parameter (ball on the wire). You wire from the parameter to getValue on the parameter node.

remember this also applies to composites - you can always add stuff to a composite, offset the "satellite" from center and rotate the composite. then both the planet and the satellite rotate.

rotation inputs

menu = "input/rotation"
@ParmTypes(value = { @ParmType(name = "rotation", defaultValue="0,90,0"), @ParmType(name = "time", defaultValue="1000")})
public void rotateBy(Euler rotation, int time) {

menu = "input/rotation"
@ParmTypes(value = { @ParmType(name = "rotation", defaultValue="90"), @ParmType(name = "time", defaultValue="1000")})
public void rotateAroundYAxisBy(float rotation, int time) {

menu="input/rotation"
@ParmTypes(value = { @ParmType(name="rotation", defaultValue="0,0,0")})
public void setRotation(Euler rotation) {