Morning Ali,
I had a look at the code, Nice work!
[look at the edits below before reading on]
I forgot to comment on the triad .. such a thing is hard to do without.
The obvious thing is (1) to display it before you involve the camera. You instantiate a new camera in Setup() and sets it's parameters too (camera(0, 0, 50, 0, 0, 0, 0, 1, 0);) .. maybe this line sets it going. Try draw triade before setting the parameters. ( Recall that I havn't got practical experience in processing. )
Fount his in references:
beginCamera();
camera();
rotateX(-PI/6);
endCamera();
in your 'wishList:
- A tree of the model blocks (possibly separated into regions). I'm thinking this might be useful for showing/hiding blocks and regions (defined in the model file for each column or architrave).
I'll suggest that you group the different blocks for a region and collects these regions in an arraylist. Making a tree is overkill. Take a look at HashMap to see if it's convenient to you.
---------
- I wouldn't mind also having the ability to manipulate block properties using clicking (mainly visibility)
Clicking is no problem ... making the cursor know what is below it is a whole other ball-game. It would probably involve ray-tracing. That's a processor-intensive task. You should save that thought for later and see if there is processor-time for it.
I'll suggest that you use the numeric tastatur/keyboard to tab through the blocks (4&6 for left7right, 8&2 for up/down, 1&9 for in/out). But you'll probably have to start thinking of a sort of interface for the user. You often see two buttons that controls the state of how the cursor is used (one for 'state position' that puts mouse-input into a camera-translate .. and one for 'state-direction' where input goes into camera-rotate). You can start out assigning key-strokes for the 'states' and save the gui-work till later. From own experience: I've used the numeric keys for a controlled 15 deg step rotation of the camera (around the model). And, a 'reset-camera parameters' key for when you get lost in space ;o)
After picking a particular shape/group .. a currentBlock/group object may be handy and redirect the drawing to just do that or turn the rest into a wire-frame presentation (that function may not be available).
... as for the problem in my previous post: Found this in the pVector library:
I commented out the peasy stuff and had a look at the temple
My suggestion of doing a 'block' and copy it is not applicable. And it's not necessary.
About flipping axis .. it could be a question of feeding the right parameters to the camera.
Is it a coincident that you've chosen to draw the blocks in proper order (bottom ones first) .. or does processing take care of the z-buffering (the task in camera-space to reorder the shapes to be drawn with the most distant ones first) ?
--------
I think that you should load 1 model with all its blocks (at time=0).
The next step is to pick one vector (from two vertices in x-z plane) from each block + the direction-vector (assumed to be the original up-vector).
Then, for each iteration of the software-earthquake, you read the same block-vector and direction (without downloading all info).
In each increment the vector-difference (to the previous) may be very small, so it could be worth while to compare it to the vector a time=0. You don't know what direction in the x-z plane it represents (temperary x), but that doesn't matter becourse you only needs the difference.
By normalizing the vector (divide each component with the vector-length) and vector-cross-producting with the direction-vector (assumed to be normalized) you get the last primary axis. Many ways leads to Rome .. which one you choose doesn't matter .. in particular becourse there is no constraint on how many resources you put into it (it's a pre-processing step that should take place before you start drawing anything)
Finally ... the rotation-matrix may be more difficult to construct than I imply. It's probably composed of sums of products of coss and sins. I promise to look into it.
-------- ( looking )----------
This is a good source for rotation scrutiny
I use the chapter 'Rotation Matrix Conventions' as a suggestion to put the 3 unite vectors above right into a matrix (M1). This matrix transforms (1,0,0),(0,1,0),(0,0,1) into the vectors. (it appear conspicuously easy .. did I forget something?).
We did not start out with a reference represented by (1,0,0),(0,1,0),(0,0,1), but one that had already been imposed an angular rotation around up (0,1,0). Ill call it (x1,0,z1),(0,1,0),(x2,0,x2) [= the normalized 'temp x & z'] . If I'm not mistaken, an inverse rotation-matrix is created by transposing the forward matrix.
If we do the trick again .. using the 3 unite vectors (x1,0,z1),(0,1,0),(x2,0,x2) to fill a matrix and transpose it (M2), where are we then?
If v is the arbitrary vector we picked in the x-z plane 'as temporary x' then
v*M2 -> takes you an angle round (0,1,0) to place it in parallel with (1,0,0). *M1 -> takes it from here to it's destination. Here you can translate it with the position-vector and it ought to be HOME, .. right?
M2 and M1 can be matrix-multiplied (watch out for proper order), but keep the position translation to itself and apply it last.