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

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 3 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...