FLATSPRITE discussion

Advanced OpenGL source port fork from ZDoom, picking up where ZDoomGL left off.
[Home] [Download] [Git builds (Win)] [Git builds (Mac)] [Wiki] [Repo] [Bugs&Suggestions]

Moderator: Graf Zahl

Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: FLATSPRITE discussion

Post by Major Cooke »

Code: Select all

// [Nash] check for special sprite drawing modes
	if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite)
	{
		// Compute center of sprite
		float xcenter = (x1 + x2)*0.5;
		float ycenter = (y1 + y2)*0.5;
		float zcenter = (z1 + z2)*0.5;
		float xx = -xcenter + x;
		float zz = -zcenter + z;
		float yy = -ycenter + y;
		Matrix3x4 mat;
		mat.MakeIdentity();
		mat.Translate(xcenter, zcenter, ycenter); // move to sprite center
I wonder if it might have something to do with this:

Code: Select all

mat.Translate(xcenter, zcenter, ycenter); // move to sprite center
I remember that being an issue so that's why I had to use those untranlate-then-rotate-then-retranslate pieces. Quite fuck ugly, yes.

Code: Select all

				if (useOffsets)	mat.Translate(xx, zz, yy);
				mat.Rotate(yawvecX, 0, yawvecY, rollDegrees);
				if (useOffsets) mat.Translate(-xx, -zz, -yy);
But if wall sprites work perfectly, then I guess it's... okay?
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: FLATSPRITE discussion

Post by Graf Zahl »

The main problem here is that flat sprite started from the wrong place. To do them right they need to start as flat sprites, not as wall sprites.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: FLATSPRITE discussion

Post by Major Cooke »

You can keep up on progress here.

I've messaged Torr Samaho on the matter. Hopefully he can help provide some insight.

Code: Select all

Actor A
{
	+NOINTERACTION
	+ROLLSPRITE
	+FLATSPRITE
	+DONTFLIP
	+ROLLCENTER
	States
	{
	Spawn:
		HEAD A 1 
		{
			pitch = (pitch + 2) % 360;
			//roll += 4;
			
			if (abs(pitch) % 90 == 0)
			{	A_LogInt(pitch);	}
		}
		Loop
	}
}
User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Re: FLATSPRITE discussion

Post by Nash »

No offense but why don't you give Graf Zahl some space? He didn't say he's not interested; he DID say he'll figure something out after the official release... he already expressed his discomfort in you nagging him. Why not just let him take care of it, since he's the one who's maintaining the engine. It looks to me he has a few ideas, he just needs time to do it.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: FLATSPRITE discussion

Post by Major Cooke »

Graf Zahl wrote:The new implementation should support rotation along all three axes. What I cannot guarantee is that you may have to make adjustments.
If this doesn't shout "Give it a try, it's a good learning lesson for you" while he has things to do, then I don't know what else it is.

Plus, it's my mess, my responsibility. I should at least make an effort to make it right again.

And, again, I didn't nag. I reminded him since he forgot about it.
User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Re: FLATSPRITE discussion

Post by Nash »

Okay... don't get me wrong. I understand you want the feature, as do I (my game uses lots of flat sprites too). I just get nervous when I see all this over-enthusiastic behavior going around. My impression is that Graf will take care of it after the release, and I trust he'll take care of it based on what he's been writing around here.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: FLATSPRITE discussion

Post by Major Cooke »

My desire right now is not so much the feature, but to fix the shitpile I left on his doorstep. Not fair to him as it was my mess to begin with. I feel I owe it to him for all the hell he goes through to deal with my crap.

Plus the fix itself isn't as bad as I thought it would be. I need to assign the correct xyz1/2 points for positioning the plane appropriately and with the correct algorithms, taking angle and pitch into account.
User avatar
Rachael
Developer
Developer
Posts: 3646
Joined: Sat May 13, 2006 10:30

Re: FLATSPRITE discussion

Post by Rachael »

MC - I think you know as well as I do if Graf was truly upset with you there would be no discussion. This thread would've been locked and tossed into nether space shortly after it appeared. Yet, he's clearly shown he's willing to work with you - and he even suggested for you a starting point. Focus on that.

This issue, as far as Graf, I, or anyone else is concerned, is ancient history now. You have a lot more time to redo it and do it right the second time. When it's ready, post another pull request. All good things take time.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: FLATSPRITE discussion

Post by Major Cooke »

Agreed. And this, Nash, is why I'm working on it as we speak.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: FLATSPRITE discussion

Post by Major Cooke »

So I have pitch working, but I think I may need to rely upon the rotation matrix in order to turn the sprites about.

I can rotate the sprite about on the X/Z axis well enough but trying to include the angle is not providing any significant results.

https://github.com/MajorCooke/GZDoom/co ... cd2098936d
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: FLATSPRITE discussion

Post by Graf Zahl »

Using the matrix is not a problem. I would have done that myself. But it all needs to start from the right values.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: FLATSPRITE discussion

Post by Major Cooke »

Alright so I did a bit of toying around. Here's the issue I kept encountering...

The sprite only wants to rotate along one axis, period. While I managed to get it to properly rotate with the pitch, it will never ever turn with angle, no matter what I tried. It just couldn't be rotated. I tried doing just a couple simple changes and all it did was just move the sprite instead of rotate it.

This was using matrices and/or just modifying the x/y/z directly.

So indeed I probably am doing something wrong here...

Code: Select all

					v[0] = FVector3(x1, z2, y1);
					v[1] = FVector3(x1, z2, y2);
					v[2] = FVector3(x2, z1, y1);
					v[3] = FVector3(x2, z1, y2);
While I understand that the x1, x2, y1, y2, z1 and z2 values are basically responsible for the dimensional scaling of the actor's sprite, I wish there was an easier way to rotate them.
User avatar
Rachael
Developer
Developer
Posts: 3646
Joined: Sat May 13, 2006 10:30

Re: FLATSPRITE discussion

Post by Rachael »

What are you doing to rotate them? Have you read some appropriate documentation on the subject?

Generally the formula for rotations is X=X*cos(ang)+Y*sin(ang), Y=X*sin(ang)-Y*cos(ang) - or something like that, it's been a while since I've done it. (The formula always works as long as you reverse sine and cosine in X and Y and one must be negative - just play around with the signs and order a bit and you'll get the correct angles).

Also you have to use a "rotation order" - it's usually Face->Pitch->Roll (roll is done last because it is the least significant rotation). For each axis your X and Y changes to a different axis - depending on the axis system being used. (And I have never read enough about GZDoom code to know which axis is vertical - I am guessing it's Y from the lingo most people use but I don't know). You may or may not have to reverse the order in order to tessellate the object properly on the screen.
User avatar
Gez
Developer
Developer
Posts: 1399
Joined: Mon Oct 22, 2007 16:47

Re: FLATSPRITE discussion

Post by Gez »

Keep in mind that after you rotate something 90° on one of its axes, the frame of reference is changed. E.g., take a character standing up. Now rotate this character 90° on the yaw angle, the character is laying on its flank. Now rotate the character's pitch 90° and the character rotates face first. If the yaw had not changed, the character would then be laying face down on the ground, but since you first changed the yaw the character merely rotated on the floor -- like if you had changed the angle instead of the pitch.

And it is possible to get a gimbal lock: a series of rotation makes it so that rotating on one of the axes is no longer possible (without first undoing a rotation on another axis).

PS: Why do you delete posts and rewrite them instead of just editing them? This thread is full of ghost posts.
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: FLATSPRITE discussion

Post by Graf Zahl »

To be honest, I do not even think that roll has much use for flat sprites. It's almost inevitable that it will rotate along the same axis as yaw in any situation where there's no pitch. Anything else would not make much sense logically.
Locked

Return to “GZDoom”