Jump to content
The Dark Mod Forums

[SOLVED] Quake 3 map support - a fix is required


Recommended Posts

@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 by motorsep
Link to comment
Share on other sites

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 by motorsep
Link to comment
Share on other sites

@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.

  • Like 1
Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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 by motorsep
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...