Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → My Ineptitude Never Fails
My Ineptitude Never Fails
2005-07-10, 10:56 AM #1
I can't even set up a freaking cog correctly. :mad:

If you recall my Basilica JKA level, which is 99.9% finished, all I want to do now is add some lion head 3DOs with transparency. Zagibu gave me a cog on my thread over here to prevent z-fighting - http://forums.massassi.net/vb/showthread.php?s=&postid=492949#post489128 but I don't know how to set it up correctly. The methods I've tried have made zilch difference.

Just for your information, my 3DO is not completely flat, but actually has a width of 0.005, I used the blocks light flag, and it looks fine up until about 1.5-2.0 JKUs away, and then it starts to blur from z-fighting.

I was just wondering how Zagibu set up this cog. I apologize for the simplicity of the matter. If I get this worked out, my level is ready for one final BETA release on the hub, and then it can be entered in the JKA Level Pack hopefully. :)
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-07-10, 11:45 AM #2
I'm sorry, I completely forgot about this one.
Here is a new version of the cog. It should work with the default values, but you might want to adjust them, so that the change is not too obvious. I've included some Print() statements, to help you see better what exactly is happening. Just comment them out or delete them for the final version:
Code:
flags=0x240

symbols

thing		player			local
thing		decor0=-1
thing		decor1=-1
thing		decor2=-1
thing		decor3=-1
thing		decor4=-1
thing		decor5=-1
thing		decor6=-1
thing		decor7=-1
thing		decor8=-1
thing		decor9=-1

vector		player_relative		local

float		min_angle=0.1		desc=Minimum dot product result between player and object that triggers offset of object
float		distance=0.05		desc=Offset from wall in JKU's that prevents Z-fighting
float		cur_dist0=0		local
float		cur_dist1=0		local
float		cur_dist2=0		local
float		cur_dist3=0		local
float		cur_dist4=0		local
float		cur_dist5=0		local
float		cur_dist6=0		local
float		cur_dist7=0		local
float		cur_dist8=0		local
float		cur_dist9=0		local
float		curr_angle		local
float		min_dist=5		desc=This distance should be set minimally lower than the distance when zfighting appears

int		i			local

message		startup
message		pulse

end

code

startup:
	Sleep(1);
	player = GetLocalPlayerThing();
	SetPulse(0.2);
	Return;

pulse:
	// Check all decor objects
	for(i = 0; i < 10; i = i + 1)
	{
		object = decor0;
		// Handle only valid objects
		if(object != -1)
		{
			object_pos = GetThingPos(object);
			object_look = GetThingLVec(object);
			player_relative = VectorNorm(VectorSub(GetThingPos(player), object_pos));
			curr_angle = VectorDot(object_look, player_relative);
			// Check player's angle to current object (dot product)
			if(curr_angle > min_angle * 2)
			{
				// Player is in front of object
				Print("In front");

				// Check player's distance to object
				if(VectorDist(GetThingPos(player), object_pos) > min_dist)
				{
					Print("Dist >");
					if(cur_dist0 == 0)
					{
						Print("Moved forth");
						SetThingPos(object, VectorAdd(object_pos, VectorScale(object_look, distance)));
						cur_dist0 = 1;
					}
				}
				else
				{
					Print("Dist <");
					if(cur_dist0 == 1)
					{
						Print("Moved back");
						SetThingPos(object, VectorSub(object_pos, VectorScale(object_look, distance)));
						cur_dist0 = 0;
					}
				}
			}
			else if(curr_angle < min_angle)
			{
				// Player is at side of object
				Print("At side");

				if(cur_dist0 == 1)
				{
					Print("Moved back");
					SetThingPos(object, VectorSub(object_pos, VectorScale(object_look, distance)));
					cur_dist0 = 0;
				}
			}
		}
	}
	Return;

end

I've also attached a sample level that demonstrates the process with a door.
Attachment: 5959/zfight.zip (8,900 bytes)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-07-10, 1:16 PM #3
Thankyou, I will try it out after I've walked my dogs! ;)
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-07-10, 2:02 PM #4
I've found a problem, but I think I might know what's causing it.

From a distance, the object does not move when I am straight in front of and still experiences z-fighting. But after I tweaked the values, and moved away from the object while facing it's left side, it moved left to right, instead of forwards and backwards.

I'm guessing this was caused by the cog moving the object based on it's YAW setting, but I have to face the object that way in JED for the lion head to face the player and align parrallel to the wall. It would be a pain to have to make 4 different lion head 3dos for each wall. Could you add a setting to the cog that specifies a vector for which direction the lion head should be facing in relation to it's movement caused by the player?

At least, I think this is the problem.
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-07-10, 11:29 PM #5
Yeah, that should be possible. I might whip something up during the day, but I can't check for another 10 hours...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-07-11, 1:23 AM #6
Ok, that should work. You have to define a vector for each decor thing, that points away from the wall. This vector is then normalized and compared with the player's position.
Code:
flags=0x240

symbols

thing		player			local
thing		object			local
thing		decor0=-1		desc=A thing that causes z-fighting
thing		decor1=-1		desc=A thing that causes z-fighting
thing		decor2=-1		desc=A thing that causes z-fighting
thing		decor3=-1		desc=A thing that causes z-fighting
thing		decor4=-1		desc=A thing that causes z-fighting
thing		decor5=-1		desc=A thing that causes z-fighting
thing		decor6=-1		desc=A thing that causes z-fighting
thing		decor7=-1		desc=A thing that causes z-fighting
thing		decor8=-1		desc=A thing that causes z-fighting
thing		decor9=-1		desc=A thing that causes z-fighting

vector		player_relative		local
vector		object_pos		local
vector		object_look		local
vector		object_orient0		desc=Vector that points away from the wall
vector		object_orient1		desc=Vector that points away from the wall
vector		object_orient2		desc=Vector that points away from the wall
vector		object_orient3		desc=Vector that points away from the wall
vector		object_orient4		desc=Vector that points away from the wall
vector		object_orient5		desc=Vector that points away from the wall
vector		object_orient6		desc=Vector that points away from the wall
vector		object_orient7		desc=Vector that points away from the wall
vector		object_orient8		desc=Vector that points away from the wall
vector		object_orient9		desc=Vector that points away from the wall

float		min_angle=0.1		desc=Minimum dot product result between player and object that triggers offset of object
float		distance=0.05		desc=Offset from wall in JKU's that prevents Z-fighting
float		cur_dist0=0		local
float		cur_dist1=0		local
float		cur_dist2=0		local
float		cur_dist3=0		local
float		cur_dist4=0		local
float		cur_dist5=0		local
float		cur_dist6=0		local
float		cur_dist7=0		local
float		cur_dist8=0		local
float		cur_dist9=0		local
float		curr_angle		local
float		min_dist=5		desc=This distance should be set minimally lower than the distance when zfighting appears

int		i			local

message		startup
message		pulse

end

code

startup:
	Sleep(1);
	player = GetLocalPlayerThing();
	SetPulse(0.2);
	Return;

pulse:
	// Check all decor objects
	for(i = 0; i < 10; i = i + 1)
	{
		object = decor0;
		// Handle only valid objects
		if(object != -1)
		{
			object_pos = GetThingPos(object);
			object_look = object_orient0;
			player_relative = VectorNorm(VectorSub(GetThingPos(player), object_pos));
			curr_angle = VectorDot(object_look, player_relative);
			// Check player's angle to current object (dot product)
			if(curr_angle > min_angle * 2)
			{
				// Player is in front of object
				Print("In front");

				// Check player's distance to object
				if(VectorDist(GetThingPos(player), object_pos) > min_dist)
				{
					Print("Dist >");
					if(cur_dist0 == 0)
					{
						Print("Moved forth");
						SetThingPos(object, VectorAdd(object_pos, VectorScale(object_look, distance)));
						cur_dist0 = 1;
					}
				}
				else
				{
					Print("Dist <");
					if(cur_dist0 == 1)
					{
						Print("Moved back");
						SetThingPos(object, VectorSub(object_pos, VectorScale(object_look, distance)));
						cur_dist0 = 0;
					}
				}
			}
			else if(curr_angle < min_angle)
			{
				// Player is at side of object
				Print("At side");

				if(cur_dist0 == 1)
				{
					Print("Moved back");
					SetThingPos(object, VectorSub(object_pos, VectorScale(object_look, distance)));
					cur_dist0 = 0;
				}
			}
		}
	}
	Return;

end

This is untested, though.

Tell me if you have irregular walls and troubles defining vectors for them.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-07-11, 11:10 AM #7
I still can't get it to work.

Here's a picture to illustrate how I set it up. The red circle is around the lion head statue, which I set to a vector of (1.00/0.00/0.00), which should be facing towards the player in the direction the arrow is pointing.

The orange blob is about where the z-fighting starts to occur. I've tweaked the min_distance values with anything as small as 0.3 or as high as 2. Nothing happens. With the previous cog, the lion was moving in the wrong direction, but now the lion no longer moves at all.

I might be setting this up incorrectly, but since you said you haven't tested this cog yet, it might be a problem there. Any ideas?
Attachment: 5989/hom.jpg (24,291 bytes)
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-07-11, 12:33 PM #8
Meh, you could at least have told me what the output's were. Anyway, this version should work. Don't forget that you have to define vectors in the form of (0/1/0) in JED.
Code:
flags=0x240

symbols

thing		player			local
thing		object			local
thing		decor0=-1		desc=A thing that causes z-fighting
thing		decor1=-1		desc=A thing that causes z-fighting
thing		decor2=-1		desc=A thing that causes z-fighting
thing		decor3=-1		desc=A thing that causes z-fighting
thing		decor4=-1		desc=A thing that causes z-fighting
thing		decor5=-1		desc=A thing that causes z-fighting
thing		decor6=-1		desc=A thing that causes z-fighting
thing		decor7=-1		desc=A thing that causes z-fighting
thing		decor8=-1		desc=A thing that causes z-fighting
thing		decor9=-1		desc=A thing that causes z-fighting

vector		player_relative		local
vector		object_pos		local
vector		object_look		local
vector		object_orient0		desc=Vector that points away from the wall
vector		object_orient1		desc=Vector that points away from the wall
vector		object_orient2		desc=Vector that points away from the wall
vector		object_orient3		desc=Vector that points away from the wall
vector		object_orient4		desc=Vector that points away from the wall
vector		object_orient5		desc=Vector that points away from the wall
vector		object_orient6		desc=Vector that points away from the wall
vector		object_orient7		desc=Vector that points away from the wall
vector		object_orient8		desc=Vector that points away from the wall
vector		object_orient9		desc=Vector that points away from the wall

float		min_angle=0.1		desc=Minimum dot product result between player and object that triggers offset of object
float		distance=0.05		desc=Offset from wall in JKU's that prevents Z-fighting
float		cur_dist0=0		local
float		cur_dist1=0		local
float		cur_dist2=0		local
float		cur_dist3=0		local
float		cur_dist4=0		local
float		cur_dist5=0		local
float		cur_dist6=0		local
float		cur_dist7=0		local
float		cur_dist8=0		local
float		cur_dist9=0		local
float		curr_angle		local
float		min_dist=2		desc=This distance should be set minimally lower than the distance when zfighting appears
float		dist_temp		local

int		i			local

message		startup
message		pulse

end

code

startup:
	Sleep(1);
	player = GetLocalPlayerThing();
	SetPulse(0.2);
	Return;

pulse:
	// Check all decor objects
	for(i = 0; i < 10; i = i + 1)
	{
		object = decor0;
		// Handle only valid objects
		if(object != -1)
		{
			object_pos = GetThingPos(object);
			object_look = object_orient0;
			player_relative = VectorNorm(VectorSub(GetThingPos(player), object_pos));
			curr_angle = VectorDot(object_look, player_relative);
			// Check player's angle to current object (dot product)
			if(curr_angle > min_angle * 2)
			{
				// Player is in front of object
				Print("In front");

				// Check player's distance to object
				dist_temp = VectorDist(GetThingPos(player), object_pos);
				if(dist_temp < 0)
					dist_temp = -1 * dist_temp;
				PrintFlex(dist_temp);
				if(dist_temp > (min_dist + distance))
				{
					Print("Dist >");
					if(cur_dist0 == 0)
					{
						Print("Moved forth");
						SetThingPos(object, VectorAdd(object_pos, VectorScale(object_look, distance)));
						cur_dist0 = 1;
					}
				}
				else if(dist_temp < min_dist)
				{
					Print("Dist <");
					if(cur_dist0 == 1)
					{
						Print("Moved back");
						SetThingPos(object, VectorSub(object_pos, VectorScale(object_look, distance)));
						cur_dist0 = 0;
					}
				}
			}
			else if(curr_angle < min_angle)
			{
				// Player is at side of object
				Print("At side");

				if(cur_dist0 == 1)
				{
					Print("Moved back");
					SetThingPos(object, VectorSub(object_pos, VectorScale(object_look, distance)));
					cur_dist0 = 0;
				}
			}
		}
	}
	Return;

end

I've added the sample level again.

BTW: In the screenshot of your level, it looks like the pillars were architecture. Is that true? Because I remember them being lit like 3dos.
Attachment: 5992/zfight.zip (9,058 bytes)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-07-12, 11:20 AM #9
I just tried the new cog out. Thankyou, it works very well with one lion head statue.

However, as soon as I put in my full 8, they all started z-fighting again. THe print out at the top of the screen seems to be confused - it constantly prints "At Side" and doesn't seem to recognize each individual statue. I haven't tried 8 separate cogs yet, but I might try it out. Perhaps you know how to fix this?

Also the picture I took is of the actual arena. The 3do pillars are in the lobby. ;)
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-07-12, 12:12 PM #10
Hmm, maybe the pulse is too fast for multiple things. The print should be confused, though, because it prints too fast to distinguish seperate things. I'll try to test it in an own level if I get a little time (I'm currently on a LAN Party).
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-07-12, 1:04 PM #11
Whenever you get a chance, I'm in no hurry. Thanks.

Quote:
Originally posted by zagibu
(I'm currently on a LAN Party).

Ooh, is that the one jEDIkIRBY was talking about? How is it? What games are you playing? :D
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-07-12, 2:47 PM #12
Quote:
Originally posted by Daft_Vader
Ooh, is that the one jEDIkIRBY was talking about? How is it? What games are you playing? :D

Hehe, I haven't seen a small pink blob around yet, so I guess it's not the same party. We were playing Q3A: Excessive before, and my pulse is currently at 200. KWP is a little sissy against that. Rocket Launcher, e.g. got a firerate of around 5/sec.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-07-12, 2:50 PM #13
Dang why can't you upload stuff when editing a post? Anyway, I have rechecked the cog with several things, and it works. Please make sure you define all the vectors correctly. I slowed the pulse down to 0.5 sec, and that works fine for 3 things. I'm pretty confident it should be enough for ten things, too. See the attached sample level.
Attachment: 6028/zfight.zip (9,093 bytes)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-07-13, 2:49 PM #14
I tried out the new cog, but I'm sorry to say the results are exactly the same as before. It still doesn't work. :/
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-07-16, 9:16 AM #15
zagibu, do you know what's going on with the cog?
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-07-16, 11:59 AM #16
Have you tested the sample level at all? Because in there it works perfectly.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-07-16, 1:50 PM #17
Quote:
Originally posted by zagibu
Have you tested the sample level at all? Because in there it works perfectly.

I did. You may have said it worked fine with 3 objects, but keep in mind I'm using 8 and they are all in close proximity to each other.

Maybe I'm just setting it up wrong, I donna' know. :(
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-07-16, 2:56 PM #18
Well, I've tested it with 10 objects, and it still works fine (see attachement). What values do you set for the orient vectors?
Attachment: 6142/zfight.zip (9,076 bytes)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)

↑ Up to the top!