-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed camera, for now. Added help menu, and a properties page. Need t…
…o fix it for javascript mode.
- Loading branch information
Showing
10 changed files
with
572 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
void setup () { | ||
size(640, 640, P3D); | ||
} | ||
|
||
|
||
void draw () { | ||
lights (); | ||
background (0); | ||
|
||
camera (30.0, mouseY, 220.0, | ||
0.0, 0.0, 0.0, | ||
0.0, 1.0, 0.0); | ||
|
||
noStroke(); | ||
box(90); | ||
stroke (255); | ||
line(-100, 0, 0, 100, 0, 0); | ||
line(0, -100, 0,0,100,0); | ||
line(0, 0, -100, 0,0,0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
public class Quat { | ||
float w, x, y, z; | ||
|
||
//Default Constructor | ||
public Quat () { | ||
w = 1.0; | ||
x = 0.0; | ||
y = 0.0; | ||
z = 0.0; | ||
} | ||
|
||
public Quat (float w0, x0, y0, z0) { | ||
w = w0; | ||
x = x0; | ||
y = y0; | ||
z = z0; | ||
} | ||
|
||
public Quat add (Quat q) { | ||
float nw = w + q.w; | ||
float nx = x + q.x; | ||
float ny = y + q.y; | ||
float nz = z + q.z; | ||
return new Quat (nw, nx, ny, nz); | ||
} | ||
|
||
public Quat mult (Quat q) { | ||
float nw = w * q.w - (x * q.x + y * q.y + z * q.z); | ||
float nx = w * q.w + x * q.x + y * q.y - z * q.z; | ||
float ny = w * q.w - x * q.x + y * q.y + z * q.z; | ||
float nz = q * q.w + x * q.x - y * q.y + z * q.z; | ||
return new Qua (nw, nx, ny, nz); | ||
} | ||
|
||
public Quat scale (float t) { | ||
float nw = t * q; | ||
float nx = t * x; | ||
float ny = t * y; | ||
float nz = t * z; | ||
return new Quat (nw, ny, nz); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class Console { | ||
int _textSize = 10; | ||
int _bufferSize = 40; | ||
int _xOffset = 20; | ||
int _yOffset = 20; | ||
ArrayList<String> _stringList; | ||
|
||
Console() { | ||
_stringList = new ArrayList<String> (); | ||
} | ||
|
||
void print(String s) { | ||
_stringList.add(s); | ||
} | ||
|
||
void draw() { | ||
pushStyle(); | ||
noStroke(); | ||
fill(0,0,0,150); | ||
rect(0,0,400,_yOffset + (_bufferSize + 1) * _textSize); | ||
fill(30,250,30); | ||
textSize(_textSize); | ||
int index = 0; | ||
int c = 0; | ||
if (_stringList.size() - _bufferSize > 0) { | ||
index = (_stringList.size() - _bufferSize) - 1; | ||
} | ||
while(index < _stringList.size()) { | ||
text(_stringList.get(index), _xOffset, _yOffset + c * _textSize); | ||
index++; | ||
c++; | ||
} | ||
popStyle(); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,49 @@ | ||
class Point { | ||
float _r = 30; | ||
float _x; | ||
float _y; | ||
boolean _isSelected; | ||
|
||
Point(float x0, float y0) { | ||
_x = x0; | ||
_y = y0; | ||
_isSelected = false; | ||
} | ||
|
||
void draw() { | ||
pushStyle(); | ||
stroke(c_pointStroke); | ||
fill((_isSelected) ? c_pointSelect : c_pointDefault); | ||
ellipse(_x, _y, _r, _r); | ||
popStyle(); | ||
} | ||
|
||
boolean isSelectedPoint(float x, float y) { | ||
return (x - _x)*(x - _x) + (y - _y) * (y - _y) < _r * _r; | ||
} | ||
|
||
boolean isSelectedCir(float x, float y, float r) { | ||
return (x - _x)*(x - _x) + (y - _y)*(y - _y) < r * r; | ||
} | ||
|
||
boolean isSelectedRect(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { | ||
int l0 = lineSideTest(x1, y1, x2, y2, _x, _y); | ||
int l1 = lineSideTest(x2, y2, x3, y3, _x, _y); | ||
int l2 = lineSideTest(x3, y3, x4, y4, _x, _y); | ||
int l3 = lineSideTest(x4, y4, x1, y1, _x, _y); | ||
|
||
return (l0 == l1) && (l1 == l2) && (l2 == l3); | ||
} | ||
|
||
void setSelected() { | ||
_isSelected = true; | ||
} | ||
|
||
void setUnSelected() { | ||
_isSelected = false; | ||
} | ||
|
||
void toggleSelected() { | ||
_isSelected = !_isSelected; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
|
||
// Pallete | ||
color c_WHITE = color (255, 255, 255); | ||
color c_BLACK = color (0, 0, 0); | ||
|
||
// Screen Color | ||
color c_background = color (50, 50, 50); | ||
color c_gnoman = color (255, 130, 130); | ||
|
||
// Menu Colors | ||
color c_modeText = c_BLACK; | ||
color c_modeBackground = color (200,200,200,200); | ||
|
||
// Help Colors | ||
color c_helpBackground = color (5,13,22); | ||
color c_helpStroke = c_BLACK; | ||
color c_helpText = c_WHITE; | ||
int i_helpStrokeWidth = 2; | ||
|
||
// Point | ||
color c_pointStroke = c_BLACK; | ||
color c_pointDefault = c_WHITE; | ||
color c_pointSelect = color (100, 255, 100); | ||
|
||
// Help Strings | ||
int i_helpStrings = 8; | ||
String[] s_helpStrings = { | ||
"h: Toggle Help", | ||
"t: Toggle Console", | ||
"f: Scale", | ||
"d: Pan", | ||
"s: Rotate", | ||
"a: Place Points", | ||
"g: Select Point", | ||
"c: Clear Points" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
int lineSideTest (float ax0, float ay0, float ax1, float ay1, float px, float py) { | ||
float val = (ax1 - ax0) * (py - ay0) - (ay1 * ay0) * (px - ax0); | ||
if (val == 0) { | ||
return 0; | ||
} else if (val > 0) { | ||
return 1; | ||
} else { | ||
return -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.