motorsep 36 Posted July 30, 2015 Report Share Posted July 30, 2015 (edited) @OrbWeaver: DR has support for Quake 3 map format and it works wonderfully, except that Quake 3 doesn't support "rotation" matrix on entities. Instead it has "angles" "Y Z X" spawnarg.I am wondering if you can add conversion from Doom 3 "rotation" matrix into "angles" "Y Z X" when map is being saved into Quake 3 format. I am pretty positive DR converts angles into matrix, so angles should be naturally available. To avoid messing with back and forth conversion, I am thinking writing "angles" spawnarg should be done along with "rotation" spawnarg. This way there would be no need to update any code pertaining to displaying entities with correct angles nor converting "angles" into "rotation" when loading Quake 3 maps made in DR. There is no need to update "angles" spawnargs in real-time either. Simply set new values to "angles" spawnarg when saving of the map is happening. Could you please fix it? Thanks beforehand. Edited August 6, 2015 by motorsep Quote Link to post Share on other sites
motorsep 36 Posted July 31, 2015 Author Report Share Posted July 31, 2015 (edited) I think I found what's needed to get this working, but I don't know programming well enough to implement it :/ This would get us angles: vector3 eulerRad = getEulerAnglesXYZ(); And this would give us degrees for each axis: float angX = radians_to_degrees(eulerRad.x()) float angY = radians_to_degrees(eulerRad.y()) float angZ = radians_to_degrees(eulerRad.z()) And in Doom3Group.cpp, EclassModel.cpp and GenericEntity.cpp we need to add that stuff. And I think in rotation.h is where DR writes entity's rotation spawnarg (so "angles" would be added there, I think). Edited July 31, 2015 by motorsep Quote Link to post Share on other sites
OrbWeaver 637 Posted July 31, 2015 Report Share Posted July 31, 2015 @OrbWeaver: Could you please fix it? Thanks beforehand. Sorry, but that's probably not going to happen in the short term. I have very little time to work on DR these days and any time I did spend would be focussed on issues that are critical for the Dark Mod, rather than improving support for third-party games that I don't play. However if you can persuade one of your programmers to fix the issue and send a pull request I can probably find the time to merge it. 1 Quote DarkRadiant homepage ⋄ DarkRadiant user guide ⋄ OrbWeaver's Dark Ambients ⋄ Blender export scripts Link to post Share on other sites
motorsep 36 Posted July 31, 2015 Author Report Share Posted July 31, 2015 Aye, apparently you and greebo were the only two folks to work on DR :/ Can you please tell me if I am going in the right direction with the code ? Quote Link to post Share on other sites
OrbWeaver 637 Posted July 31, 2015 Report Share Posted July 31, 2015 Can you please tell me if I am going in the right direction with the code ? I'm not overly familiar with that part of the code, but what you have posted so far does seem logical and the Q3 parts of the GtkRadiant codebase should be pretty mature. But I think the only way to confirm that it is doing what you need is to test it in your game. I suggest the first thing to do is get at least someone in your team set up to produce Windows DR builds from the Git sources. This will be useful because even if I were to miraculously fix the issue myself, I wouldn't have any way to provide a new Windows build for testing (but maybe you are all on Linux only and this isn't an issue). Quote DarkRadiant homepage ⋄ DarkRadiant user guide ⋄ OrbWeaver's Dark Ambients ⋄ Blender export scripts Link to post Share on other sites
motorsep 36 Posted July 31, 2015 Author Report Share Posted July 31, 2015 Last time I tried to build DR 2.0.2 I managed to build it successfully. I'll try building master after work and see if it builds. Quote Link to post Share on other sites
motorsep 36 Posted August 2, 2015 Author Report Share Posted August 2, 2015 (edited) I managed to compile master with no errors, but it crashes on launch. Will try compiling 2.0.2 tomorrow and see if that runs. EDIT: Never mind, I managed to build master with MSVC2013 Community Edition (32bit for now). Edited August 2, 2015 by motorsep Quote Link to post Share on other sites
motorsep 36 Posted August 6, 2015 Author Report Share Posted August 6, 2015 (edited) Problem solved! (with help of one of the guys who works with me) In rotation.h in the following function : void write(Entity* entity, bool isModel = false) const add Vector3 euler = m_rotation.getMatrix4().getEulerAnglesXYZDegrees(); at the beginning of the function. Then comment out the same line inside if (!isModel) { and add std::string keyVal2 = std::to_string( euler[1] ) + ' ' + std::to_string( euler[2] ) + ' ' + std::to_string( euler[0] ); entity->setKeyValue( "angles", keyVal2 ); after entity->setKeyValue("rotation", keyVal); at the end of the function. Done! Full code: void write(Entity* entity, bool isModel = false) const { Vector3 euler = m_rotation.getMatrix4().getEulerAnglesXYZDegrees(); // greebo: Prevent the "angle" key from being used for models, they should always // have a rotation matrix written to their spawnargs. This should fix // the models hopping around after transforms if (!isModel) { //Vector3 euler = m_rotation.getMatrix4().getEulerAnglesXYZDegrees(); if (euler[0] == 0 && euler[1] == 0) { entity->setKeyValue("rotation", ""); write_angle(euler[2], entity); return; } // Non-z-rotations will fall through here } // The below call to reset the "angle" keyvalue will // trigger callbacks and reset this matrix. std::string keyVal = m_rotation.getRotationKeyValue(); entity->setKeyValue("angle", ""); // This call will usually update the m_rotation member again entity->setKeyValue("rotation", keyVal); // motorsep 08-05-2015; writing Quake 3 "angles" std::string keyVal2 = std::to_string( euler[1] ) + ' ' + std::to_string( euler[2] ) + ' ' + std::to_string( euler[0] ); entity->setKeyValue( "angles", keyVal2 ); // motorsep ends } P.S. I haven't worked with Git, so I don't really have time to mess with it to create pull request, sorry. Edited August 6, 2015 by motorsep Quote Link to post Share on other sites
OrbWeaver 637 Posted August 6, 2015 Report Share Posted August 6, 2015 Good job. I'll certainly consider merging this change, although I'll want to add some additional code to ensure that the new behaviour only applies in games that require it, probably via a setting in the .game file. Do you know if Quake 3 ONLY requires the "angles" key, or does it need "rotation" as well? Quote DarkRadiant homepage ⋄ DarkRadiant user guide ⋄ OrbWeaver's Dark Ambients ⋄ Blender export scripts Link to post Share on other sites
motorsep 36 Posted August 6, 2015 Author Report Share Posted August 6, 2015 I was thinking of having a check for the game type to be Quake 3 (in the .game file) but decided against it, since having "angles" in Doom 3 maps does no harm, and hopefully eventually Dark places engine (and maybe even ioquake3) and q3map2 compiler will support Doom 3's rotation matrix. Right now Quake 3 and engines that support Quake 3 maps/content (Darkplaces engine for example) only support "angles" for func_statics and "angle" for entities like info_player_start (rotation around Z axis as I recall). Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.