I rotate the left (red) sword 90 degrees, the camera and the other object - right sword (blue) stay stationary, then I rotate the blue sword and the red one also rotates with it. I tried inserting and swapping around the push pop commands, putting them in-between rotations and they didn't seem to do anything.
Code: Select all
plx_mat3d_push();
plx_mat_identity();
plx_mat3d_apply(PLX_MAT_MODELVIEW);
plx_mat_identity();
plx_mat3d_apply_all();
//TRANSFORM RIGHT CONTROLLER
vector_t transformedVertsRightController[76];
plx_mat_transform(sword, transformedVertsRightController, 76, 4 * sizeof(float));
//mat_rotate_x(2.2f);
//rotates left (red) controller
mat_rotate_x(-2.2f);
mat_rotate_y(-2.0f);
//TRANSFORM LEFT CONTROLLER
vector_t transformedVertsLeftController[76];
plx_mat_transform(sword, transformedVertsLeftController, 76, 4 * sizeof(float));
plx_mat3d_pop();
Can't I first rotate the vertex array of the object, then submit it to the matrix?
Code: Select all
// Vertices for the sword
vector_t sword[76] = {
//right edge
{ -0.055163, -3.947190, -0.000000, 1.0f },
{ -0.041008, -3.800521, -0.007942, 1.0f },
{ 0.044857, -3.809751, -0.000000, 1.0f },
{ 0.014696, -3.274535, -0.012691, 1.0f },
{ 0.151422, -2.841005, -0.000000, 1.0f },
{ 0.069818, -2.490783, -0.018990, 1.0f },
{ 0.188623, -2.133870, -0.000000, 1.0f },
{ 0.083189, -1.770629, -0.018990, 1.0f },
{ 0.194529, -1.477070, -0.000000, 1.0f },
{ 0.060419, -1.161509, -0.018990, 1.0f },
{ 0.165813, -0.773039, -0.000000, 1.0f },
{ 0.018869, -0.507682, -0.018990, 1.0f },
{ 0.125755, -0.330209, -0.000000, 1.0f },
{ -0.003405, -0.341672, -0.018990, 1.0f },
//handle
{ 0.173421, -0.289250, -0.000016, 1.0f },
{ -0.056396, 1.036529, -0.000009, 1.0f },
{ -0.063859, -0.311720, -0.000016, 1.0f },
{ -0.269681, 1.001541, -0.000009, 1.0f },
{ -0.000011, -0.305318, -0.054207, 1.0f },
{ -0.213438, 1.022534, -0.045449, 1.0f },
{ 0.115654, -0.295042, -0.054207, 1.0f },
{ -0.111428, 1.034082, -0.045449, 1.0f },
{ -0.000011, -0.305318, 0.053408, 1.0f },
{ -0.213438, 1.022534, 0.044650, 1.0f },
{ 0.115654, -0.295042, 0.053408, 1.0f },
{ -0.111428, 1.034082, 0.044650, 1.0f },
//guard front
// X Z Y blender coordinates
{ -0.156711, -0.356212, 0.000175, 1.0f },
{ -0.003405, -0.341672, -0.018990, 1.0f },
{ -0.156711, -0.356212, 0.000175, 1.0f },
{ -0.156711, -0.356212, 0.000175, 1.0f },
{ -0.045441, -0.345056, 0.093277, 1.0f },
{ -0.003405, -0.341672, -0.018990, 1.0f },
{ 0.156134, -0.327147, 0.093277, 1.0f },
{ 0.125755, -0.330209, -0.000000, 1.0f },
{ 0.256806, -0.317053, 0.000175, 1.0f },
{ 0.156134, -0.327147, -0.094267, 1.0f },
{ 0.125755, -0.330209, -0.000000, 1.0f },
{ 0.156134, -0.327147, -0.094267, 1.0f },
{ -0.003405, -0.341672, 0.018990, 1.0f },
{ -0.045441, -0.345056, -0.094267, 1.0f },
{ -0.156711, -0.356212, 0.000175, 1.0f },
//guard edge 24
// X Z Y blender coordinates
{ 0.256806, -0.317053, 0.000175, 1.0f },
{ 0.152616, -0.292066, 0.093277, 1.0f },
{ 0.156134, -0.327147, 0.093277, 1.0f },
{ -0.045441, -0.345056, -0.094267, 1.0f },
{ 0.152616, -0.292066, -0.094267, 1.0f },
{ -0.048958, -0.309976, 0.093277, 1.0f },
{ -0.048958, -0.309976, 0.093277, 1.0f },
{ -0.045441, -0.345056, -0.094267, 1.0f },
{ -0.156711, -0.356212, 0.000175, 1.0f },
{ -0.048958, -0.309976, 0.093277, 1.0f },
{ -0.160228, -0.321132, 0.000175, 1.0f },
{ -0.156711, -0.356212, 0.000175, 1.0f },
{ -0.160228, -0.321132, 0.000175, 1.0f },
{ -0.048958, -0.309976, -0.094267, 1.0f },
{ -0.156711, -0.356212, 0.000175, 1.0f },
{ -0.045441, -0.345056, 0.093277, 1.0f },
{ -0.048958, -0.309976, -0.094267, 1.0f },
{ -0.045441, -0.345056, 0.093277, 1.0f },
{ 0.152616, -0.292066, 0.093277, 1.0f },
{ 0.156134, -0.327147, -0.094267, 1.0f },
{ 0.156134, -0.327147, -0.094267, 1.0f },
{ 0.152616, -0.292066, 0.093277, 1.0f },
{ 0.256806, -0.317053, 0.000175, 1.0f },
{ 0.253289, -0.281973, 0.000175, 1.0f },
};
//- end of katana geometry
//--------------------------------------------------------------
I know I can use OpenGL but I want to keep the refresh rate as high as possible.
A workaround would be to apply manual math to two of the columns, say if I want to rotate on the X axis I apply cos and sin functions on the angle value and multiply it with the Y and Z columns but it's going to look ugly.
I know this is a VR game, I will drop stereoscopic vision to get higher frame rate. It would be interesting however to know how one would render from 2 cameras at the same time, probably it would cut the frame rate in half literally. I'm guessing it would involve moving the camera position left and right and then combining buffers.
Update:
How do you get a more realistic 3D camera? The parallax one appears to be the equivalent of an 'orthographic' camera in Blender, meaning that regardless whether an object is near or far it's the same size in the frame. The equivalent of this in real life is looking at everything with long telescopic lens.
Code: Select all
plx_mat3d_perspective(60.0f, 640.0f / 480.0f, 0.1f, 100.0f);//60 deg. FOV, aspect ratio, near plane, far plane
Instead of this: I'm getting this: