Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    135
  • comments
    130
  • views
    52780

About this blog

This journal may contain languages not suitable for minors and some occasional swearing.

Entries in this blog

 

LUA

So, I didn't do much progress with the event system yet, but for fun, I decided to plug in LUA real quick to see what I could come up with, and here's what the output looks like:


Unit Test: UnitTest_EventSystem

Event System Test - OnStart
GOOD_SHIP: I'm hit! (health=90)
EVIL_SHIP: I'm hit! (health=90)
GOOD_SHIP: I'm hit! (health=80)
EVIL_SHIP: I'm hit! (health=80)
EVIL_SHIP: I'm hit! (health=70)
GOOD_SHIP: I'm hit! (health=70)
GOOD_SHIP: I'm hit! (health=60)
EVIL_SHIP: I'm hit! (health=60)
EVIL_SHIP: I'm hit! (health=50)
EVIL_SHIP: I'm hit! (health=40)
ship_evil: dominating!
GOOD_SHIP: I'm hit! (health=50)
EVIL_SHIP: I'm hit! (health=30)
EVIL_SHIP: I'm hit! (health=20)
EVIL_SHIP: I'm hit! (health=10)
ship_evil: dominating!
GOOD_SHIP: I'm hit! (health=40)
GOOD_SHIP: I'm hit! (health=30)
GOOD_SHIP: I'm hit! (health=20)
ship_good: dominating!
GOOD_SHIP: I'm hit! (health=10)
GOOD_SHIP: I'm hit! (health=0)
GOOD_SHIP: *BOOM*!!
EVIL_SHIP: I WIN. BITCH
The winner is ship_good
Event System Test - Display
Event System Test - Stop






So yea, it's pretty much the same, and for the most part it is, except this is the LUA that's driving this:



winner = "none"

ship_good_health = 100
ship_evil_health = 100

good_streak = 0
evil_streak = 0

while 1 do

dice = math.random(100)

if dice > 50 then
ship_good_health = ship_good_fire()
evil_streak = evil_streak + 1
good_streak = 0
else
ship_evil_health = ship_evil_fire()
good_streak = good_streak + 1
evil_streak = 0
end

if evil_streak > 2 then
evil_streak = 0
print("ship_evil: dominating!")
end

if good_streak > 2 then
good_streak = 0
print("ship_good: dominating!")
end

--[[ print("ship_good_health: ", ship_good_health ) --]]
--[[ print("ship_evil_health: ", ship_evil_health ) --]]

if ship_good_health 0 then
winner = "ship_evil"
break
end

if ship_evil_health 0 then
winner = "ship_good"
break
end

end

print("The winner is ", winner)





Not the most elegant thing you've seen, but hey, it was just for fun... and what the hell is up with those LUA comments? that looks real ugly to me... oh well.

I guess you're wondering what the code side of things looks like... it's not that great either, but here it is:


int ship_good_fire(lua_State *L)
{
ship_good.m_evFire.Execute();

int health = ship_evil.health;
lua_pushnumber(L, health);

return 1;
}





This is the main:


// initialize Lua
L = lua_open();

// load Lua base libraries
lua_baselibopen(L);
luaopen_math(L);

// register our function
lua_register(L, "ship_good_fire", ship_good_fire);
lua_register(L, "ship_evil_fire", ship_evil_fire);

// run the script
lua_dofile(L, "ships.lua");

// cleanup Lua
lua_close(L);





The rest is handled by the event system. This is all hacked in, so don't think too much of it, I'm just trying to learn how LUA can be used, and I'm still figuring out how to do a better event system.

I really wish LUA played nicer with C++, I'd love to just be able to do this:

lua_register(L, "ship_fire", SpaceShip, SpaceShip::Fire);

or something like that, I've looked into some of the libraries some people have made that better integrate C++ with LUA, but they all seem so cumbersome.

VisualLR

VisualLR

 

Event System

So, I had previously worked on my event system, and I had tested it, but I ended up putting it in the back burner because I needed to do some graphics work. But, as I do more and more work, the need for an event system is becoming more urgent, or at least more desirable.

I'm not entirely happy with my current implementation because it uses templates, and templates have a way of becoming hard to manage the more you work with them. Another problem I have with them using templates is that it became a bit troublesome when I decided to work on the event manager class (aka, the event scheduler).

But, this is what it looks like right now:



All the main application is doing is randomly issuing "Fire" event on the good or evil ships, when the good ship fires, the evil ship listens for that event and determines that it has been hit. If a ship's health reaches 0, it executes the "Destroyed" event. What I didnt do, but would be trivial is to make the other ship listen for the "Destroyed" event and display a message, such as "I win. bitch", but it wasn't necessary because I had already proved that all listeners listen for the event and react appropiately to it.

VisualLR

VisualLR

 

Concerning game engines

I posted this in the comments on someone else's journal, but I think it's worthy of being a post here as well. It's about the whole thread of posts that's been going on about writing your own game engine and why you should or souldn't.

Here it is:

I recommend that anyone working on their game engine read the EULA on the code from books they buy, for example, I don't remember which one of these, but probably both:


3D Game Engine Architecture : Engineering Real-Time Applications with Wild Magic (The Morgan Kaufmann Series in Interactive 3d Technology)


Game Physics (Interactive 3d Technology Series)

the EULA states that you can use the software, for commercial or noncommercial purposes, provided that each memeber of your team owns a copy of the book, and as long as you dont redistribute the source.

Which is great, for the price of the book, you get a really complete physics library, that you just need to plug into your engine and use, no need to write your own.

That's what I'm doing =)

VisualLR

VisualLR

 

Networking

So, a few days ago, johnhattan sugested I try Raknet (http://www.rakkarsoft.com/ so last night I took it for a test drive.

It was great, I got a very simple text based chat program working in less than an hour, and the code is so clean and well designed. I really liked it, so whenever I get tired of working on the graphics side of things, I'll keep extending the simple chat application, and testing out the other features of RakNet, the autopatch feature seems very cool.


VisualLR

VisualLR

 

Good progress

This weekend was good, I refactored my dynamic rendering pipeline, and now it actually works. I never could figure out what was going on before, but every so often some of the stuff being dynamically rendered was blinking (this was the best case), worst case, entire letters would disappear altogether, imagine a buffer becoming full and then dumping out the first few elements to make room for the new ones, but the new ones never came. Kinda like that... doesn't matter, it's all fixed now and works quite nicely.

Now that I am able to display some text, I got my framerate counter up, and I'm happy to see that my entire terrain is rendering at 70+ average fps.

Anyway, I'm gonna get back to work. I still have that strange UV issue with models to look at, but I may just do something else... problems like that annoy me sometimes.

VisualLR

VisualLR

 

Tired

So I haven't been around much these past couple of days... my wife got a job that requires me to wake up at an extremely early hour in the morning to go drop her off... being the night person that I am, this is problematic because now I feel tired at night when I need to be up and doing my stuff. But, I'm sure I'll get used to it and I'll be able to get back to my old routine, or close to it.

Not a lot of interesting stuff, I'm still having that UV problem, sorry I keep missing you Rick, I've been in bed when you've msg'd me... =(

Hopefully I'll be able to lock that down during the weekend, it's gone on for far too long, it's weird, I didn't have this problem when I wrote my own 3dsmax exporter back in the day... now I've tried two exporters and I get the exact same results, and the author of one of these exporters said my code was fine... so annoying.

VisualLR

VisualLR

 

Madness

I'm getting the exact same problem using flexporter. For the life of me, I can't seem to be able to load in UVs anymore...

Why is this wrong?


for ( uint16 i = 0; i 3; ++i )
{
uint16 v = mesh.mFaces;
uint16 tv = mesh.mTFaces;

vertices[v].u = mesh.mTVerts[tv].x;
vertices[v].v = mesh.mTVerts[tv].y;
}



Am I missing something? does 3DStudio export UVs in some particular way I'm not aware of?

At least I didn't spend all night working on this, I set up the actual texture loading, so now any texture I specify in max gets loaded and set when the model is drawn. Except, of course, the UVs are wrong.

This is annoying, and I'm too tired to start looking at it.

VisualLR

VisualLR

 

Noooo

Sunday is almost over and I don't feel like I accomplished anything this weekend. Well, that's not entirely true, I did find that I'm not gonna be able to use EaseImport http://www.easeproduction.new.fr. I liked its simplicity and how easy it was to get something up and running, but it appears to be buggy. I thought the problem was on my end, but I saw a post on the site's forum where someone else is experiencing the same issue. If the issue were to be fixed relatively soon, then I'll give it another shot, but I won't be as patient, I already wasted a lot of time.

For now, I'm back to using Flexporter (http://www.codercorner.com), but unfortunately, it is giving me its share of problems. For once, this is a significantly more complex software, so integrating into an existing project is not as easy. And the other part is that again, I'm experiencing some strange behavior with me model's pointer, so it's crashing when I'm trying to build it. This time, I'm pretty sure the problem is on my end, I'm just getting tired, so it becomes difficult to spot problems.

Anyway, I'll have more (though, not much more, since I'll be at work all day) tomorrow.

[UPDATE]

Got flexporter working, I can now load the files, (geometry only). I'll do the textures tomorrow, then I'll move on to loading animations (skeleton hierarchy and the like). But now I gotta go to bed. yay.

VisualLR

VisualLR

 

Found the problem

I found what's causing the strange behavior, but I haven't come up with a solution yet. It's strange, but basically, what's happening is that for some reason the UVs are different on different faces that share a same vertex.

For example,

--- Face: 0
0: -20.00 -20.00 0.00 [ 1.00 0.00 ]
2: -20.00 20.00 0.00 [ 1.00 1.00 ]
3: 20.00 20.00 0.00 [ 0.00 1.00 ]

Notice the UVs for vertex 0, they're 1.0, 0.0 further down the list we have:

--- Face: 4
0: -20.00 -20.00 0.00 [ 0.00 0.00 ]
1: 20.00 -20.00 0.00 [ 1.00 0.00 ]
5: 20.00 -20.00 40.00 [ 1.00 1.00 ]

Now they're 0.0, 0.0 which is wrong, and since this is being mapped directly into the vertex buffer, it's changing UVs that were already good.

So now I have to figure out why this is the case.

VisualLR

VisualLR

 

ARGH!

I'm really pulling my hair out on this one...

So, I'm filling up this vertex buffer with data imported from a file. When I build up the buffer, I'm printing out the texture coordinates to my log file, at this point they are correct. When I build my index buffer, I'm printing out all the contents of the vertex buffer, using the indices into the vertex buffer (I started doing this for debugging). Now on this pass, the UV's have changed, they are no longer correct, EXCEPT, for the last 2 faces (the last 6 tris are correct).

What's scary is that I'm not doing anything with the vertex buffer at between those two things, so something is not telling the truth, I wish I could say that the printing out of the full vertex buffer was wrong, but the scary part is that I see the wrong results in the rendering.

I've gone over the code so many times, everything looks fine...

This is just bizarre, check this out:


for ( i=0; i _topo->_NbFaces; i++ )
{
CImpFace* srcFace = mesh->_topo->_Faces;

DPrint("--- Face: %d", i);
for ( uint16 ref = 0; ref 3; ++ref )
{
uint16 vIndex = srcFace->VertexRef[ref];
vertices[vIndex].u = srcFace->UV[ref][0].u;
vertices[vIndex].v = srcFace->UV[ref][0].v;

DPrint("%d: %.2f %.2f %.2f [ %.2f %.2f ]", vIndex, vertices[vIndex].x, vertices[vIndex].y, vertices[vIndex].z, vertices[vIndex].u, vertices[vIndex].v);
}
}




This prints out correctly:

--- Face: 0
0: -20.00 -20.00 0.00 [ 1.00 0.00 ]
2: -20.00 20.00 0.00 [ 1.00 1.00 ]
3: 20.00 20.00 0.00 [ 0.00 1.00 ]


Now, when I do this:


for ( i=0; i _topo->_NbFaces; i++ )
{
CImpFace* srcFace = mesh->_topo->_Faces;

for ( uint16 ref = 0; ref 3; ++ref )
{
uint16 vIndex = srcFace->VertexRef[ref];

DPrint("%d: %.2f %.2f %.2f [ %.2f %.2f ]", vIndex, vertices[vIndex].x, vertices[vIndex].y, vertices[vIndex].z, vertices[vIndex].u, vertices[vIndex].v);
}
}












If you notice, I'm not doing anything except printing the data again (I got rid of anything else other than this just to isolate this behavior).

This is the result:

0: -20.00 -20.00 0.00 [ 1.00 0.00 ]
2: -20.00 20.00 0.00 [ 0.00 0.00 ]
3: 20.00 20.00 0.00 [ 0.00 0.00 ]

And my cube reflects the incorrect texture mapping.

So annoying, I hate problems like this.

Here's what it looks like:


VisualLR

VisualLR

 

Net coding

So I have this very basic network library, and I can do some real simple stuff with it, and I'm having fun playing with it, making a small crappy chat program, and then it hits me, there is no way I can turn this into a full fledged MMO server in any reasonable time frame, there is just too much to consider. Or I could, but at the expense of writing some other important system, hell, I still need to finish the core renderer (which atm is the most complete system I have).

So, I may put it on the back burner, once again, but I will also consider integrating Open TNL (www.opentnl.org). I mean it's there, I can use the code, if I decide to license it, it's either $300, or $1000 depending on the license... may not be a bad idea after all.

Anyway, I gotta go...

VisualLR

VisualLR

 

It's checkout time.

Time to head home, I can't wait to get there and keep messing with the net code stuff, it's fun.

That's all I have...

Seriously.

Ok, I'm leaving.

VisualLR

VisualLR

 

Finally got stuff to work.

Monday was a bad coding day... couldn't get even the simplest things (that I've done many times) to work, my brain decided to unplug some major areas, apparently. Yesterday started bad, but as it got later it improved.

I got a very crude, slightly buggy chat program running. It's client/server, and I only tested it locally so far, but I was able to run several clients and all the chat data was properly propagated to all the clients.

I don't love the code design, so now that I have a working version I'm going to refactor it and then I'll take a couple of days to design an MMO server architecture (no coding, just on paper). This may involve a trip or two to the nearest bookstore to do some research.

Anyway, today I'm actually working on a cool fun task I can't tell you about... I got it working yesterday, I just need to improve the authoring side of it today.

VisualLR

VisualLR

 

On C# and C++

So, last night I got the urge to start fiddling with some networking code... sadly, I didn't get very far, in fact, I never got into the networking stuff. My first idea was, I'll make the networking library a DLL, then I'll make a small test bed application in C# and I'll get something going in no time. Boy was I wrong. All the hype around C# made me think that using C# with C++ (unmanaged) libraries was straightforward. Perhaps it's just that the information I found is not accurate. But it's something like this:

// Import the creation function with standard calling convention [ DllImport( @"MyDLL.dll", EntryPoint = "??CreateMyClass@@PFWR@Q", CallingConvention = CallingConvention.StdCall ) ]
public static extern IntPtr CreateMyClass();

Which is not too bad, although I do find it very annoying that I need to specify the decorated function name myself, this is something that the compiler should figure out, I guess it'll get better in next versions of the language (there's some talk about it being real easy in VS.net 2005), regardless, that part was annoying, but more annoying is that I apparently need to create a static function in my DLL called "CreateMyClass" that all it does is call new on MyClass and return it.

So, I found all this to be an insane amount of work for such a simple standalone test bed program, so I ended up going for a really simple Win32 app.

So I'm looking forward to going home tonight and just getting the Win32 stuff out of the way so that I can start playing with some net code.

And now, it's time for lunch.

VisualLR

VisualLR

 

Why I don't post interesting stuff

The problem is that I have a conflict, I work in the games industry, so I can't just go freely discussing what I'm working on because I could get in trouble. And when I get home, if I do some coding on my own time, I usually get very into it and do it until I go to sleep, which leaves no time to talk about it here, except the next day when I'm at work, but since I'm at work... basically a while (1) with no breaks.

And it's not like I get to do anything that cool at home anyway, there's only so much you can do and not feel like you're neglecting your loved ones.

Oh, on that note, although I still play World of Warcraft (usually during my lunch hour), I uninstalled it from my home computer, it was too much of a distraction. Now I actually do some productive stuff at home. yay. (I do miss playing though, that game is fun, oh well).

Ok, on a development related note, I'm interested in learning a little bit about how MMOG's client/server architecture works (not so much high level, but low level stuff). Anyone know where I can find some good reliable information on this? I think it would be a really fun "hobbyist" kinda project to make a little MMO system, even if it's just a sort of chat room in its first iteration.

[edit]
Oh, I forgot to mention something... I changed webhosts for my website, and when I did and needed to update the DNS servers on my domain, I found that network solutions had somehow lost most of my website's registration data (even though I had renewed my domain name for the next 6 years about two weeks ago). I had to call them several times and fax them some data that proved I owned the site at some point before I could regain control of it.

But, it's all straightened out and I am going to take the time one of these weekends to really overhaul the site, improve the layout and change some things.

VisualLR

VisualLR

 

back to school?

So I had to take a mandatory course on C++... although I already knew 95% of what was taught, that 5% was actually pretty interesting. The problem is that taking a C++ class 3 days, 8 hours each day is pretty exhausting, and probably not very conducive to retaining half of what they teach... sigh.

So I'm tired, and I'm getting sick, which sucks.

Anyway, VS just finished compiling, so I'm gonna go take a look at what I just did.


VisualLR

VisualLR

 

Back in black

Yay, I'm coding again... it feels live I haven't coded anything since Dec. 1st. I took a whole month off from work, it was real nice. I was missing it though.

I'm playing around with some HDR bloom effects, pretty interesting stuff.

Also been playing World of Warcraft too much... damn Blizzard for making such a fun game. This is the first MMO game I play too, I never really liked any of the other ones (I tried a few).

Anyway, I'm going to get back to it...

VisualLR

VisualLR

 

Bored.

I'm at work and I have nothing to do... especially since I start my vacation tomorry. Well, I still need to come in two days next week, but that's not bad.

I got a new book:

3D Game Engine Programming by Stefan Zerbst.

I no longer buy these books to read them in their entirety, I just got them to read a few interesting chapters and as reference when I'm stuck on some problem. But I'll at least skim through most of the chapters and read anything interesting. I also like to support game development authors whenever I can, they are usually people who not only have a full time job, but they make the time to share their knowledge and experience with the rest of us. Knowing what it's like working in this industry, I know how valuable free time really is now.

Not much else going on, turkey day is upon us, I'll probably spend a good amount of this weekend doing some research programming, writing a couple of shaders, or maybe setting up a little client/server app, I've always wanted to play with networking programming, but until now I had been too busy.

Anyway, I think it's check out time.

LS.

VisualLR

VisualLR

 

Resting

Well, the game I was working on is finally out and I can now rest. It was a long project, but it was so much fun. I truly grew as an engineer and am now a lot better than I used to be, even though I used to think I was pretty good. It was amazing working on a team with scuh talented and smart engineers. I feel comfortable saying that I learned more about software design, engineering, math, graphics, AI, networking in this project than I did in 4 years of school. I am a firm believer that you learn by doing a whole lot more than you do by studying, this is why I had such a hard time in school.

It's satisfying to play our game now. For a long time I only saw our game in snapshots, small parts... there's a bug in a level, you go in, you fast forward to where the bug is, you find the problem, go into the script or code, you fix it and you move on to the next thing... never really playing. Now I get the chance to see all the fantastic work that our designers and artists did with the technology we gave them. Even if they complained about it all the time ;)

I'm really happy with the game we made and I can't wait to get started on the next one.

The only thing that kind of bothers me, but not enough to give it much importance is how reviewers tend to root for the underdog, even when the top dog has a clearly superior product. But I guess it comes with the territory.

And now that I've had some time to play (these are all my opinions, if you disagree, then we must agree to disagree, I won't be convinced that a game does not suck, if I feel that it does).

Doom3 sucks.

WoW is cool for an MMO, it makes me hope they make a Diablo3 soon.

Prediction: Half life 2 will be overrated, but good.

Counter Strike Source: I was never into CS, I tried this and didn't find what millions of other people did... feels like if I was playing an old game, like quake 1... not too bad though.

Sims2: Just like the first one, it was entertaining when I used cheats and made a big ole house with all the cool stuff in it. It got old soon after that.

Finally, the games that I'm looking forward to play are:

LOTR B4ME... coming soon.

HL2 - will probably not look as good as their videos ever did, even on my high end system at work, I hope it's fun.

Prince of Persia 2: The first one was just awesome, best console game I've ever played (this console generation, of course).


And I think that's it... man it feels good to be back to normal.

LS.

VisualLR

VisualLR

 

So, so tired....

Man.... lots of work lately, but it's getting there. We're racing towards the finish line, and although it's still a few weeks away, it feels like it's almost upon us. This explains why I haven't updated this thing in a while... and why this is such a short entry, gotta get back to work.

I'm tired. Very tired. Tomorrow is saturday, but that makes no difference.

out.

VisualLR

VisualLR

 

Bad day.

Not a very good day today. I pretty much think that everything that could have gone wrong did. Not coding wise really, just stuff. A good friend was let go today, they didn't tell us why. This morning he made us waffles, by noon he was gone. So yea, I'm upset.

Other than that... because of the long weekend, I didn't have all my shit together, then we had a review and nothing worked. Bah.

So, I'm looking forward to going home and if I'm lucky, play a little WoW... but more likely I'll go home, watch TV for a bit then go to bed. Exciting is the life of a game developer... eh, I'm just bitter, it usually is a lot of fun, but there are bad days.

All I can say today is. Bah.

VisualLR

VisualLR

 

The word is out.

The first screenshots, and a video of the stuff I've been working on have been released. Here's a cool screenshot of it:


Screenie

yay!

VisualLR

VisualLR

 

Slow day

Slow day today...

Capt. Dale Dye stopped by today, I happened to be in the room where they were going to show him some parts of the game so I stayed to hang out. He's a nice man, he sure has a lot of stories and his insight and advice is really interesting. Last time I saw him was well over a year ago when we went to play paintball (for combat reference, of course). That was a pretty fun time. He would show us combat strategies and then we'd enact them in the field (under his direction). It was very intense and exciting, I can only hope that I get a chance to do that again.

Anyway, I've got a task to do, so no quick tip today, at least not for now.

VisualLR

VisualLR

Sign in to follow this  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!