A
Akari
Guest
Could someone post source of programm that load camera matrix. I get confused with it.
I believe this was discused when the walk map was being worked on in technical no?Could someone post source of programm that load camera matrix. I get confused with it.
I found description of sector 2 in this post https://www.ff7catalog.com/threads/1832/ as well as Kero programm that loads it. I has problems with signs of vectors... and maybe with something else. Just looking at code that loads this thing makes things much more clear.I believe this was discused when the walk map was being worked on in technical no?Could someone post source of programm that load camera matrix. I get confused with it.
Camera and walkmesh via Reunion
It doesn't seem to be there anymore (sigh) there was a huge long thing on the walk mesh information. Someone had a nice viewer for it (unless that was you Akari)
cFieldCam.vy.x = -cFieldCam.vy.x;cFieldCam.vy.y = -cFieldCam.vy.y;cFieldCam.vy.z = -cFieldCam.vy.z;cFieldCam.oy = -cFieldCam.oy;cFieldCam.vx.x /= 4096.0f; cFieldCam.vx.y /= 4096.0f; cFieldCam.vx.z /= 4096.0f;cFieldCam.vy.x /= 4096.0f; cFieldCam.vy.y /= 4096.0f; cFieldCam.vy.z /= 4096.0f;cFieldCam.vz.x /= 4096.0f; cFieldCam.vz.y /= 4096.0f; cFieldCam.vz.z /= 4096.0f;tx = -(cFieldCam.ox*cFieldCam.vx.x + cFieldCam.oy*cFieldCam.vy.x + cFieldCam.oz*cFieldCam.vz.x);ty = -(cFieldCam.ox*cFieldCam.vx.y + cFieldCam.oy*cFieldCam.vy.y + cFieldCam.oz*cFieldCam.vz.y);tz = -(cFieldCam.ox*cFieldCam.vx.z + cFieldCam.oy*cFieldCam.vy.z + cFieldCam.oz*cFieldCam.vz.z);
glScalef(-1.0, 1.0, 1.0);gluLookAt(tx, tz, ty, cFieldCam.vz.x, cFieldCam.vz.y, cFieldCam.vz.z, 0.0, 1.0, 0.0);
voidDatFile::GetWalkMesh(TotalGeometry &walkmesh){ u32 offset_to_walkmesh = 0x1C + GetU32LE(0x04) - GetU32LE(0x00); Geometry geometry; geometry.TexEnabled = false; u32 number_of_poly = GetU32LE(offset_to_walkmesh); int start = offset_to_walkmesh + 0x04; for (u32 i = 0; i < number_of_poly; ++i) { Vertex v[3]; v[0].p.x = -static_cast<s16>(GetU16LE(start + 0x00)); v[0].p.z = static_cast<s16>(GetU16LE(start + 0x02)); v[0].p.y = static_cast<s16>(GetU16LE(start + 0x04)); v[0].c.r = 1.0f; v[0].c.g = 0.0f; v[0].c.b = 0.0f; v[0].c.a = 1.0f; v[1].p.x = -static_cast<s16>(GetU16LE(start + 0x08)); v[1].p.z = static_cast<s16>(GetU16LE(start + 0x0A)); v[1].p.y = static_cast<s16>(GetU16LE(start + 0x0C)); v[1].c.r = 1.0f; v[1].c.g = 0.0f; v[1].c.b = 0.0f; v[1].c.a = 1.0f; v[2].p.x = -static_cast<s16>(GetU16LE(start + 0x10)); v[2].p.z = static_cast<s16>(GetU16LE(start + 0x12)); v[2].p.y = static_cast<s16>(GetU16LE(start + 0x14)); v[2].c.r = 1.0f; v[2].c.g = 0.0f; v[2].c.b = 0.0f; v[2].c.a = 1.0f; geometry.AddTriangle(v); // go to the next triangle start += 0x18; } walkmesh.GeometryVector.push_back(geometry);}
voidDatFile::GetCameraMatrix(Matrix &camera){ u32 offset_to_camera = 0x1C + GetU32LE(0x0C) - GetU32LE(0x00); // get camera matrix (3 vectors) float vxx = static_cast<float>( static_cast<s16>(GetU16LE(offset_to_camera + 0x00))) / 4096.0f; float vxy = static_cast<float>( static_cast<s16>(GetU16LE(offset_to_camera + 0x04))) / 4096.0f; float vxz = static_cast<float>( static_cast<s16>(GetU16LE(offset_to_camera + 0x02))) / 4096.0f; float vyx = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x06))) / 4096.0f; float vyy = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x0A))) / 4096.0f; float vyz = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x08))) / 4096.0f; float vzx = static_cast<float>( static_cast<s16>(GetU16LE(offset_to_camera + 0x0C))) / 4096.0f; float vzy = static_cast<float>( static_cast<s16>(GetU16LE(offset_to_camera + 0x10))) / 4096.0f; float vzz = static_cast<float>( static_cast<s16>(GetU16LE(offset_to_camera + 0x0E))) / 4096.0f; Matrix mat(vxx, vyx, vzx, 0, vxy, vyy, vzy, 0, vxz, vyz, vzz, 0, 0, 0, 0, 1); // get camera position in world s16 ox = static_cast<s16>(GetU16LE(offset_to_camera + 0x14)); s16 oy = -static_cast<s16>(GetU16LE(offset_to_camera + 0x16)); s16 oz = static_cast<s16>(GetU16LE(offset_to_camera + 0x18)); float tx = -(ox * vxx + oy * vyx + oz * vzx); float ty = -(ox * vxy + oy * vyy + oz * vzy); float tz = -(ox * vxz + oy * vyz + oz * vzz);// Matrix mat2;// MatrixTranslation(mat2, -tx, -ty, -tz);// printf("%f %f %f", tx, ty, tz);// MatrixMultiply(camera, mat, mat2); camera = LookAt(tx, ty, tz, vzx, vzy, vzz, 0, 1, 0);}
template <class type>struct WalkVertex{ type x, z, y, r; };template <class type>struct Camera{ Vertex<type> vx, vy, vz; S16 repeat; S32 ox, oy, oz; S32 blank; S16 size;};...struct FF_CAMERA{ U32 nSectionLength; Camera<short> cCamera; // Repeat data - this is not always here so read section length first to ascertain how much to read in! S32 unknown1; Camera<short> cRepeatCamera;};...struct FF_WALKMESH{ U32 nSectionLength; U32 nSectors; vector< WalkVertex<S16> > cVertexList; vector<U16> cEdgeList;};
// * SECTION TWO: Camera; get section length first as it varies in.seekg(cMemory->sHeader.pSections[1], ifstream::beg); in.read((char *)&cMemory->s2, sizeof(U32)); // - Now read in section based on section length, not struct size in.seekg(cMemory->sHeader.pSections[1], ifstream::beg); in.read((char *)&cMemory->s2, cMemory->s2.nSectionLength+4);... // * SECTION FIVE: Walkmesh in.seekg(cMemory->sHeader.pSections[4], ifstream::beg); in.read((char *)&cMemory->s5, 8); // - Vertex list WalkVertex<S16> cVert; for(int i = 0; i < (int)cMemory->s5.nSectors * 3; i++) { in.read((char *)&cVert, sizeof(WalkVertex<S16>)); cMemory->s5.cVertexList.push_back(cVert); } // - Edges list U16 cAccess; for(int i = 0; i < (int)cMemory->s5.nSectors * 3; i++) { in.read((char *)&cAccess, sizeof(U16)); cMemory->s5.cEdgeList.push_back(cAccess); }
XYZ vectors are normalized vectors that sets camera position. Z vector set direction, but not the point in worldspace.Akari: isn't that sort of the point, that where the camera is pointing is down the z-axis - into the world? In which case the point where you want the camera to "look at" is anywhere along the z-axis? If the camera wasn't pointing at any point down the z-axis then surely the camera z-axis itself would be incorrect.
Best. Post. Ever.l'm on PSP
Hard to type.
look at fieldscript. May contain SCR2* and other camera opcodes.
Sony! why no keyboard on PSP?
Ahah! Nice one, good thinking Batman. Debug rooms... fair enough, but their walkmeshes aren't that interestingit is position before camera swoops down during opening movie.
Is that the part of the game right before sector 7 collapses? It seems to me that since it switches to an entirely different field for the top, it doesn't matter as long as there's a warp to that field. Unless I'm misunderstanding your point, then ignore me...also the number of stairs on the mesh does not match the background image.
Actually it's post Sector 7's demise because its from the Shinra building stair climb from heck.Do you have a DS? Opera DS is coming out in Japan this month, and the touchscreen makes a much better keyboard than buttons and a D-pad.
Is that the part of the game right before sector 7 collapses? It seems to me that since it switches to an entirely different field for the top, it doesn't matter as long as there's a warp to that field. Unless I'm misunderstanding your point, then ignore me...also the number of stairs on the mesh does not match the background image.![]()
voidDatFile::GetCameraMatrix(Matrix &camera){ u32 offset_to_camera = 0x1C + GetU32LE(0x0C) - GetU32LE(0x00); // get camera matrix (3 vectors) float vxx = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x00))) / 4096.0f; float vxy = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x04))) / 4096.0f; float vxz = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x02))) / 4096.0f; float vyx = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x06))) / 4096.0f; float vyy = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x0A))) / 4096.0f; float vyz = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x08))) / 4096.0f; float vzx = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x0C))) / 4096.0f; float vzy = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x10))) / 4096.0f; float vzz = static_cast<float>(-static_cast<s16>(GetU16LE(offset_to_camera + 0x0E))) / 4096.0f; // get camera position in world s32 ox = -static_cast<s32>(GetU32LE(offset_to_camera + 0x14)); s32 oy = -static_cast<s32>(GetU32LE(offset_to_camera + 0x18)); s32 oz = -static_cast<s32>(GetU32LE(offset_to_camera + 0x1C)); float tx = -(ox * vxx + oy * vyx + oz * vzx); float ty = -(ox * vxy + oy * vyy + oz * vzy); float tz = -(ox * vxz + oy * vyz + oz * vzz); Matrix mat(-vxx, vyx, vzx, 0, -vxy, vyy, vzy, 0, -vxz, vyz, vzz, 0, 0, 0, 0, 1); Matrix mat2; MatrixTranslation(mat2, -tx, -ty, -tz); MatrixMultiply(camera, mat, mat2);}