Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Pfhreak
Jan 30, 2004

Frog Blast The Vent Core!

Interesting read, but he doesn't seem to pose a solution. He suggests, and correct me if I'm not reading this right, that your game is more or less too narrow of a domain for a broad use data structure. That you'll eventually hack in links between the objects for your own specialty purposes -- keeping caches fresh for example.

However, for the hobbyist developer like myself, they seem to provide a simple means of managing object hierarchy, and allow me to make minimal changes to my entities state to propagate changes in positioning.

I'm interested now that you brought that article up in how adopted these things really are. I thought the scene graph was a de facto standard, but it seems I may have been wrong. Your thoughts?

Adbot
ADBOT LOVES YOU

Contero
Mar 28, 2004

OneEightHundred posted:

It's hard to even give one because things are in flux at the moment. Things aren't really as consistent as they were when everyone was trying to copy Quake 3 or Doom 3. Now, there are several approaches and which one is the best depends entirely on what you're making, mainly because there are several completely incompatible ways to deal with lighting, especially lighting over large areas.

Got suggestions for giant outdoor type games? WoW or Oblivion or that sort of thing?

I'm making a heightmap based ourdoorsy kind of game right now and I'm pretty much winging it. Reading or code suggestions for modern rendering code even remotely related would be helpful.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
Some guy wrote a whole MMO engine by himself to use as a demo for breaking into the game programming industry. He posted the source for everything (client, server, tools) and it's free to download here. It's kind of an ugly version of multi-player Diablo.

The project compiled without complaint in VS 2008 C++ Express edition and ran just fine for me with both the server and client systems running locally. I don't know if his implementations are 'good' in the sense of being professionally written, but it does run and seems to mostly work. Interesting stuff to dig around in for ideas if nothing else.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Pfhreak posted:

However, for the hobbyist developer like myself, they seem to provide a simple means of managing object hierarchy, and allow me to make minimal changes to my entities state to propagate changes in positioning.
The typical renderer is broken into a couple distinct parts:
- A scene manager, which handles the task of interpreting the world state and composing it into a set of high-level rendering primitives (i.e. models, lights, particle systems, static geometry)
- The front-end, which takes high-level primitives, processes their interactions with each other (i.e. lighting, transparency sorting) and generates low-level rendering primitives (i.e. geometry sets).
- The back-end, which takes low-level primitives and issues calls to the graphics API to render them.

The problem with scene graphs is they blur the lines there by assuming that structuring high-level scene objects a certain way will result in improvements in the low-level rendering process.

He doesn't really need to post an alternative, merely state that using a "one size fits all" scene representation is a bad approach and you should structure your renderer so that each stage of it takes the optimizations that are most appropriate.

quote:

I'm interested now that you brought that article up in how adopted these things really are. I thought the scene graph was a de facto standard, but it seems I may have been wrong. Your thoughts?
I don't know what the adoption rate is, but I thought they were a stupid inflexible gimmick when they came out, and I've been steadily more vindicated over the years, hopefully I'm not alone.

Contero posted:

Got suggestions for giant outdoor type games? WoW or Oblivion or that sort of thing?
WoW uses alphamapped terrain (i.e. terrain pieces have textures associated with them that indicate how much of each tile texture to use) at a fixed LOD. Fixed LOD can be problematic, though WoW decided to turn that drawback into a benefit by modeling terrain around it (i.e. see the cliffs in Howling Fjord).

Indoor areas use a visibility scheme where they're broken into areas and each area can see some set of other areas as well as possibly "outside".

You probably want to use a regional coordinate system, i.e. objects are always contained within either a terrain area or an indoor model, and while objects in one region can collide with objects in adjacent regions, their coordinates are always local to the region and anything in non-adjacent regions is ignored. This simplifies collision checks, and prevents issues with floating point precision breaking down.

Also if you are going to do a huge game, keep in mind that CONTENT CREATION is going to be your biggest challenge. Indoor games can get away with the fact that there are several simplistic map editors that can be hijacked to make them, for a massive interconnected world though, you would probably need to make the tools to piece the world together, unless you're going to break the world into zones with distinct loading points.

Good tools are the most important thing to creating a good game, and ironically, they're also the least-fun thing to write.

Contero
Mar 28, 2004

OneEightHundred posted:

:words:

Thanks. That'll give me something to chew on for a while.

OneEightHundred posted:

Good tools are the most important thing to creating a good game, and ironically, they're also the least-fun thing to write.

Fortunately that had occurred to me.



The editor has actually been more fun so far since my rendering code is literally "draw a shitload of triangle strips". Also Qt has been a joy to work with.

Can you comment on this? It's apparently a screenshot from DICE's frostbite engine and it's almost exactly the kind of thing I want work on (with respect to the really far away stuff). My real-time rendering book simply says "an example of multiple level of detail terrain" but I find it hard to believe that the geometry in the background is just a simplified mesh.



It doesn't seem like any of the games they are using the frostbite engine in have scenes like this, so it might just be an extremely impractical example that's running < 1fps on a really powerful machine. Or at least I hope so. :ohdear:

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Well yes, the stuff in the background most likely is simplified. There are a couple ways of doing that, primarily adaptive subdivision or simply using fixed subdivision levels at particular ranges from the viewpoint.

The reason it still maintains fairly high detail is because it uses alphamaps, rather than per-vertex terrain painting, which means that the terrain texturing detail can be at a higher resolution than the geometric detail.

edit: DICE published a presentation on Frostbite:
http://developer.amd.com/assets/Andersson-Tatarchuk-FrostbiteRenderingArchitecture(GDC07_AMD_Session).pdf

Terrain is hybrid procedural, a form of content creation I can only hope we start seeing more of, meaning that it's algorithmically generated but portions of the results can be overrided to suit gameplay needs. I'd strongly recommend checking out World Machine 2 if you're interested in doing this offline.

It doesn't appear to use a heightmap division based LOD system though, so it probably uses some other arbitrary LOD scheme. I'm unfortunately not familiar with any LOD schemes that would allow you to quickly LOD an arbitrary mesh, the one I use requires a pretty large precomputation time for large meshes, but that's the kind of thing you'd be looking for.

It may be possible that it's not LODing the mesh anyway, but rather progressively increasing complexity based on the generation algorithm. You could very easily do something like, for example, store a fairly low-resolution map of geometric complexity and use that to determine subdivision levels in the resulting geometry since you could generate height for arbitrary points.

OneEightHundred fucked around with this message at 00:20 on Feb 1, 2010

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Pfhreak posted:

I'm interested now that you brought that article up in how adopted these things really are. I thought the scene graph was a de facto standard, but it seems I may have been wrong. Your thoughts?

The thing is, the scene graph was invented partially to solve a problem that just doesn't exist anymore -- namely, the cost of frequent state changes. Most state changes can be pipelined in current hardware so as not to cause a flush or stall, leaving just the cost of the API overhead (which is reduced by using state blocks, below). Sorting by state is useless in most cases* and is in fact kind of totally against the state model in Direct3D 10 and 11 (which uses pre-created "state blocks" for entire pipeline stages). Usually in a modern engine it's much more important to sort by distance -- front to back to avoid overdraw, back to front to properly render overlaping transparency, or front to back in a depth-only pre-pass, then back-to-front in the main rendering pass to do both.

The only thing scene graphs are still really useful for is tracking hierarchical transforms -- and even that can be easily rolled into your existing "logical" scene.


*: there are some state changes that can cause large pipeline inefficiencies if used frequently or improperly, so grouping still matters to some degree

stramit
Dec 9, 2004
Ask me about making games instead of gains.
Did anyone here go in the gamejam last weekend? I went to the sydney one with a friend and we made a pretty solid game in 48hrs. How was everyone's experience?

The group that I was there with were great. Everyone got along well and had a great time. Food was nice and the games fun :D

Our game was called ‘The Ferryman’. As the ferryman it is your job to escort souls across the river of the dead to either Hades or the Elysium fields. You do this by talking to the souls and deciding if they were good or bad souls.

Here is a pic of the game we made (2 man team programmer / artist). We are going to upload it to the internet for other people to play but we want to tune some gameplay first.

Vinlaen
Feb 19, 2008

That looks really neat!

What engine/libraries did you use?

Nibelheim
Jul 7, 2006

Strumpy posted:

Did anyone here go in the gamejam last weekend? I went to the sydney one with a friend and we made a pretty solid game in 48hrs. How was everyone's experience?

The group that I was there with were great. Everyone got along well and had a great time. Food was nice and the games fun :D

Our game was called ‘The Ferryman’. As the ferryman it is your job to escort souls across the river of the dead to either Hades or the Elysium fields. You do this by talking to the souls and deciding if they were good or bad souls.

Here is a pic of the game we made (2 man team programmer / artist). We are going to upload it to the internet for other people to play but we want to tune some gameplay first.



Looks good!

I went to the Jam in Ottawa myself along with five other programmers from my game development club. We split up into two teams, and I ended up on a team of three programmers / three artists.

We made a game called "Undoor the Lock" which is a hommage to the classic zelda-esque dungeon games. Only this time, your regular methods of solving puzzles will not be of help. For example, the first room contains a locked door and a key. To solve it, you must pickup the door and unlock the key.

We enjoyed the idea very much. and although the end product really isn't polished, still had a drat blast and ended up with a complete prototype. We used XNA and started the code pretty much from scratch.

Link to game: http://www.globalgamejam.com/2010/undoor-lock

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Vinlaen posted:

That looks really neat!

What engine/libraries did you use?

Unity3d. It's pretty much my goto these days for anything game related. I program game tech at work all week (360/ps3). It's nice in my spare time to just focus on gameplay programming. I think I miss it.

@Nibelheim I'll have a play tomorrow when I'm at work. It sounds like a fun idea!

Vinlaen
Feb 19, 2008

Thanks for the info!

How easy do you find Unity?

It's awesome they released the indie version for free but their prices for the professional versions seem a bit high. ($1500) Luckily the indie version has mostly everything but lacks real-time shadows which bothers me.

Also, the iPhone version looks nice ($399) but lacks networking support and requires you to purchase Unity3D Pro ($1500) PLUS iPhone Pro ($1500) which is a bit expensive.

Anyways, I'm still interested in using it. How difficult do you think a Final Fantasy Tactics/Disgaea clone would be?

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Vinlaen posted:

Thanks for the info!

How easy do you find Unity?

It's awesome they released the indie version for free but their prices for the professional versions seem a bit high. ($1500) Luckily the indie version has mostly everything but lacks real-time shadows which bothers me.

Also, the iPhone version looks nice ($399) but lacks networking support and requires you to purchase Unity3D Pro ($1500) PLUS iPhone Pro ($1500) which is a bit expensive.

Anyways, I'm still interested in using it. How difficult do you think a Final Fantasy Tactics/Disgaea clone would be?

Unity 3d is the best indie game engine out there in my opinion. You have to do things their way, but the documentation and 'free' stuff you get make it totally worth it. As far as I am aware you do not need the Pro version for iPhone support unless you want the networking ect. The best thing about unity is that you don't have to worry about any low level stuff and can just make a game. All the collision objects and stuff are great the GUI layer is nice ect.

RE Disgaea ect: Unity is an engine that doesn't really like working with 'grid' based games. You can code it over the top but it gets a little messy (I tried this and made a little block pushing tech test - http://blog.strumpy.net/?p=3). The game I made is purely grid based. If you want to do something that isn't grid based, but 'emulates' grid based gameplay that would be much nicer. By this I mean that each movement is a 'specific' distance and that grid data is captured in some higher level game object or as volumes placed in the level.

nolen
Apr 4, 2004

butts.

Strumpy posted:

Unity 3d is the best indie game engine out there in my opinion. You have to do things their way, but the documentation and 'free' stuff you get make it totally worth it. As far as I am aware you do not need the Pro version for iPhone support unless you want the networking ect. The best thing about unity is that you don't have to worry about any low level stuff and can just make a game. All the collision objects and stuff are great the GUI layer is nice ect.

RE Disgaea ect: Unity is an engine that doesn't really like working with 'grid' based games. You can code it over the top but it gets a little messy (I tried this and made a little block pushing tech test - http://blog.strumpy.net/?p=3). The game I made is purely grid based. If you want to do something that isn't grid based, but 'emulates' grid based gameplay that would be much nicer. By this I mean that each movement is a 'specific' distance and that grid data is captured in some higher level game object or as volumes placed in the level.

I think it's almost time for a Unity3D megathread. Wouldn't you agree?

Bastard
Jul 13, 2001

We are each responsible for our own destiny.
Unity3d is still 3d only right? That is to say, you can emulate 2d by placing the camera in a fixed position/angle, but you still need 3d models for everything?

BinaryChef
Sep 19, 2006

Bastard posted:

Unity3d is still 3d only right? That is to say, you can emulate 2d by placing the camera in a fixed position/angle, but you still need 3d models for everything?

Unity can handle 2D games as well! Check this game out.

I would imagine this could be done pretty easy using built in and custom scripts, which would require you to know a little JavaScript, C#, or Python(Boo).

BinaryChef fucked around with this message at 09:39 on Feb 4, 2010

brian
Sep 11, 2001
I obtained this title through beard tax.

I develop alot in Unity3D and can probably help with any questions anyone has regarding the physics/gameplay/non-rendering related stuff. It's one of the joyous development experiences i've ever had in terms of everything not only working correctly but also in scope of possibilities. It may not be super cutting edge graphics wise but for prototyping and iphone games it's really awesome.

Lurking Haro
Oct 27, 2009

Bastard posted:

Unity3d is still 3d only right? That is to say, you can emulate 2d by placing the camera in a fixed position/angle, but you still need 3d models for everything?

How about putting the sprites as textures on a simple polygon square?

stramit
Dec 9, 2004
Ask me about making games instead of gains.

brian posted:

I develop alot in Unity3D and can probably help with any questions anyone has regarding the physics/gameplay/non-rendering related stuff. It's one of the joyous development experiences i've ever had in terms of everything not only working correctly but also in scope of possibilities. It may not be super cutting edge graphics wise but for prototyping and iphone games it's really awesome.

The shader language is pretty thorough. If you know what you are doing you can make some pretty awesome effect / graphics. The low level graphics performance (i.e engine stuff that you have no access to) isn't amazingly fast. But for indie stuff it's more then powerful enough.

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Lurking Haro posted:

How about putting the sprites as textures on a simple polygon square?

That's how I would do it if I was making a '2d' game in unity.

Vinlaen
Feb 19, 2008

How do you create rooms and indoor environments for Unity3D? (ie. Neverwinter Nights, etc)

It seems like I need to learn Blender (or Google Sketchup?) but I'm not sure.

What's the _easiest_ way for a programmer who knows very little about modeling to create some simple rooms and hallways with a few textures?

nolen
Apr 4, 2004

butts.

Bastard posted:

Unity3d is still 3d only right? That is to say, you can emulate 2d by placing the camera in a fixed position/angle, but you still need 3d models for everything?

I've used this for my 2D work in Unity and it seems to be popular within the community as well:

http://www.anbsoft.com/middleware/sm2/

brian
Sep 11, 2001
I obtained this title through beard tax.

Vinlaen posted:

How do you create rooms and indoor environments for Unity3D? (ie. Neverwinter Nights, etc)

It seems like I need to learn Blender (or Google Sketchup?) but I'm not sure.

What's the _easiest_ way for a programmer who knows very little about modeling to create some simple rooms and hallways with a few textures?

You can use the built in primitives for setting out simple walls and so on, anything past that and your best bet is a proper 3D modelling program, Blender is free, has good integration with Unity and is pretty popular in the community. I personally find it one of the most horrifyingly awful UIs i've ever experienced but whatever floats your boat.

Vinlaen
Feb 19, 2008

What would you suggest besides Blender?

It seems like I almost want a map editor (like the one for Half-Life 2, etc) so I can create rooms, hollow them out, add textures, etc, etc.

brian
Sep 11, 2001
I obtained this title through beard tax.

If you can find a map editor that exports maps as FBX or some other polygon based format that unity reads then great, the issue is that map editors in general are designed around BSP trees or CSG operations, which are used in older generation engines for faster occlusion culling (i.e. not drawing what you can't see). Unity doesn't do BSP trees so it can't read BSP files.

So in answer to your question, i'd recommend any typical 3D modelling program like 3DSMax/Maya/Softimage XSI/Blender since they all have pretty good integration with Unity (apart from Max which requires a bizarre trick to export correctly). They also tend to be easier to use if you're not used to Hammer/UnrealEd/etc. If you find any modelling application you're happy using that exports to FBX it'll almost always be fine in Unity.

The other option is to just use Unity boxes for everything, scale them to the right size and so on then texture them as needed, it'll probably be alot easier and you can always try and find a willing artist once you get the gameplay side of things working.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Vinlaen posted:

What would you suggest besides Blender?

It seems like I almost want a map editor (like the one for Half-Life 2, etc) so I can create rooms, hollow them out, add textures, etc, etc.

The *easiest* way is to create a simple human-editable format file (XML/YAML maybe) in which you specify boxes of a given size and dimension and material, then do it by hand. That'll let you get some test scenes together.

After that, I'd consider looking up the Quake3 BSP format, and learning how to parse that. I know that sounds like a huge amount of work, and it can be kind of tricky, but it's honestly not that bad if you're going to ignore all the VIS optimization information. If you do this, you can then use gtkRadiant/the Q3 level editor of your choice. Like I said, it seems like overkill, but if you want something as sophisticated as the HL2 editor, this is probably the easiest way to get close.

Mine GO BOOM
Apr 18, 2002
If it isn't broken, fix it till it is.

nolen posted:

I think it's almost time for a Unity3D megathread. Wouldn't you agree?
I would very much like this. I've been wanting to play with it a bit, and the startup of a megathread for just it and good links would be a great start.

AskYourself
May 23, 2005
Donut is for Homer as Asking yourself is to ...

Nibelheim posted:

I went to the Jam in Ottawa myself along with five other programmers from my game development club.


Do you have a brother in India ?

AskYourself fucked around with this message at 20:14 on Feb 6, 2010

Nibelheim
Jul 7, 2006

AskYourself posted:

Do you have a brother in India ?

Why yes, yes I do. Have we met sir?

Staying on topic, this little gem came out of the Sydney Jam: http://www.youtube.com/watch?v=QYPwYfbi8jA

It's called GNILLEY, and basically it's a zelda game that you control with a microphone. It made for a pretty hilarious show.

Nibelheim fucked around with this message at 23:42 on Feb 6, 2010

ping
Aug 15, 2001

by Lowtax
Unity looks excellent. Does anyone have any experience with the web-based side of it, with the web player and such? I'm thinking about using it for a project I have brewing, but it'd be nice to hear some firsthand experiences.

nolen
Apr 4, 2004

butts.

ping posted:

Unity looks excellent. Does anyone have any experience with the web-based side of it, with the web player and such? I'm thinking about using it for a project I have brewing, but it'd be nice to hear some firsthand experiences.

What questions do you have? The web player performs the same as the standalone "player", really.

AskYourself
May 23, 2005
Donut is for Homer as Asking yourself is to ...

Nibelheim posted:

Why yes, yes I do. Have we met sir?

We played poker twice together. Last time was at your bro's goodbye party. Actually we launched into a laugher when we found out we both were goons !

It was inevitable we meet virtually on this forum !

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Hubis posted:

After that, I'd consider looking up the Quake3 BSP format, and learning how to parse that. I know that sounds like a huge amount of work, and it can be kind of tricky, but it's honestly not that bad if you're going to ignore all the VIS optimization information.
If you ignore the visibility info then it will be glacially slow. Fortunately, the visibility technique it uses isn't hard:

Each BSP leaf has a cluster number and area number. Area-to-area visibility is determined by area-sealing doors. Cluster-to-cluster visibility is determined by a precomputed bitfield which contains 1 bit for each cluster-to-cluster visibility check.

If a leaf is visible, all surfaces on that leaf's surface list are visible.

That's it. The only thing hard about the format are the parametric surfaces, which are easy to generate polygons for, but annoying as hell to stitch or LOD.

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Nibelheim posted:

Why yes, yes I do. Have we met sir?

Staying on topic, this little gem came out of the Sydney Jam: http://www.youtube.com/watch?v=QYPwYfbi8jA

It's called GNILLEY, and basically it's a zelda game that you control with a microphone. It made for a pretty hilarious show.

Yeah that was a really good one! It was kinda hard sitting 2 meters from a guy yelling into a microphone for 40 hours though!

I also just splashed out and bought unity pro... I don't know how they can get away without proper version control systems in the indie version.

Nibelheim
Jul 7, 2006

Strumpy posted:

Yeah that was a really good one! It was kinda hard sitting 2 meters from a guy yelling into a microphone for 40 hours though!

I also just splashed out and bought unity pro... I don't know how they can get away without proper version control systems in the indie version.

Haha you were at the Sydney Jam? When me and my buddies were talking about GNILLEY the first thing that came to mind was "I can't imagine having to work next to that team all weekend."

@AskYourself: High five :V

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Nibelheim posted:

Haha you were at the Sydney Jam? When me and my buddies were talking about GNILLEY the first thing that came to mind was "I can't imagine having to work next to that team all weekend."

Yeah I was. It was really fun. The one thing I would have liked would be for the comp to run at better hours. We only actually got 40hours (Friday from 9pm until Sunday at 1pm). It was meant to start at 5pm but there was some media stuff ect that we had to do. Waste of time.

I think it would have been better if it had started at midday friday and gone until midday sunday. Could have actually gone home to sleep 8 hours a night as well and still done the same amount of work.

akadajet
Sep 14, 2003

Contero posted:

Can you comment on this? It's apparently a screenshot from DICE's frostbite engine and it's almost exactly the kind of thing I want work on (with respect to the really far away stuff). My real-time rendering book simply says "an example of multiple level of detail terrain" but I find it hard to believe that the geometry in the background is just a simplified mesh.



It doesn't seem like any of the games they are using the frostbite engine in have scenes like this, so it might just be an extremely impractical example that's running < 1fps on a really powerful machine. Or at least I hope so. :ohdear:

A lot of these large terrain engines use normal maps to supplement geometry. You should check out the terrain texturing tutorials at this site:
http://www.dhpoware.com/demos/index.html

I've seen a few projects which generate high-res normal maps on the GPU with perlin noise. Using those to supplement lower-res heigthmaps can make for some drat good looking terrain on the cheap.

Hunterprime
Mar 22, 2005

Fixing networks and making games
Hey Game programmers and other technical people. If your in town for GDC, come meet up with us! We had great luck last year and I hope to do the same this year.

http://forums.somethingawful.com/showthread.php?threadid=3266382

Fabre
Jul 25, 2006

I'm having a problem doing per-pixel collision detection on transformed objects. Here is the code I have, it works perfectly when the objects are not rotated, so I believe the issue may be with the rotation of the step vectors. When the objects are rotated, the collisions are way off.

code:
// Performs a per-pixel collision check between two sprites
bool ICollidable::Intersects(ICollidable* _pOther)
{
	// Check for bounding circle collision
	float fDistanceX = (this->GetPositionX() - _pOther->GetPositionX());
	float fDistanceY = (this->GetPositionY() - _pOther->GetPositionY());
	
	float fDistanceSq = (fDistanceX * fDistanceX) + (fDistanceY * fDistanceY);
	
	// If the combined length of the bounding radii is less than the distance between the centres, the objects are not touching.
	if(sqrt(fDistanceSq) > (m_pSprite->GetBoundingRadius() + _pOther->m_pSprite->GetBoundingRadius()))
	{
		return false;
	}
	
	// Move on to per-pixel collision detection
	ICollidable* pA = this;
	ICollidable* pB = _pOther;
	
	// Calculate X and Y step per pixel (relative to the sprite of the other object)
	PVRTVec3 vec3XStep, vec3YStep;
	
	vec3XStep.x = 1.0f;
	vec3XStep.y = 0.0f;
	vec3XStep.z = 0.0f;
	
	vec3YStep.x = 0.0f;
	vec3YStep.y = 1.0f;
	vec3YStep.z = 0.0f;
	
	// Get the size of the sprite
	int iSize[2] = {pA->m_pSprite->GetActualSize(), pB->m_pSprite->GetActualSize()};
	int iHalfSize[2] = {iSize[0] >> 1, iSize[1] >> 1};
	
	// Construct a matrix to transform from the local space of this object to that of the other object
	PVRTMat4 mtxRotationA, mtxRotationB, mtxInvRotationB;
	
	// Rotation matrix for this object
	PVRTMatrixRotationZ(mtxRotationA, pA->GetRotation() / 180.f * 3.14159265f);
	// Rotation matrix for other object
	PVRTMatrixRotationZ(mtxRotationB, pB->GetRotation() / 180.f * 3.14159265f);
	// Inverse rotation matrix for other object
	PVRTMatrixRotationZ(mtxInvRotationB, -pB->GetRotation() / 180.f * 3.14159265f);
	

	// Calculate the offset of the top-left corner of each sprite from the center of the object
	PVRTVec3 vec3Corner[2];
	
	vec3Corner[0].x = -iHalfSize[0];
	vec3Corner[0].y = -iHalfSize[0];
	vec3Corner[0].z = 0.0f;
	
	vec3Corner[0] *= mtxRotationA;
	
	vec3Corner[0].x += pA->m_transform.fX;
	vec3Corner[0].y += pA->m_transform.fY;
	
	
	vec3Corner[1].x = -iHalfSize[1];
	vec3Corner[1].y = -iHalfSize[1];
	vec3Corner[1].z = 0.0f;
	
	vec3Corner[1] *= mtxRotationB;
	
	vec3Corner[1].x += pB->m_transform.fX;
	vec3Corner[1].y += pB->m_transform.fY;
	
	// Calculate a vector from the top-left corner of the other object to the top-left corner of this object, 
	//	then rotate it to bring it into the local space of the other object
	PVRTVec3 vec3Start;
	
	vec3Start.x = vec3Corner[1].x - vec3Corner[0].x;
	vec3Start.y = vec3Corner[1].y - vec3Corner[0].y;
	vec3Start.z = 0.0f;
	
	vec3Start *= mtxInvRotationB;
	
	// Transform the step vectors
	vec3XStep *= mtxRotationA;
	vec3XStep *= mtxRotationB;
	
	vec3YStep *= mtxRotationA;
	vec3YStep *= mtxRotationB;

	// The current position within the coordinate frame of the other object
	PVRTVec3 vec3Pos;
		
	// Iterate through all pixels in the current object
	for(int iY = 0; iY < iSize[0]; ++iY)
	{
		vec3Pos = vec3Start;
		
		vec3Pos += vec3YStep * iY;
		
		for(int iX = 0; iX < iSize[0]; ++iX)
		{
			// If this pixel of the player's sprite is collidable
			if(pA->m_pSprite->IsOpaque(iX, iY) && pB->m_pSprite->IsOpaque((int)vec3Pos.x, (int)vec3Pos.y))
			{
				return true;
			}
			
			vec3Pos += vec3XStep;
		}
	}
	
	return false;
}
I have been trying to sort this out for a few days now, so any help would be much appreciated!

Adbot
ADBOT LOVES YOU

Hanpan
Dec 5, 2004

I've been trying to put together some kind of action based platformer for a while now, and I'm really stuck as to which engine I should use.

It started out as a flixel project, but Flash really can't handle the kind of things I want to do. After that, I tried out pygame and some of the libraries associated with 2d gaming. It's nice but I ran into the same performance problems I encountered with Flash. As the game progresses, I'm very keen to start using high res backgrounds so I definitely need an engine with a little more grunt.

I've tried Torque2d, which is terrible, as well as attempting to modify Unity which isn't really engineered with 2D games in mind (it's annoying having to model 3d objects for a simple platform.)

It seems to me the only real way to get the performance I want is to either build something for scratch. Does anyone know of any other engines out there I could try? XNA is probably right for what I need, but I'd like the game to be multi-platform if possible. I don't mind learning a new language if there is a particular framework out there which people can recommend.

Hanpan fucked around with this message at 13:24 on Feb 19, 2010

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply