Jump to content

  • Log In with Google      Sign In   
  • Create Account

MarkS

Member Since 09 Jan 2001
Offline Last Active Feb 11 2016 03:12 AM

#5257714 How to create shader that fades based on two different connecting surface angles

Posted by MarkS on 17 October 2015 - 03:34 PM

It looks like ambient occlusion.




#5256580 Should I use OpenGL or Directx

Posted by MarkS on 10 October 2015 - 03:30 PM

This question has been asked multiple times and is actually not allowed.

From the For Beginners FAQ:
 

"This" versus "that" threads are considered flame bait and will usually be closed on sight. Such questions have usually been asked before, several times, so there should be no need to ask them again.




#5256556 The wrong way to count lines of code

Posted by MarkS on 10 October 2015 - 12:39 PM

Not really. It's a useful metric- at least it would be if they implemented it properly. Gives you a ball park figure of how complex a project is.


It really isn't. Brackets, for instance, are arbitrary. They make the code cleaner, but do not translate to machine code. There is quite a bit in all modern languages that exists for aesthetics and code organization that do not have any effect on the final machine code.

This:

if(...){}
is equal to this:

if(...)
{
}
Your code really isn't any more compact in the first case.


#5255919 What's the best system on which to learn ASM?

Posted by MarkS on 06 October 2015 - 06:15 PM

I vote 68000. I learned to program on a Mac 512KE and the only processor I've actually learned assembly for was the 68000. It has a remarkably easy and rather nice instruction set.




#5255130 which program I should use for a text adventure

Posted by MarkS on 02 October 2015 - 07:34 AM

Hi Snatcher,
 
Have you considered using a programming language instead? It would give you the ability to build on your efforts from creating this in the future.
I'm currently learning javascript and am working on a text adventure also with some graphics.
Good luck either way and let us know how you get on.


I've been wanting to make a text adventure game for years. I've been programming for 30 years. Text adventures are easy to write, so long as you don't include a command parser. This is absurdly hard to get right. I've tried and failed. Parsing the individual commands is easy. Applying the parsed commands to grammar rules is not so. If you can find a program that does this for you, use it!


#5255068 which program I should use for a text adventure

Posted by MarkS on 01 October 2015 - 07:24 PM

I'd use Quest, if for no other reason than the website actually shows how to use it. Twine seems like an afterthought.


#5255059 Need scene graph advice, please!

Posted by MarkS on 01 October 2015 - 04:50 PM

Tom Forsyth gives a pretty good argument against scene graphs in his blog. It falls under his OffendOMatic blog post!


#5255023 Books with decent, real and useful projects?

Posted by MarkS on 01 October 2015 - 01:00 PM

Someone else will have to chime in then. I gave up on programming related books years ago. There may be books like what you're looking for, but I haven't checked in nearly a decade.


#5254931 Books with decent, real and useful projects?

Posted by MarkS on 01 October 2015 - 12:25 AM

This was a common theme back in the 90's when graphics APIs either didn't exist or were in their infancy. I have several very old computer graphics books that detail how to make something useful, from start to finish, and all use software renderers. I think the focus has shifted now to explaining how to use the various features of the different APIs, and since the APIs are so complex, the authors really do not have the time or space for much else. It is left to the reader to assemble the pieces into something useful.

That being said, I no longer recommend buying books on any computer graphics related subjects. The technology changes so fast these days that by the time the book makes it to print, it is seriously outdated. You'll find more up to date stuff online where changes can be published immediately.


#5254476 Glut & opengl only for 2D [Question]

Posted by MarkS on 28 September 2015 - 02:37 PM

Yes, OpenGL is well suited to 2D rendering. Google "OpenGL orthographic projection" to get started. You could also use DirectX, if you wanted. 2D is 3D, missing a D. *wink*


#5254080 Creating a filled Bresenham's ellipse

Posted by MarkS on 25 September 2015 - 09:49 PM

I just found this: http://enchantia.com/graphapp/doc/tech/ellipses.html

It looks interesting as well.


#5253862 sprite render is very slow

Posted by MarkS on 24 September 2015 - 01:36 PM

I'm sorry, but you're going to have to provide more than a compressed archive of code if you want to get help. Post the sprite rendering code here in code tags. I'm not going to download a compressed archive and dig through multiple files to try and figure out where the error is and I doubt many people would either.

Also, it sounds like you want someone to download your code base, fix it and then send it back to you. Not going to happen. We'll comment on the code you post openly on the forum, but you'll need to be the one to make the changes.


#5253543 Creating a filled Bresenham's ellipse

Posted by MarkS on 22 September 2015 - 04:39 PM

I've done this before, but with pixels. You fill spans between quadrants.
 
So this:
            voxelInfo.chunk.SetVoxel(xc + x, yPos, zc + z, 9, true);
            voxelInfo.chunk.SetVoxel(xc - x, yPos, zc + z, 9, true);
            voxelInfo.chunk.SetVoxel(xc + x, yPos, zc - z, 9, true);
            voxelInfo.chunk.SetVoxel(xc - x, yPos, zc - z, 9, true);
 
Would become something like this:
            voxelInfo.chunk.SetVoxelSpan(xc - x,xc + x, yPos, zc + z, 9, true);
            voxelInfo.chunk.SetVoxelSpan(xc - x,xc + x, yPos, zc - z, 9, true);
You also need to be careful of using 32-bit integers. They can overflow quite easily once the ellipse gets too big due to the squares. I did a test years ago. I don't remember exactly how big I had to make it before getting an overflow, but it wasn't all that large.

Here is a better ellipse drawing algorithm I've used in the past:
void FillEllipse(long left,long top,long right,long bottom)
{
	long		a,b,x,y,temp;
	long		old_y;
	long long	d1,d2;
	long long	a2,b2,a2b2,a2sqr,b2sqr,a4sqr,b4sqr;
	long long	a8sqr,b8sqr,a4sqr_b4sqr;
	long long	fn,fnw,fw;
	long long	fnn,fnnw,fnwn,fnwnw,fnww,fww,fwnw;

	if(right < left)
	{
		temp = left;
		left = right;
		right = temp;
	}
	if(bottom < top)
	{
		temp = top;
		top = bottom;
		bottom = temp;
	}

	a = (right - left) / 2;
	b = (bottom - top) / 2;

	x = 0;
	y = b;

	a2 = a * a;
	b2 = b * b;
	a2b2 = a2 + b2;
	a2sqr = a2 + a2;
	b2sqr = b2 + b2;
	a4sqr = a2sqr + a2sqr;
	b4sqr = b2sqr + b2sqr;
	a8sqr = a4sqr + a4sqr;
	b8sqr = b4sqr + b4sqr;
	a4sqr_b4sqr = a4sqr + b4sqr;

	fn = a8sqr + a4sqr;
	fnn = a8sqr;
	fnnw = a8sqr;
	fnw = a8sqr + a4sqr - b8sqr * a + b8sqr;
	fnwn = a8sqr;
	fnwnw = a8sqr + b8sqr;
	fnww = b8sqr;
	fwnw = b8sqr;
	fww = b8sqr;
	d1 = b2 - b4sqr * a + a4sqr;

	while((fnw < a2b2) || (d1 < 0) || ((fnw - fn > b2) && (y > 0)))
	{
		DrawHorizontalLine(left + x,right - x,top + y,0.4,0.7,1.0); // Replace with your own span filling function. The hard-coded numbers were color values for testing purposes and can be ignored.
		DrawHorizontalLine(left + x,right - x,bottom - y,0.4,0.7,1.0);

		y--;
		if((d1 < 0) || (fnw - fn > b2))
		{
			d1 += fn;
			fn += fnn;
			fnw += fnwn;
		}else{
			x++;
			d1 += fnw;
			fn += fnnw;
			fnw += fnwnw;
		}
	}

	fw = fnw - fn + b4sqr;
	d2 = d1 + (fw + fw - fn - fn + a4sqr_b4sqr + a8sqr) / 4;
	fnw += b4sqr - a4sqr;

	old_y = y + 1;

	while(x <= a)
	{
		if(y != old_y) // prevent overdraw
		{
			DrawHorizontalLine(left + x,right - x,top + y,0.4,0.7,1.0);
			DrawHorizontalLine(left + x,right - x,bottom - y,0.4,0.7,1.0);
		}

		old_y = y;
		x++;
		if(d2 < 0)
		{
			y--;
			d2 += fnw;
			fw += fwnw;
			fnw += fnwnw;
		}else{
			d2 += fw;
			fw += fww;
			fnw += fnww;
		}
	}
}



#5253034 collision detection in maze issue

Posted by MarkS on 19 September 2015 - 08:18 AM

My ultimate goal for this will be a little game, something like Boulderdash crossed with Pacman.


I apologize. I didn't finish my thought; it was a LONG day for me. We are trying to help you based on a very rudimentary image. Is it safe to assume that the graphics shown are simply placeholder graphics? If so, your character bounding box is far too large. In fact, it is far too large even if these are the final graphics! The collision bounds needs to be as small as possible so as to not cause false positives. There is precious little reason for your character's collision bounds to be so large as to force a collision with the environment. As it stands now, your character is always in contact with the walls. If you were to use an actual physics library, your character wouldn't move at all.

All of your problems would go away if you were to reduce the size of the blue square and you would have a much easier time if it were a circle and you did a radius collision test.


#5252945 collision detection in maze issue

Posted by MarkS on 18 September 2015 - 03:35 PM

The problem with this is that if I'm moving say left and down, it still won't go in the down direction until I stop moving.


This line needs some clarification. If the player starts moving down before being fully in the maze cell, he'll end up moving through the wall. The character MUST continue moving in the original direction of travel to clear the wall. That is, unless you plan on rotating the character, at which point you would be better off doing a radius collision test.

It would help if we knew more of your ultimate goals for this.




PARTNERS