TOPIC_TITLE
stringlengths 4
128
| CATEGORIES
stringlengths 13
48
| POST
stringlengths 0
85.6k
| ANSWERS
stringlengths 0
146k
|
---|---|---|---|
Ray/Face Intersection | Math and Physics;Programming | This is probably very easy and the sort of thing one could find with a 2 minute web search, but I'm a bit of a thicko when it comes to maths, sorry. [sad]I have a number of faces, each of which lie in a particular plane.I'm trying to move a point from A→B and detecting whether it hits a face as it moves (this is for objects in the game world - when spawned they float above the ground, and they are dropped to the floor by attempting to move them down 256 units).All of the planes are described as a normal and an offset from the origin. As far as I can tell, you can detect which side of a plane you're on by taking the dot product of a position and the plane's normal, then comparing that to the offset. For example,static bool IsInFront(Vector3 position, Plane plane) { return Vector3.Dot(position, plane.Normal) > plane.Offset;}static bool IsBehind(Vector3 position, Plane plane) { return Vector3.Dot(position, plane.Normal) < plane.Offset;}I use this technique to detect which side of the level's BSP partition planes I'm on to calculate what sort of area I'm in (solid, water, lava and so on) so it appears to work. [smile]What I intended on doing was to first check if both points (source and destination) were on the same side of the face's plane, and if so to return (they obviously don't intersect the face). If they do lie on different sides of the plane, however, I'd then like to calculate the point intersection. Once I had that I could check it against the edges of the face to see if it lay inside or outside the face - and if it was I could finally return the point of intersection.My questions, therefore, are: how would you calculate the intersection point of a ray and a plane, and how would you check whether a point lay inside a face or outside it? (I can do the latter in 2D via the cross product and checking the z component of the result). | Check out the SIGGRAPH ray-plane intersection page. It does a good job of explaining the test. There's only a slight modification for segments - if Rd is the unit direction from A to B, then you check to see if t is between 0 and ||B-A|| instead of just greater than 0.As for detecting whether a point is inside a face or not, it really depends on what kind of face it is. You mentioned BSP trees so I'll assume they're convex at least. For simple triangles you could probably get away with calculating the barycentric coordinates of the point, and for other polygons you can use the half-plane method. That's where you create a series of planes that are perpendicular to the polygon plane, yet coincident with each edge, and do a series of front/back tests. Assuming you create the planes such that the normals all face inward, if all the tests return front then the point is inside the face, otherwise it isn't. One advantage of this method is that it works very well for polygons in 3D, since you don't have to project down to a 2D space to perform the test. ; Edit: The posted code had a bug in it, so I replaced it in case anyone found this thread. Some collisions worked fine, others didn't.Thanks for the link, it was very helpful. [smile]/// <summary>Calculate the collision of a point moving through the plane.</summary>/// <param name="start">The starting position of the point.</param>/// <param name="end">The desired end position of the point.</param>/// <returns>Either the end point or the intersection point, depending on whether the point hits the plane or not.</returns>public Vector3 GetCollision(Vector3 start, Vector3 end) {// Get the distance along of the intersection:Vector3 FacingNormal = -this.Normal;float Distance = -(Vector3.Dot(start, FacingNormal) + this.Offset) / Vector3.Dot(end - start, FacingNormal);// Check range:if (Distance < 0 || Distance > 1) {// Intersection point happens behind or in front of the ends of the line.// This means that either the line isn't long enough to make contact with the plane, or that the // line doesn't hit the plane at all (ie, it lies parallel to it).return end;} else {// We intersect the line somewhere along its length.return start + (end - start) * Distance;}}Yes, faces are convex (sorry for not mentioning that). Your second method sounds exactly like what I was after.Addendum: For detecting whether the point lies inside the face or not I check each edge, taking the cross product of the edge vector and the offset of the point from the first edge's vertex. This gives a normal that will point one way if the point is inside the face, the other way if it is outside. I then take the dot product of this value for each edge. If the result is > 0 or < 0 for all faces, then the point is inside; if there's a mixure of > 0 and < 0 then it lies outside.It appears to work quite well, at any rate.[Edited by - benryves on September 12, 2007 4:13:31 AM] |
Creating enums | Old Archive;Archive | ChooseEnum displays all the elements in a enum and asks the user to choose one (by an associated value which is displayed)Is there any way make the following look nicer? (remove the cast and typeof)static int ChooseEnum(Type enumerable)HairColour playerHairColour = (HairColour) ChooseEnum(typeof(HairColour));Also is there any way to create enums on the fly? e.g. load the haircolours from a file.If not I'll need to use some sort of associative container (like maps in c++), should I use Dictionaries? or can people suggest a better alternative?Using dictionaries would make the above code look neater , But I would lose type safety.Hope that makes sense. | Quote:Is there any way make the following look nicer? (remove the cast and typeof)Generics. Unfortunately, generic constraints can't be "enum," but something likestatic T ChooseEnum<T>(); // called like ChooseEnum<HairColor>()static void ChooseEnum<T>(out T result); // called like ChooseEnum(out myHairColor);might work for you.Quote:Also is there any way to create enums on the fly? e.g. load the haircolours from a file.You can achieve the desired result, yes.Quote:Using dictionaries would make the above code look neater , But I would lose type safety.Not neccessarily. What is the implementation you are thinking of? ;Quote:Original post by jpetrieGenerics. Unfortunately, generic constraints can't be "enum," but something likeI was afraid that was gonna be the case, I didn't want to get into 'advance' stuff like generics till I had a better grasp of the basics. Also enum would've worked so nicely for what I was doing.Quote:Using dictionaries would make the above code look neater , But I would lose type safety.Not neccessarily. What is the implementation you are thinking of?The idea is to load a number of strings from a file. The user would then choose from one of these strings and a value for this would be stored. The reason for wanting enums the value would be stored as integers(fast) and when they're displayed I can use strings(slow). They would also be type safe e.g. i couldnt assign a haircolour to an eyecolour.[Edited by - EternalNewbie on September 11, 2007 11:54:58 AM] |
Thinking about taking up game programming | For Beginners | I'm currently going to school for Application Development and am in need of a new hobby. I'm taking my second course on VB with a couple on Java and database programming to follow. I figure by taking up game programming I can learn a new language and have a little bit of fun with it. My ultimate goal is to be able to make an old school 2-d RPG.What I want to know is:What language should I use, and where can I find some good tutorials/learning resources for it?Pre-thanks for anyone who helps me out! | There are many threads on this so searching through this forum board should yield some interesting discussions. Personally, I'd go with Python and PyGame - it's an easy language that allows for pretty fast development. There's some tutorials on the PyGame site, too. |
Creating physical models and scenes for PhysX with "FizX Scene". | Math and Physics;Programming | http://fizxscene.com/"FizX Scene – is a development tool, allowing you to create physical scenes and objects, witch then can be used in your own projects with integrated AGEIA PhysX SDK. It uses visual-based modeling approach with a set of dialogs and menus to create objects and to change their properties. As patterns for physical objects common 3d models are used."If shortly, its a kind of physical editor, allowing to create complex physical models and scenes for PhysX. Follow link above for more details. Its free.Questions? | |
Amazon : self-affiliating possible? | GDNet Lounge;Community | Assuming Amazon still do the affiliate program they used to, can you register your own site as an affiliate and then buy all your Amazon stuff through it? | Quote:Original post by d000hgAssuming Amazon still do the affiliate program they used to, can you register your own site as an affiliate and then buy all your Amazon stuff through it?From their Operating Agreement:You may not purchase products during sessions initiated through the links on your site for your own use, for resale or commercial use of any kind. This includes orders for customers or on behalf of customers or orders for products to be used by you or your friends, relatives, or associates in any manner. Such purchases may result (in our sole discretion) in the withholding of referral fees and/or the termination of this Agreement. Products that are eligible to earn referral fees under the rules set forth above are referred to as "Qualifying Products." ; AMAZOWNED! |
Exporting ms3d to md2 | 2D and 3D Art;Visual Arts | Hi, I'm trying to export an ms3d model to md2. The model has a texture. How do I export it so that the md2 file will also have the texture associated? Many thanks | |
Using opensource icons? | GDNet Lounge;Community | I need some icons for a closed source/commercial program.May I use crystal and tango ?I don't really get the license stuff.Can I use it freely? Modify it freely? Do I have to put a notice somewhere?Anyone experience with that? | You may use them freely, provided that you mention the license under which you use them. For crystal, you must allow your users to change the images at will with minimal difficulty. For tango, you must include a copyright notice of their choice.You may modify them freely, provided that if the modifications are distributed in any way, then they are also distributed under the same license.; You could also check out FamFamFam if size isn't an issue. ; Well let's change the topic to."Do you know more opensource icon themes I could use?".32x32 or 24x24 would be nice. |
Why are so many things in Comp.Sci. Named so we can't search for them on computers? | GDNet Lounge;Community | So, I'm picking away at stuff for an algorithm's class, and started looking around for different methods of searching graphs. Apparently I'm rather tired now. I base this on how long it took me to clue into why searching for A* in google is so highly futile.Anyone have any ideas (serious ones are not pre-req for posting here) about why some of us in Computer Science can miss such an issue so easily when titling a paper for our new and cool development? | Perhaps it's a test by Google. They want to see who can actually find stuff about computing science because you have to KNOW stuff about computing science beforehand to find it, and if you know stuff about computing science you're eligible for a job... ; Your google skills need tweaking.A star tutorialhttp://www.google.com/search?q=A+star+tutorial&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a; I've been wondering this myself. "Light cookies" is another example of this. ; It's because Computer Scientists (i.e. people with a degree that says "computer" and "science" in some order, with or without other adjectives, nouns, and adjective nouns) have huge egos and love to give things descriptively non-descriptive titles that don't make sense, in an effort to make their research sound really advanced. ; It could have been worse - they could have stuck with their original algorithm name - "A". ; Yeah, there is a counterpart to Z buffers called A buffers I think. Although searching for "A buffer" works... ; umm, searching for a* works just fine for me.clickie;A pathfindingresulted in a three relevant pages. A* tutorial, Amid page, and devmaster.What was your problem? BTW game developers are not searching graphs, game developers are working with a nice large detailed land full of colors, grass, trees, and hills. Land like that cant be made into graph without insane computational difficulty *1, or weird glitches. So A* is left for mental masturbation, or that few case where it might work, if there will not be better algorithms.*1 It's not only one time overhead, it has overhead everytime when it should be used, when computing delta. ;Quote:Original post by Raghargame developers are not searching graphs, game developers are working with a nice large detailed land full of colors, grass, trees, and hills. There is no grass, tree, or hill inside your computer, and the colors exit only on your monitor. Game developers are working with a computer-friendly internal representation of that stuff, which includes visibility or navigation graphs. Quote:Land like that cant be made into graph without insane computational difficulty *1, or weird glitches.Which is why everyone uses the reverse operation of transforming computer-friendly data into grass, trees and hills, instead of transforming grass, trees and hills into computer-friendly data. |
Very, very fast event library | General and Gameplay Programming;Programming | When profiling some code I'd been working on recently, I was surprised and dismayed to see boost::signals functions floating to the top. For those of you who are unaware, boost::signals is a wonderfully useful signal/slot library which can be used alongside boost::bind for delegate-based event handling such as one sees in C#. It is robust, featureful, and flexible. It is also, I have learned, incredibly, terrifyingly slow. For a lot of people who use boost::signals this is fine because they call events very seldom. I was calling several events per frame per object, with predictable results.So I wrote my own. Slightly less flexible and featureful. It's optimized for how everyone tends to actually use events. And event invocation is fifteen to eighty times faster than boost::signals.The library relies upon Don Clugston's excellent FastDelegate library and upon the deliciously evil, horribly useful boost::preprocessor library. The former is included; the latter is not, so you'll need to have Boost installed and its headers available to the compiler.A basic usage guide is as follows:#include <event.h>#include <string>#include <iostream>class Subject{public:// events::Event is parameterized by the argument list passed to the event handlers.// I like to make events public and mutable. If you want you can hide them behind// mutators instead.mutable events::Event<std::string const&> NameChangedEvent;// I've decided not to make events invocable via operator(). It's too easy to // accidentally invoke an event in this way.void SetName(std::string const& name){m_name = name;NameChangedEvent.Invoke(m_name);}private:std::string m_name;};class Observer{public:Observer(Subject const& subject) : m_subject(subject){// Registers the OnNameChanged function of this object as a listener, and// stores the resultant connection object in the listener's connection set.// This is all you need to do for the most common case, where you want the// connection to be broken when the Observer is destroyed.m_cs.Add(m_subject.NameChangedEvent.Register(*this, &Observer::OnNameChanged));}private:// I like to make my event handler functions private, delegating to public functions// as necessary.void OnNameChanged(std::string const& newName){std::cout << "The subject's name is now " << newName << "." << std::endl;}// The connection set is a utility class which manages connection lifetimes for// you. It's similar in functionality to boost::signals::trackable, but provides// slightly more flexibility over connection lifetimes. For the normal case,// you only need one connection set per listening object (no matter how many// things it listens to) and you never need to do anything with it except call Add().events::ConnectionSet m_cs;Subject const& m_subject;};int main(){Subject s;Observer o(s);s.SetName("Joe");}This is beta-quality software, and its interface and implementation are both still in flux. It's intended primarily to get ideas flowing here on what form the ideal event library would take. Is this library too much or too little? Are there widely useful features it's missing? In particular, I'm interested to hear whether the ConnectionSet system is reasonable.download (ver 0.08)[Edited by - Sneftel on July 28, 2007 12:59:58 AM] | Could it work with Impossibly fast delegatesI find the above quoted solution to be far too hackish, relying on compiler and architecture specifics, whereas this one is on-par, but only relies on language features.It also contains an example of event dispatching, although I didn't test it. ; I waffled over that for some time. Impossibly Fast Delegates is incredibly elegant compared to Fastest Possible. It is, however, considerably less supported by actual compilers (IIRC, it doesn't even work on VC++.NET 2003). But yes, it should be trivial to change from one to the other. ; I'm not convinced Connection::operator=() handles self assignment properly if m_node && m_node->refCount == 1. It seems like it'd decrease the reference count to 0 then assign 0 to m_node thus annihilating its state. ; *smacks forehead* I'm not exactly sure how that got off my TODO list without actually getting done. Thanks. ; For that matter, while I suck horribly at reading boost::preprocessor code, I can't seem to find assignment operators or copy constructor for the Event<> class (or a NonCopyable inheritance). ; Hmm, you're right. I forgot to copy over the boost::noncopyable designation when I switched to file-based iteration. ; Both of the above issues (and a couple of others) are now fixed in the latest version. ; I'm trying to convince myself of the utility of the ConnectionSet class, and to be honest, I'm failing. It doesn't seem to supply any additional invariants over a container of Connection objects that an object could hold anyway. Right now it just seems like a good way to create dangling references in an Event<> delegate chain. ;Quote:Original post by SiCraneI'm trying to convince myself of the utility of the ConnectionSet class, and to be honest, I'm failing. It doesn't seem to supply any additional invariants over a container of Connection objects that an object could hold anyway.Oh, it surely doesn't. It's primarily there as a simplified adapter class, and as a "best practice" container which can have its implementation modified as necessary. In particular, I've been thinking about ways to be able to free the heap-allocated refcount once the Connection is put in a ConnectionSet, to optimize for the case where that's the one and only reference.Quote:Right now it just seems like a good way to create dangling references in an Event<> delegate chain.Hm... how do you mean? |
Exporting 3Ds Max animations for Gamebryo | 2D and 3D Art;Visual Arts | Hi everybodyI'm having problems when I try to export a 3ds max 8 animation to a NIF file (gamebryo format). It's quite an old eval version of gamebryo, v1.2, however I think it should be able to read exported animations but I can't figure out how to do that.The animation i'm trying to export is a very simple wave motion, created from a primitive plane converted into editable poly, and from which I translate on Z axis a set of vertex at different keyframes to render a basic wave effet. The animation runs well in 3ds max viewer and there is no error when exporting to NIF (or KF, I've also tried that) through the gamebryo plugin, however when rendered into gamebryo I just see a static wave.If I export some other kind of animations like simple texture UV-translations in the same scene, these animations are OK but the first one still doesn't move.So I wonder if i've missed some hidden option that would allow me to correctly export the animation.Does anybody know how to fix this, if ever it's possible?Thanks a lot in advance | All right, for those who could have the same problem, a solution is to use the "Morpher" modifier applied on the editable mesh/poly, and make the keyframes by using the morpher's channels |
Python - C/C++ | Engines and Middleware;Programming | HiI am quite confused by now and hope that someone may shed some light here... :)I want to call C/C++ functions from Python. For this I'm cuurrently using the Boost library, but experience "some" trouble with it.I've created a dll and export some functions from it with the BOOST_PYTHON_MODULE() macro. Thereafter I use bjam to compile the project and all seems fine... except that no dll or *.pyd file is created. Since my boost and python experience is yet quite limited I do not know what to do next.* I'm running this on Windows XP* The Boost python examples compile nice with bjam (no dll/pyd here either)* I can compile the dll with visual studio (but then i obviously won't get a pyd file)* In all cases I get a *.obj and *.pyd.rsp so I get the feeling that some kind of "linking" stage is missing.* I have read the Boost/Python docs several times, but I do not get the results that I should.Can someone please tell me the basics mechanisms of the bjam builder and how the rules work in jamfiles. Any comments are appriciated.Thank you// Javelin | Quote:Original post by Javelin* I can compile the dll with visual studio (but then i obviously won't get a pyd file)This works perfectly fine for me. You need to set the output of the project (Configuration Properties->Linker->General) to a .pyd file. There may be some additional settings you need to set, but I can't think of anything at the moment. ; You can use the ctypes package that's included with python version 2.5 instead of boost::python. It's easier in my opinion. ;Quote:Original post by Omid GhavamiQuote:Original post by Javelin* I can compile the dll with visual studio (but then i obviously won't get a pyd file)This works perfectly fine for me. You need to set the output of the project (Configuration Properties->Linker->General) to a .pyd file. There may be some additional settings you need to set, but I can't think of anything at the moment.So a .pyd is the same as a .dll but with a different name extension? I thought it was a specially processed file to fit with python.(Btw. I graduated from Chalmers in 2003 and now I live nearby. It a small world sometimes... :) )Quote:Original post by smrYou can use the ctypes package that's included with python version 2.5 instead of boost::python. It's easier in my opinion.Tested it and it seems quite nice, but if I understand things correct I can't use C++ classes with it.What I really would like to have is a transparent mapping between python classes an c++ classes. E.g. if I have a class "foo" in c++ I would like to inherit that class to a python class "bar".So if I make a call in python, I dont need to know if the function is defined in c++ or python. The call just looks the same.It sees that Boost.Python gives me this, but I can't figure out how to build the things together. If anyone has a short example (with code) I really would appriciate it.Thanks for your answers. At least it incereased my spirits... ;)// Javelin; I'm an idiot... :]Small typo in my build files...Seems to work now...// Javelin ;Quote:Original post by JavelinQuote:Original post by Omid GhavamiQuote:Original post by Javelin* I can compile the dll with visual studio (but then i obviously won't get a pyd file)This works perfectly fine for me. You need to set the output of the project (Configuration Properties->Linker->General) to a .pyd file. There may be some additional settings you need to set, but I can't think of anything at the moment.So a .pyd is the same as a .dll but with a different name extension? I thought it was a specially processed file to fit with python.I believe so, yes. It is of course different because of the content of the dll, but it's still a Dynamic Type Library. Someone correct me if this is wrong ^^Quote:(Btw. I graduated from Chalmers in 2003 and now I live nearby. It a small world sometimes... :) )It is indeed [smile] Nice to see other chalmerists around here =) ; Which version of Visual Studio are you using? Just wondering because I had 2005 and downgraded to 2003 just to be able to make python extensions work. Maybe there is a workaround now but my experience has been VC 2005 does not like python - or maybe its the other way around.For my own python development i write a C API interface into what ever it is I'm using then I can either use PyRex or Swig to access it. ;Quote:Original post by MrRageJust wondering because I had 2005 and downgraded to 2003 just to be able to make python extensions work. Maybe there is a workaround now but my experience has been VC 2005 does not like python - or maybe its the other way around.The Python C API is incredibly brittle and hard-coded, including macros offsetting into structs to retrieve data, etc. You therefore have to have everything compiled with the same compiler if you want anything to stand a chance of working without cryptic errors.; One of the major reasons that pythons built with different compilers are incompatible is that they use FILE* internally, which is of an implementation defined type. ;Quote:Original post by KylotanThe Python C API is incredibly brittle and hard-coded, including macros offsetting into structs to retrieve data, etc. You therefore have to have everything compiled with the same compiler if you want anything to stand a chance of working without cryptic errors.Oh, wow. No wonder I couldn't get Pygame to install.Are there plans to fix this, either before or in P3K? |
How to change the font style in DirectX9 | Graphics and GPU Programming;Programming | Hi!Im asking myself how to change the font style after creating the global ID3DXFont font.I only know the following sequence:1.) Creating the global ID3DXFont font object with a font description:D3DXCreateFontIndirect(ptrD3DDevice,&FontDesc,&DxFont);2.)Use this font object to draw text with the DrawText-Method.Where can I change the style when I want to use "Arial" and then "Times New Roman"...ID3DXFont has a GetDesc-Method but no Set(). | You'll need to create a new ID3DXFont object for each font/style you want to use. You can have several ID3DXFonts at the same time, and draw some of the text with one, and some with the other. ;Quote:Original post by sirobYou'll need to create a new ID3DXFont object for each font/style you want to use. You can have several ID3DXFonts at the same time, and draw some of the text with one, and some with the other.I thought it would be the same as with the sprites where you only have ONE sprite object.Is there a limit for ID3DXFont-objects or could I create a Text-class, and each instance of this class would have its own font object? ;Quote:Original post by DelrynIs there a limit for ID3DXFont-objects or could I create a Text-class, and each instance of this class would have its own font object?I'm not aware of any hard-set limit. Naturally, you'll be limited by memory, and it's important to note that each ID3DXFont object has it's own texture internally, and with larger fonts, this texture would be pretty big.You don't have to, but it's recommended that you only have one ID3DXFont object per possible font/style combination.Also, as long as you pass them all the same ID3DXSprite within one Begin/End sequence, you shouldn't have any particular performance issues with multiple ID3DXFont instances.Hope this helps. ; This helped, thx :)How can I use this function with a ID3DXSprite? Simple create a sprite and pass it? What does the drawtext function with it?;Quote:Original post by DelrynThis helped, thx :)How can I use this function with a ID3DXSprite? Simple create a sprite and pass it? What does the drawtext function with it?If you already have an ID3DXSprite, then you can pass it to DrawText.DrawText uses the sprite for batching - think of ID3DXSprite as a vertex buffer manager, when you call ID3DXSprite::Draw(), it just adds the sprite to the vertex buffer - likewise, passing the sprite to ID3DXFont::DrawText causes each letter to be drawn as a sprite, meaning better performance.You'll only see better performance if you're calling DrawText more than once. The font object manages a texture internally, and renders glyphs to that, then draws them applied to textured quads. If you call DrawText twice in a row with no sprite specified, the font object has to draw the text in two batches, otherwise it can queue both draw calls up to the sprite, and let it draw them in one go.My explanation sucks :P |
What books did developer read for game development in the 1990s? | For Beginners | I want to make a game But I wonder how game developers worked in the 1990s, how they made games, how they learning before the Internet became as widespread as it is today. etc.how do they know how to build game mechanics as character ability power up system?how they know to reverse engineering game competitor company.what book I should read? | As far as I know (not being a programmer myself), books on the subject started appearing in the early 2000s. Up to that point, it was “learn by doing” and tips from one another. ;The first book that came to mind was Tricks of the Game-Programming Gurus: Lamothe, Andre, Ratcliff, John, Tyler, Denise: 9780672305078: Amazon.com: Books, which was geared toward beginners/students/amateurs. There were others, but that's the best selling pre-2000. After that point in time, game development became a hot topic in the book publishing world. Even GameDev.net has a series - Beginning Game Programming: A GameDev.net Collection (Course Technology Cengage Learning): 9781598638059: Computer Science Books @ Amazon.com.Otherwise, in the professional realm a lot was “learn by doing” as Tom said, or through word of mouth on early Usenet/IRC/websites (pre-GameDev.net in 1999 - see About GameDev.net). ;Computers in that era didn't have an OS like we have today. The machine booted, and you were dropped in a command shell or in an interactive BASIC interpreter. You basically programmed directly at the metal. Video memory was directly accessible, by writing in a known address range you could make pixels appear at the screen in various colors. The “OS” had a corner in the memory too for its data, but nothing prevented you from poking around there. Lua, Python, C#, C++ didn't exist, ANSI-C was just invented (K&R book about that was in 1989 iirc). Assembly language of course did exist (with books) and was used.Monthly computer magazines were published for all types of home computers. Tips and tricks were exchanged in that way, also program listings were printed in those magazines that you could then enter at your own computer. Studying those listings, and trying things for yourself is how you learned. There was also technical documentation about the computer.If you want to enjoy that stuff, today there is a retro-computing movement, that lives in that era, except with slight more modern hardware but still no OS, etc.;Alberth said:Computers in that era didn't have an OS like we have today.In the 1990s there was MSDOS, Several versions of Windows, and of MacOS. And that's not all the operating systems of the nineties, most likely.Like Linux, for instance.;Tom Sloper said:Alberth said:Computers in that era didn't have an OS like we have today.In the 1990s there was MSDOS, Several versions of Windows, and of MacOS. And that's not all the operating systems of the nineties, most likely.Like Linux, for instance.Yep. There were things like Windows 95, Win 98, and at the time I was still using a Commodore Amiga (AmigaOS) .To deal with the original question “what game dev books was I reading in the 90s?” Back in that era, one of my favorites was : The Black Art of 3D Game Programming by André LaMothe. ;Abrash was the guy who did the Windows NT graphics subsystem and worked on Quake.https://www.drdobbs.com/parallel/graphics-programming-black-book/184404919 ;There are a couple of" history of video games" books, that track the rise of the medium and genre.Just google for them. ;GeneralJist said:There are a couple of" history of video games" booksThat's not what the OP is looking for.;Thanks all |
Choosing a career in AI programmer? | Games Career Development;Business | Hello everyone, my name is Ramon Diaz; I am currently studying Game development and programming at SNHU. I have taken the initiative to learn about a professional career in AI programming. I have a lot of gaps in my development in the short term. I have blueprint experience with AI but not enough to choose a career in this profession. I would like to know how I can be competitive leaving the university in 5 months after finishing my studies. I am looking for knowledge from all of you who have been in the industry for years. | Entry level? Know your algorithms, it will help you at interviews. If you have made demos it can help you get jobs, but the market is wide open right now and should be relatively easy to find work for the foreseeable future. Overall, it reads like you are on the right path. When you graduate and start looking for work, be open to any positions rather than just an AI specialty. Once you have a job it is easier to transition into whatever specialty you prefer.;Thank you. ;I would like to know how I can be competitive leaving the university in 5 months after finishing my studies.Talk about last minute. Create AI projects? Or A game with character behaviors? Pathfinding examples. Crowd movements. Anything really. Learn how navigation meshes work.;@dpadam450 Character Behavior is what I doing in the project at this moment. Everything related to AI programming.;@dpadam450 Is it the same when learning C++ in AI as visual scripting Blueprint? If I were to make a demo, what kind of programming should I focus on my attention? ;@frob It is important to have a portfolio? ;Not for programming. You will need to show you know how to do the work, but it is usually some interview questions and writing some code of their choice. If you have something you want to share with them, you can do it if you want. Having done fancy demos can sometimes help get interviews, and can help show your interest and abilities, but it is generally not needed. It does not hurt, unless you do it badly and therefore becomes a cautionary warning. Build it if you want. I have interviewed and hired bunches of programmers without portfolios. ;I'm studying AI at the moment, in terms of statistical learning. I've learned so much about AI over the past few weeks. Check out: https://hastie.su.domains/ISLR2/ISLRv2_website.pdfandMachine Learning with R: Expert techniques for predictive modeling, 3rd Edition |
Newbie desperate for advice! | Games Business and Law;Business | Hi allI'm new to the game development community and need some advice.I've created 2 educational games with a simple idea but are sufficiently challenging for all ages. These could be played on pcs or phones.Is it worth patenting any parts of the games?What would be the best way to monetize?How should I market the games? | hendrix7 said:I'm new to the game development communityReally? Your profile shows that you've been a member here since 2004, and your last activity was in 2007, asking about raycasting.hendrix7 said:Is it worth patenting any parts of the games?Probably not. Expensive and there will be hurdles, and possible lawsuits after the patent is granted (if it is).hendrix7 said:What would be the best way to monetize? How should I market the games?There are several threads here in the Business and Law forum about that. While you wait for more replies from the community, you can read up on those previous answers to those questions. Mainly, “you should have thought about that before you finished your games.” (You wouldn't be “desperate” now.) Good luck with your sales!;@hendrix7 Filing for a patent can be expensive, and you need to document the solution and how it separates from anything else. I have developed software that solved problems in a way that no other software does, but there is only a very small portion of that that can actually be patented. Even though you can file an application yourself, I would recommend hiring an experienced IP attorney. This too is very expensive, though, so you are best off doing this if this idea can provide millions in income. If it can't, then it's actually not that harmful if anybody copies it.You could look at registering trademarks, design and other parts of the games. This is cheaper, but it will protect you brand more than your idea or solution.Again, if this is something that could turn a real profit, it might be worth looking into. If not, it's a very costly waste of time.As for marketing - my day job is actually creating videos and commercials etc., so naturally that's the first thing that comes to mind.Make videos for social media or other platforms where your target audience is likely to see it. Oh, and you need to define a target audience. Know where they are, what they respond to, what their struggles are and how your product will solve their problems, enhance their life experience or in other ways contribute positively to their life.There are several other ways to do this, but the list exceeds my level of expertise in the area.;patenting is costly, and time intensive. As said above, it depends on a lot if it's worth it. ;@hendrix7 Nothing is worth patenting unless you're willing and able to defend your patent. There is no patent police; you're responsible for finding and prosecuting infrigement.What you're patenting has to be novel and non-obvious to a person skilled in the art. You called your idea ‘simple’ which makes me wonder if it's obvious or already in use.;@Tom Sloper Thanks TomI have been programming for a while but not games until now.Thanks for getting back and your advice, particularly patents.;@scott8 Thanks for your reply.I see. The play of the game utilises basic maths skills so I'm guessing it'll be difficult to identify anything that's unique. I suppose, in a similar way, it would be difficult to patent something like ‘Wordle’. Am I right? |
Hi I'm new. Unreal best option ? | For Beginners | Hallo everyone. My name is BBCblkn and I'm new on this forum. Nice to virtually meet you 🙂. One of my biggest dreams is to make my own videogame. I love writing design as in text on how my dream game would be. Now I got no skills to create it. But who knows what life will bring. Is Unreal the best program to have fun with an experience ? Obviously I prefer a simple but capable program. Not pre designed auto drop. Why not install Unreal and roam into it and see if anything happens.My favorite games are in the genre of Fantasy, usually stone age with magic. Dota, Homm, Diablo and the odd one out is the genius Starcraft 1. But I played plenty of different games, especially when I way younger. I don't game currently at all but designing gets my creative juices flowing and is so inspiring and fun. Thanks for having me guys | BBCblkn said:My name is BBCblknI am truly sorry for you. Even Elons daughter has a better name than that.BBCblkn said:Is Unreal the best program to have fun with an experience ?Give it a try, but it's not meant for total beginners.Starting small always is a good idea. 2D is easier than 3D. You could try GameMaker, learn some programming language, learn some math, move on to more advanced engines like UE or Unity… ;There's honestly no perfect program for beginners. If I had to compare Unreal though at my skill level, I would probably pick Unity. However, It really comes down to your needs, and how much programming you want to learn. Furthermore, I would also keep in mind other engines.;@BBCblkn I'd recommend Gamemaker studio 2 as a first engine. It's easy to learn and I haven't had a problem making my game ideas in it yet.There are some good tutorials on YouTube to follow to learn it. Do note you'll be limited to 2D games with GMS2.Bit late to the post, but I hope it helps;gamechfo said:Bit late to the postTwo months late. Always consider whether you honestly believe that a question asked long in the past is still awaiting an answer. Thread locked. |
How to publish a book? | GDNet Lounge;Community | Hello, So, over the holidays I finished my 1st book. Do any of yall writer types know where I can find:an editorpublisherIt's like 99% done, just need to know what to do next. Also, it's cross genre, so it doesn't necessarily fit the standard model. | You've given nowhere near enough information to get a final answer, but I can suggest next steps for you. (For background, I've worked as an author, co-author, editor, and ghostwriter on 9 books so far.)Publishing is a business deal. You need to figure out what business services you need.Do you even need a publisher? Do you need a distributor? You already mention needing an editor. Do you need marketing? Do you need retail agreements? Digital or physical? If physical, POD or offset, how many each of hard or soft, what size of print run can you afford? What business services do you need? Publishers have an awful lot of potential features of what they can provide and what those services cost.Once you know the list of services you actually need, your favorite bookstore will have books that have listings of all the major publishers and hundreds of minor publishers, along with the services they provide and the specialties they work with. Work through the listings methodically, and talk to them all until you've got a deal. You'll also want to start shopping around for a lawyer at that point, both because they have connections and because they'll be working with the contracts you'll be signing.Once you know what you need and have talked with your lawyer the first few times, you will be ready to start shopping around. It's far better if you have more money and are using the publisher as a paid service. That is, you pay them for the services they provide up front. It will cost you many thousand dollars but you'll require far fewer sales to reach profitability. It can be better to do an online plus POD service starting out if you're self funded. If they need to front any of the money there will be two phases to the deal, one phase before it's profitable and another after a threshold is reached and it's profitable. The exact terms will depend on your needs and the services they'll be providing. Before you sign with anyone, you'll need to work back and forth more than once with your lawyer to help you negotiate what's fair in the agreement. Good lawyers understand the costs of the various services and can help you get fair rates.Just like publishing games, the more you need from them the harder your pitch becomes. If you need a lot of services the more it will cost you. If you're looking for them to invest in you, front you money, and pay for the books, don't expect a lot of money from the deal, and in addition your pitch needs to be amazing and you'll be rejected many times. If you've got the money to self-publish and are only looking for retail agreements that's rather easy. ;hmmmWell Self publish might work too. I'm looking for:an editor publishing distribution for ebookNo hard cover or physical book planned at this timemaking cover art. Future Audio book production. I think that's it. I'd be willing to do physical print if needed, but I don't really want to pay for that at this time. frob said:You've given nowhere near enough information to get a final answer The issue is I don't know what questions or criteria I should be asking or looking for. ;Have you considered publishing with Packt?https://www.packtpub.com/;GeneralJist said:2. publishing distribution for ebook 3. No hard cover or physical book planned at this timeFor distribution of an ebook there are plenty of options. Amazon is the biggest with kindle direct publishing requiring little more than an html file and an image for the title. If you are comfortable with software tools you can use that same document to build/compile every other format out there. You're on the hook for everything else with the business if you go that route, but it can work well if you are marketing through your own channels.There are many ebook publishers out there targeting specific platforms and specific readers or specific genres. I mentioned publisher lists, they also include electronic-only publishers. Understand the tools they use against piracy are also helpful since otherwise anybody with access to the file can make unlimited copies.Be careful of contracts, you almost certainly want something that has a non-exclusive agreement since you've done all the work yourself already. If a publisher wants an exclusive deal they need to be putting quite a lot on the negotiating table.GeneralJist said:4. making cover art.Find an artist with the style you like and contact them. Often it's in the range of a couple hundred bucks, especially for ‘unknown’ artists when they're starting with something that wouldn't have seen the light of day otherwise. Artist friends are best, and asking around at local art schools is inexpensive.GeneralJist said:5. Future Audio book production.If you don't need it now, it's something easily done later.GeneralJist said:1. an editorThis one is the most difficult. Skilled editors are amazing. If you go with a publishing house they'll provide professional editors, at professional rates. ;taby said:Have you considered publishing with Packt?https://www.packtpub.com/hmmm 1st time hearing of them.Looks like they are more of an educational option?My book is a mix of mental health journey auto bio, and Sci Fi elements. It's not really a standard “how to” for game dev. ;so I just heard back from my 1st publisher submission.https://triggerhub.org/And they essentially say they be willing to look at it deeper, and have extensive edits to focus on the mental health angle. but they would want me to cut a lot. From what they are hinting at, It sounds like they want to cut a lot of the Game dev and gaming journey, as they are a publisher focused on mental health.So, now I need to decide what to do.I sent them back an email saying I'm open to continued dialogue.Without knowing exactly what they want to cut, and edit, I don't know how to proceed.Also, would it be better to hold out, and find a publisher that is willing to accept most of the game dev journey, as I'm looking for a continued publisher to work with, aka accept most of the book as is. Any advice would be helpful.Thanks yall. ;GeneralJist said:Any advice would be helpful.Look into your own mind and heart.;hmmmok,So I've submitted to a few other places.We shall see.I submitted to this place called author House, and they got back to me really quick, but it looks like they want me to pay a couple thousand for a package:https://www.authorhouse.com/en/catalog/black-and-white-packagesI personally find that a bit frustrating.I mean, really, I wrote the book, I thought traditional publishers get paid from a % of sales?@frobWhat do you think?Is the above package a good deal?I was also a little put off, as it seems the person who called me didn't even read anything about my book, and asked me “so what's your book about?"beyond the above, how does this usually work? Edit: so, after a bit of basic research, it seems the above organization is a bit scamy. The hunt continues. ;You're unlikely to get a publisher deal, where the publisher pays you an advance and distributes your book to retail outlets.You'll have to self-publish, meaning you have to bear all the costs for printing, and nobody will distribute it for you. https://en.wikipedia.org/wiki/Vanity_press |
First-person terrain navigation frustum clipping problem | General and Gameplay Programming;Programming | I am trying to develop first-person terrain navigation. I am able to read a terrain and render it as well as to move around the terrain by interpolating the location of the camera every time I move around. The main problem I have is that depending on the terrain, i.e. moving on a sloping terrain, the near plane clips my view (see below). What is the best way to avoid this? Presumably, I can interpolate the heights for the bottom corners of the near plane … any help would be appreciated. | I believe this can aways be an issue. I mean if you are clipping to a near plane and that plane passes through geometry, it has to do something. That being said you technically don't have to clip to a near plane at all, however many graphics APIs require it. Another other thing to consider is once you have collision working, you can put your camera, including your near clipping plane inside a collidable object, for instance a sphere, such that this problem will never occur. If you are eventually going to make this a real first-person game, that should take care of the problem since your camera will be inside the players head. Even in a 3rd person game you can put them inside a floating sphere. ;Gnollrunner said:That being said you technically don't have to clip to a near plane at all, however many graphics APIs require it.The near clip plane is always needed, even if you use a software rasterizer. If you don't do the clipping, vertices would flip behind the camera, causing glitches way worse than what we get from clipping.mllobera said:What is the best way to avoid this? Presumably, I can interpolate the heights for the bottom corners of the near plane … any help would be appreciated.Yes, basically you want to ensure that the camera is in empty space (above the hightmap), not in solid space (below the heightmap).But in general you can not treat the camera as a simple point, because the front clip plane requires a distance larger than zero. So ideally you build a sphere around the camera which bounds the front clip rectangle of the frustum, and then you make sure the sphere is entirely in empty space, for example. In the specific case of your terrain not having too steep slopes however, it should work well enough to sample height below camera, add some ‘character height’, and place the camera there. That's pretty simple and usually good enough for terrain.It's quite a difficult problem mainly for 3rd person games in levels made from architecture. It's difficult to project the camera out of solid space in ways so the motion still feels smooth and predictable.Some games additionally fade out geometry which is too close, attempting to minimize the issue.Imo, the ‘true’ solution to the problem would be to let the clipping happen, but rendering the interior volume of the geometry as sliced by the clipping plane.That's pretty hard with modern rendering, which usually lacks a definition of solid or empty space. But it was easy to do in the days of Doom / Quake software rendering. When i did such engine, it was possible to render clipped solid walls in simple black color. This felt really robust and not glitchy, so while it does not solve all related problems, i wonder why no game ever did this. ;@undefinedJoeJ said:The near clip plane is always needed, even if you use a software rasterizer. If you don't do the clipping, vertices would flip behind the camera, causing glitches way worse than what we get from clipping.You can clip to a pyramid instead of a frustum. I used to do this many years ago on old hardware. So there is no near clipping plane. In fact you don't need a far clipping plane either.Edit: Just wanted to add as far as I know the near and far clipping planes mostly have to do with optimizing your Z resolution. If you are dealing with that in other ways, I think they aren't strictly necessary. I currently don't even deal with the far plane and let LOD solve Z-fighting issues.;Gnollrunner said:You can clip to a pyramid instead of a frustum.I see. You still have front clip. It is a point, formed indirectly as the intersection of the other other frustum planes.I've misunderstood your claim to be ‘you don't need a front clip’. But you didn't say say that. Sorry. But now i'm curious about the experience with z precision you have had. I guess it just worked? Which then would probably mean: All those painful compromises of ‘make front plane distant so you get acceptable depth precision for large scenes’, are a result of a bad convention being used by APIs?Or did you use no z-Buffer? ;@undefined My whole engine is based on aggressive LOD and culling. I don't do projection in the matrix. It's a post step. My Z coordinates are world distances. My current project does have a near clipping plane mainly because DirectX wants one, but it's not that relevant for my application.;Ah, so you use the pyramid for culling only. But for rasterization, the usual front clip plane at some distance i guess.Still an interesting question if ‘some distance’ is really needed, but i guess yes.I did some experiment about point splatting. It uses spherical projection, which is simple than planar projection:auto WorldToScreen = [&](Vec4 w){Vec4 local = camera.inverseWorld * w;if (local[2] < .1f) return (Vec3(-1)); // <- front clip at some distance of 0.1Vec3 screen = (Vec3&)local;screen[2] = length(screen); // if it was zero, i'd get NaN herescreen[0] = (1 + screen[0] / (screen[2] * camera.fov)) / 2;screen[1] = (1 + screen[1] / (screen[2] * camera.fov)) / 2;return screen;}; Planar projection would cause division by zero too, i guess.;Thanks for all your comments! I will need to investigate how to do what Gnollrunner proposed (about putting the camera inside of a sphere). ;This may be obvious, but in case it helps:Let me note that, as a first-person camera may be more likely than a third-person camera to draw very close to geometry, it likely makes some sense to have a smaller near-plane distance for the former than the latter.Now, this only ameliorates the problem, it doesn't remove it entirely: it means that the problem will still appear, but only if the player gets very close indeed to a surface. It's intended to be used in conjunction with one or another means of preventing the camera from approaching quite so near to a surface (such as the sphere-approach mentioned by others above).;Thaumaturge said:This may be obvious, but in case it helps:Let me note that, as a first-person camera may be more likely than a third-person camera to draw very close to geometry, I'm not sure that's so true. I mean in both cases you have to take care of the problem somehow. The case of a first-person camera is a bit easier because it should always be in the collision boundary of the player (sphere(s), ellipsoid, capsule etc.). As along as the near plane is also within that boundary, the problem should never occur. So if you have a 10cm radius sphere and put the camera in the back of it, that gives you maybe a 10 to 15 cm camera to near clipping plane distance to play with depending on the field of view you are going for. With a 3rd person camera, you can also get very close to terrain, in fact your camera can end up within terrain or some object if you don't do anything to solve that problem, and this will happen very often without separate camera collision. One typical way to handle this is just implement your following camera, ignoring terrain considerations. Then to figure out your camera's actual position, project a line back from the head of the avatar to the camera's ostensible position, and see if it intersects anything to get the camera's true position. In reality you should project a cylinder and not a line since your camera will need its own bounding sphere to contain the near clipping plane. In any case this means that as you move around your camera can jump forward to clear terrain and objects. I've seen this in a few MMOs. However, when you leave blocking terrain you have the option of implementing smooth movement back to the cameras desired location. If you want to get really fancy, I guess you could try to predict when your camera will need to jump forward ahead of time and try to do smooth moment forward too. Maybe you can have a second camera bounding sphere which is somewhat larger, that would trigger smooth movement, but I think you would still need a fallback camera jump routine to be safe. |
How to render to texture with opengl | Graphics and GPU Programming;Programming | I finally got around to trying to implement shadow mapping on opengl just as a learning exercise and I found that I have no idea how to set render targets in OpenGL. I know in GLSL, you can write to gl_FragData[n] but how do you set what texture corresponds to that? I read up a little on FBO (Frame Buffer Objects) and it seems to do what I'm looking for. But it surprised me that it's still an EXT extension since DirectX seemed to have had the ability to set render targets for a while now and one would assume that OpenGL would have had this important feature put in the spec by now. So I tried leafing through the OpenGL 2.1 specifications and I couldn't find any standardised way of setting render targets aside from using extensions like FBO or pbuffers. Am I missing something? Is there really no standard method in OpenGL to set render targets or even multiple render targets? | Look at the Texture Buffer Object 201 Article in the OpenGL Section on this site. There is cleary explanied how to render to multiple targets. ; You can look at my examplehttp://steps3d.narod.ru/downloads/msrt-src.zip - it shows how to render to serveral render targets and uses FBO's to render to. |
Importing Unmanaged Code into Managed Program | Graphics and GPU Programming;Programming | I have a sea rendering code in Visual C++.But All my project is in Visual C#.Now I have made the DLL of the Unmanaged Code and import it in Managed Code in Visual C#.Let me know if there is some performance penalty or decrease of FPS while using/importing Unmanaged Code into Managed Program.thanks and regards. | |
ToLua Tutorial | Engines and Middleware;Programming | I'm currently trying to add a Lua binding wrapper to my project, and after testing LuaBind I would like to test toLua.Can anybody point me to a good tutorial on getting started with this tool? | One of the problems with all the Lua wrappers is that there just ins't enough info on the intertubes to implement those libs in our projects.It's unfortunate. I would like to try toLua, but I think I'll just revert back to luaBind... ; Well the problem is that for most Lua related projects the manual is treated as the definitive documentation. You didn't mention whether or not you had looked at the manual for toLua, but here it is for reference.An updated version can be found as part of the toLua++ package here. Maybe this would be more useful because I think toLua++ is still actively being developed. ; I've just readed the info in the reference you linked and I still have no idea how to use ToLua. I mean, i readed somethink like an "executable" but there is nothink ".exe" in the file you download...Please answer to a very beginner level... I have a very good understanding of c/c++ language, but I still get freezed everytime a reference shoots me with source code and tells me "build it" ; I do not know of another tutorial then their documentation page Zorbfish already referenced. I found it good information and got me up and running with Tolua++.What tolua basically does is converting your class prototypes (which you must manually create in a seperate file) to Lua tables which you later can use in your scripts. Thus say that you for example have the following class (the upper): // your real class definitionclass Character {public: Character(); void setPosition(int x, int y); int getXPosition() const; int getYPosition() const;private: int _x, _y;};// tolua class prototypeclass Character{ Character(); void setPosition(int x, int y); int getXPosition() const; int getYPosition() const;};Then you must create the class prototype as the lower one. Then compile this prototype file with the tolua++ executable to a tolua library (see tolua docs). For example if you called your prototype file you can compile with the following line:tolua++ -o tolua_character.cpp -H tolua_character.h -n character character.cpp- tolua_character.cpp & tolua_character.h are the sources created by tolua- character is the name of the tolue library- character.cpp is the prototype fileYou now can include the tolua_* files to your project. When you have created your Lua state call the following code (do not forget to include the tolua_character.h file):tolua_open(luaState);tolua_character_open(luaState);You now can create characters and call methods in your Lua scripts:local char = Character:new()char:setPosition(5,5)I hope this explanation helps you getting tolua running. |
Best way to do this? (OOP, Trees) | General and Gameplay Programming;Programming | Hello folks, yet another design principles question:Let's say, I have a class which is a graphical representation of some data modelclass MyDataModel : SomeTreeModel{ <...>}class MyDataModelGraphicalRepresentation : SomeSceneGraphNodeClass{MyDataModel* theDataModel;void GenerateGraphicalRepresentationFromDataModel(){ buildRepresentation(theDataModel);}}The graphical representation keeps a reference theDataModel to the data to construct the geometry from. The data model itself is tree-based. The MyDataModelGraphicalRepresentation class is some scene graph library node class extension.My question is, in what way you should store the reference to the data model. For now, I can think of 3 options:1) Store a pointer to the data model. Have it allocated and deallocated outside the MyDataModelGraphicalRepresentation class object and pass the pointer.class MyDataModelGraphicalRepresentation{MyDataModel* theDataModel;void SetDataModel(MyDataModel* dataModel){ this->theDataModel = dataModel;}void GenerateGraphicalRepresentationFromDataModel(){if(this->theDataModel) buildRepresentation(this->theDataModel);}}2) Store a pointer to the data model. Have it allocated and deallocated INSIDE the MyDataModelGraphicalRepresentation class object and pass the pointer.class MyDataModelGraphicalRepresentation{MyDataModel* theDataModel;MyDataModelGraphicalRepresentation(){ theDataModel = new MyDataModel();} MyDataModelGraphicalRepresentation(){ delete(theDataModel);}void GenerateGraphicalRepresentationFromDataModel(){if(this->theDataModel) buildRepresentation(this->theDataModel);}}3) Store the tree as an automatic variable. If you want to set the tree data, a deep copy of the tree is done.class MyDataModelGraphicalRepresentation{MyDataModel theDataModel;void SetDataModel(MyDataModel& newDataModel){MyDataModel.setDeepCopy(newDataModel);}void GenerateGraphicalRepresentationFromDataModel(){ buildRepresentation(this->theDataModel);}}What do you think? | It all depends on the ownership model you want to use.If you want to "tack on" your object on top of an existing data set which always has a longer lifetime than your object, then using a reference to the object (without any ownership semantics) will work.If you want your object to manipulate a data set independently of the original data set, then some exclusive ownership scheme (for instance, aggregation) with initialization by copy is better.If you want shared ownership of the manipulated data, use an adapted pointer type, such as boost::shared_ptr. |
age = noobness? | GDNet Lounge;Community | I have been told many of times of many of forums that since im sixteen im a noob...whats with that stuff. i got 5 years of c++ under my belt like many of people...but since im young i guess it doesnt matter how much experience i got, i will never e taken seriously?so whats up with that i know guys in their mid twenties that got 2 of three yers under their belt and people consider them goow experience people(which i think otherwise). Im not considering myself a expert of even close to being a "experienced person". I just want to people to take people my age seriously even thoe we are young....seriosly if everyone started programming at this age the games would be better...since you would take a serious challenge when your twentiesh and with all this time thinking you get greater and more originals game ideas for the future. so whats up with the discimination thats all... | The people in their 20s, is that 2 years experience at work? Experience using C++ in a job is way more valuable than as a hobby. I had been programming in C++ for ~7 years when I got my first programming job, and had made some pretty cool things, but my code was really bad. I never knew it was bad though until a year or two later I went back to it...And saying you have X years C++ is all very well, but show us screen shots of what you made. A demo is way more convincing...And also, teenagers are simply less mature than people in their 20s - much more likely to think their idea is new and they are going to change the world, rather than think why nobody else already did what they want to. I'm talking averages here - I'm not saying you are immature just because you're 16. ; This is a point that is raised on IRC occasionally. We don't know you beyond what you've typed up on the screen, and thus our only impression of you comes from the way in which you present yourself.Sloppy spelling, lack of punctuation and inability to use the shift key, therefore, don't leave a very good first impression, no matter how good you happen to be with C++ - regardless of age. ; Why do you mention your age? If you do not consider that being sixteen years old is a relevant piece of information when assessing your messages, refrain from saying that you are. If you insist on mentioning it, people will use that information to estimate your competence by comparing you to the average sixteen-year-old they know. On the other hand, a 25-year-old has nine years of life experience that a 16-year-old doesn't have, including the bits about "learning how to learn". Without additional information, I would consider a 25-year-old with 2 years experience a more competent person than a 16-year-old with 5 years experience in about any domain of competence.Ultimately, "5 years of C++" is a very misleading sentence. C++ is a language which can only be completely mastered if you spend many years learning its intricacies, and this assumes that you were familiar with development, computer science, the C language, and language semantics theory. I'd say I need at least two or three more years to fully master C++, and I've been going at it since 1998. So, "5 years of C++" could be "5 years of learning how to use Modern C++", or they could be "5 years of using the C-with-classes subset of C++ without any regard for defined behaviour". And this makes the statement worthless to assess your actual skill. ; Yea I understand all this I guess I was just interested in some replies from other peolple to conclude my theory. Where im from lots of people in their mid twenties take this as a hobby. I will say that my programming is more then a lil scratchy, I have troubles all the time remembering things since I have school and still program after and before it starts.But i will start presenting myself better by using shift and and punctuation marks more often. ; Guess what, people are going to make assumptions about you based on who you are, how old you are, what you look like, your economic background, how you write, etc. Here's the thing, you can't do a damn thing about. Just accept it and move on. The only way you will change their minds is with your actions. Your words are useless. ; Age is an arbitrary variable.Not quite so, of course; but for instance I'm nineteen but I like to present myself as a sixteen-year-old -- and people actually believe me this and don't find it unmatching for me. What does my age of nineteen mean then? Well, nothing. Mental age doesn't have to correspond to your physical age -- and you can do something about your mental age -- as opposed to your physical age. Let those people who tell you you're a noob just because you're sixteen be a motivation for you to get better.And as to the Internet subculture, age is usually not given much value -- at least not on the places that I frequent. My e-friends (whom I actually do know personally) range in age from fifteen up to thirty-three -- it must be a funny look to see us gather somewhere, but so what?And then there's the thing that benryves mentioned -- all the people behind their screens can only judge you by the letters that you type. If you look like a noob -- well, then you are a noob in their eyes. Don't look like a noob and you won't be one. Of course, this is not only about pressing Shift and paying some attention to your grammar, but rather your attitude to others in general. Myself, I don't mind people using lowercase everywhere and forgetting to use proper punctuation as long as they're nice to others.People and interaction with them is a very broad topic about which many book have been written and your problem falls into the scope of these books. You certainly can do something about that, but this is a game development forums, geeks live here -- it's kind of like asking a medical question here -- majority of the people here don't specialise on the topic, unfortunately.. ; Don't be offended. You look like a noob because you started a thread saying that your gonna make an mmorpg with over 100,000 weapons and 10,000 spells, or something like that. Such is the stereotypical noob behaviour.For god sake, go and learn some python, then write a top down rpg. with 10 weapons and 10 spells. Then come back with screen shots or a demo and say "Look what I did this year." and get some opinions on what your next step should be.If you'd just gone into "For Beginners" and said you wanted to make games and what do you need to do now, you would have got better responses.So here is a list of facts:1) you CAN write an mmorpg but only as part of a large team.2) You can write a multiplayer rpg on your own but it takes time and years of practice.3) You can have fun making games if you stick to simple stuff. 4) You will get disrespected by some people if you don't use correct punctuation. Thats because they will find your posts harder to read; especially if your not posting in their first language.5) Your age is nothing to do with it; your mental maturity, and experience define your "noobness". Those things correlate with age but the correlation varies per person.Good luck with your game writing career. Your only 16 and have your whole life ahead of you, and the time you spent complaining could have bee spent installing python. <cough>install*python<cough>; It depends on how you define noob, you're 16 so that makes you relatively new to life in general, new to programming and new to all other kinds of experiences.Your age isn't advertised (partly for privacy reasons) on these forums unless you explicitly give it to us, thus no-one can or will assess the aptitude of your programming abilities on your age; only on the quality of your written words and the standard of advice or questions you post.Saying you have 5-years experience in C++ holds little merit, it doesn't tell us anything about how well you know the language, for all we know that means you've been aware of the existence of C++ Classes for 5 years, or it could mean you've learnt its the intricacies and you're a master of design patterns, template meta-programming and are able to produce highly efficient yet portable code.You also have to consider that if you only know one flavour then you will always be a noob when it comes to knowing the best tool for the job - because you only know how to use one tool.I myself have 14 years experience in programming across a multitude of languages, using a multitude of APIs and can tackle a problem with a multitude of different design approaches. My GDRating implies I am a moderately helpful person here on GDNet and yet I would not class myself above being an intermediate programmer. Based on that could you guess how old I am?The old adage of you're too old/young to program is just a misnomer really. ;Quote:Original post by dmatterSaying you have 5-years experience in C++ holds little meritI once knew a guy who had been skating for 8 years, and still couldn't do a kickflip |
Optimizing the rendering of hundreds of boxes | Graphics and GPU Programming;Programming | I've been programming in directx for about six months, mostly simple demos and the like. Never had any performance issues until recently.Basically I'm making a game with a grid based editor, each grid is a box that gets loaded into the world.Now the problem is when I'm rendering hundreds of boxes the performance starts dying on me. I've heard of a rule that you should never make over 500 draw calls with directx, obviously I'm brekaing that rule by severel thousand boxes :DI've basically been looking around online for a simple way to optimize the way things work, maybe not render boxes I'm not seeing but I'm just not sure which direction I should be heading here.The thing is, I'm not sure just which direction I should be going now, I just want to do something simple. Is there some sort of direction I can take? | Quote:Original post by chillypacman...maybe not render boxes I'm not seeing but I'm just not sure which direction I should be heading here...Yeah... that's the direction you should be going for starters. Instead of looping through every "box", just render the ones in the area that is visible on screen. It might help if you have a camera class that holds a map location and then uses this to determine which part of the grid to render.Cheers; I'd make one dynamic vertex buffer big enough to contain "a lot" of boxes (Probably a few thousand) in some manager class. Then, instead of creating a box, you can tell the manager class that you want to render a box, and pass in a position and size. The manager class can add that information to an internal vector, and then at the end of the frame, just lock the VB and update it with the data for all boxes in the vector, and then draw them in one call.If you run out of space in the VB, you can just lock and draw multiple times.This is exactly what ID3DXSprite does internally (And my sprite manager in my engine), although it's obviously with quads rather than full models. ; Three things:Batching: If the geometry AND transforms are static then at load-time (or even build-time) shove them all in the same vertex/index buffer so that you can blast them at the GPU in a single (or very few) calls.Instancing: If the geometry is the same for each cube/grid but the transforms change then look up "geometry instancing". You can render the same block of geometry 1000's of times, each with a different transform all in a single draw call.Culling: Don't submit draw calls for geometry that you know won't be on the screen. Look up "quad tree" as it'll probably suit you quite nicely. Just bare in mind that there is a sweet spot - highly accurate culling can increase draw calls which introduces more overhead than having 'mostly accurate' culling.Oh, and the other thing - make sure you've got a solid set of analysis results in from PIX or NVPerfHUD (etc..) before you get started. You won't know what is or isn't improving performance if you don't know where you were when you started [wink]hthJack ; alrighty guys, thanks for the advice, I'll look into it all :)[Edited by - chillypacman on September 10, 2007 11:10:05 AM]; I'd suggest that you look both at the instancing sample in the SDK and at the instancing demo at humus.ca. The latter will show you how to enable instancing on ATI SM2 cards (i.e., those before the X1xxx series). |
Atmospheric Scattering problem | Graphics and GPU Programming;Programming | I need to calculate the Atmospheric Scattering. I have tried the ATI's way and NVIDIA's way ,but I dont't gain the correct result.I'm very hurt for veryl ong time.IF i don't have progess,I may lost my job. I tried the code which is described in http://www.gamedev.net/community/forums/topic.asp?topic_id=461747. But the result is dark sky. Who have maked the thing? Can you help me? I lost hope! Thanks you very much! | |
Ready to Unleash The Fury, calling all beta testers.. | Your Announcements;Community | I'm about to do a public release of my terrain engine (www.gcengine.com), if anyone wants to help with testing or play with the demo send me a message, I'll get you setup.Here are a few videos in the meantime, a flyover from Nashville to Murfreesboro(lo-res public data), and a wireframe test showing off the runtime LOD system. | |
problem with directdraw GetCaps function | Graphics and GPU Programming;Programming | When i use the GetCaps function of directdraw to get the capabilities of my hardware, the strucutre DDCAPS is not filled with any values, it is returned as it is. Any idea why this could be happening??? | Code? Debug output? Return codes? ; I want to remind about setting the dwSize member of DDCAPS to the size of the structure before calling GetCaps, in other words dwSize = sizeof(DDCAPS), have you done that?Also, if GetCaps isn't returning DD_OK, check for DDERR_INVALIDOBJECT return value to make sure you'ven't created your DirectDraw object incorrectly.Apart from that, as far as I know, there's not many ways the method can fail. |
general lighting structure - help! | Graphics and GPU Programming;Programming | Hi there.im pretty new to game programming (only just finished 1st year of degree) but over summer ive been working my way through Frank Luna's Introduction to 3d game programming with directx 9.0c : a Shader approachEverything is goin pretty well, however i do have a big question about lighting in relation to its structure with the rest of an app. what is the easiest way to code multiple lights? (lets use for example 3 lights)do i:A) hard code 3 lights into the basic shader (although this seems inflexible and surely would be inefficient as would need lots of tests to see which lights were/were not active i.e. range, point vs directional vs ambient etc) B) leave the shader as a 1-light shader, and simply Re-Render the scene say 3 times each time adding the result to the back buffer (although this seems expensive as it'd mean effectively rendering a scene 3 times!)Also ive been told its best to include as few as possible tests (eg if statements switches etc) in shaders. so does that mean id need to create multiple fx files, each one taking different input for each possible combination of lights??? eg. fx1 for a pointx1 + directional, fx2 for a pointx2 +directional, perhaps another for pointx3 + directional etc (although that seems crazy!) anyway sorry for my inexperience!! | Quote:Original post by NovaBlackB) leave the shader as a 1-light shader, and simply Re-Render the scene say 3 times each time adding the result to the back buffer (although this seems expensive as it'd mean effectively rendering a scene 3 times!)I'm pretty sure that this is the approach that Doom3 used.It may seem like a bad idea to draw the scene 3 times, but as long as your scene-graph traversal is fast, it shouldn't be a problem.If you use shadow maps, then you'll also have to render the scene once from the perspective of the light source, and some reflection techniques might also need their own passes... So a modern game engine rendering a scene with 5 light sources might actually render the scene over 10 times to produce the final screen!I also know that Horde3D uses this approach (or at least it's default forward shading pipeline does). ; ahh excellent! i didnt realise at all that modern games actually renedered a scene that many times with a reasonable frame rate!hmm well ok for now ill try stick with that apporach and see how it goes!also whilst im on the topic, say i made a 'Light' class, so i could just instantiate lights by passing say directional/point as an argument, whats the best way of iterating through them all when rendering?Is it ok to say build all the fx handles in the light constructor, then just make some kind of linked list/container, holding pointers to the lights and iterate through each one pulling out the relevant handles for each one (e.g position, direction vector, color etc) and plugging them into the relavant fx file variables before a render pass? (then obviously doing 1 pass for each light present)ps. thanks for the quick reply!! its early!! lol appreciate the advice |
Where to start!! | For Beginners | My 8yr old son is very much into gaming and is a very intelligent young man (he is mentally equiv to a 12 yr old), I am trying to get him to focus on something he enjoys as he is getting depressed at school as children his age are being nasty to him, well he has decided he would like to learn to design and create computer games. So I was wondering if anyone could point me in the right direction as to which books I should get for him and what GCSE's would be best for him to concentrate on. Any help is greatly appreciated.Many thanksRachel | Maybe you could look around and find some free online books? I'm sure there are some. I never actually bought any books myself on game development so I cant really recommend any, sorry. ; Hi Mystical,I understand your query, just one small thing, when books in the industry are written, the majority of them are aimed at other industry professionals, or at least people of a greater age.However, one great thing about the industry is that it is a very creative industry, and kids are very creative. This would lead me to believe that maybe some aspects of the game design area. You could encourage the childs artistic qualities, which would be of great benefit later in his childhood when he gets to an age were he can dicide fully for himself which area he would potentially like to enter. To answer your questions on books, maybe find out which genres of games he particularly likes and maybe get one or two books on game design in those areas.hope this helps ; I'd recommend him getting into Microsoft's XNA.He can do this for free too.Download the "Microsoft Visual C# Express Edition" (then get the service pack)http://msdn2.microsoft.com/en-us/express/aa975050.aspxScroll down to "Step 2"(the service pack 1 is on that page as well just a little lower on "Step 3")Don't forget to register! (It will only work for 30 days if you don't)And then download "Microsoft XNA Game Studio Express Refresh"http://www.microsoft.com/downloads/details.aspx?FamilyID=12ADCD12-7A7B-4413-A0AF-FF87242A78DE&displaylang=enNo service pack for that one.He will need to learn a bit of C# (Can anyone recommend any good books for beginners on C#?) and there are a few XNA books out there (I recommend Benjamin Nitsche's book - Professional XNA Game Programming: For Xbox 360 and Windows)http://www.amazon.com/Professional-XNA-Game-Programming-Windows/dp/0470126779/ref=pd_bbs_sr_1/002-8153368-1513607?ie=UTF8&s=books&qid=1189021363&sr=8-1Microsoft has also made it easy with their creators website (free downloads and game examples).http://creators.xna.com/Plus there are MANY other XNA development sites (just google for "XNA").I can relate to what your son is going through, I was "gifted and talented" myself when I was young (taught myself QBasic at around his age and made a bunch of text RPGs ;) ).Hope this helps,DavidEdit: Thanks Crypter![Edited by - shadowDragon on September 6, 2007 9:29:53 PM]; I don't know about your son, but for me it's very hard to learn programming and game design without having actual programmers around to explain things. Sure I can read all the books I want, but nobody tells me what the terms mean, and definitions don't mean a whole lot.My advice, if you have a programmer friend, try and talk him into teaching the boy, or can enroll him in some kind of class(even if it's an online class), that would be better than any book. ;Quote:(sorry I don't know the key word to turn these into links on this forum)They are just the HTML anchor <a> tags. i.e...<a href="http://www.example.com">Example</a>Produces:ExampleI would probably recommend starting with something simple at first, such as a BASIC language (I heard Quick BASIC was pretty good). This will allow him to learn the basics of programming while being able to produce something with graphics alot quicker.Alot of young kids may get discouraged if they have to work alot to produce simple graphics; or even learn concepts that do not directly relate to their game in mind. Then again, I do not know your child, so this might not be true[smile]You can also try a GameMaker program. This will allow him to learn basic game concepts, and even some scripting, without all of the assets of programming. Afterwords, when he feels ready, he can move onto a more complex language like C++, C#, Java, et al.If he is really up to it, I second learning C# first. Providing how well he does, he may then learn a more complex language like C++. ; Allow your son to develop his imagination and improve creativity as opposed to learning programming concepts.perhaps your son would be better off with a package such as FPSCREATOR http://www.fpscreator.com/ , ok, so it's not the best software around but it is affordable and you can get started almost immediately, this will allow your son to focus on game design as opposed to programming syntax - which can be very frustrating and demotivational if things go wrong.your son could create a basic game in a weekend which will help him to develop creatively - nothing better than to see a project to fruition :)once your son becomes comfortable with this he can then start the more technical route of programming :)in terms of GCSE's, maths and science are very important subjects to study, but dont worry too much about what he should be studying for games, what is more important is the ability to be good at most subject for all round development.I can't stress this enough -"imagination is more important than knowledge" , Einstein ; Hi.I started into programming at the age of 14 by myselfI learned C++ pretty much by "reverse engeneering"I read a small tutorial of C++ and then started with many source codes, removing and debugging seeing what the code was actually doing.As far as Documentation goes, I've read the manuals from what I was using. i.e. Direct X SDK Documentation is VERY good(SDK stands for Software Development Kit and they're mostly used for developing programs using 3rd party tools.)In my personal experience, I started with XGL, a Glide Wrapper for Direct3D. Then I wrote some tiny applications until I got better. Then I wrote my own image viewer from scratch, which was actually pretty good but never released because of some video driver stability issues. I also released a project on sourceforge (x86mph) and I'm part of the ClamWin antivirus team now.Now (I'm 19) I'm making my first big 3D game. However I'm not studying a programming-related career and thus have little time to code now. Probably your kid will have much time for it.As for example (open source code) the best choice is to look at http://sourceforge.netAfter choosing the programming language (C++ is the most used for games, although the hardest) for compiling programs he will need compilers. These are free from Microsoft (there are other options):http://msdn2.microsoft.com/es-ar/express/aa975050.aspxThen I strongly recommend downloading the Plattform SDK and DirectX SDK, both from the microsoft page too.OpenGL SDK can be also downloaded from Internet.Hope this helps.Dark SylincEDIT: gamedev.net itself has very useful resources:http://www.gamedev.net/reference/; You may want to take a look at the Kids Programming Language (KPL) which is a programming language aimed for kids that are your son's age. ; If he's having trouble with social situations... picking up a hobby like programming / game development, might only make him more isolated, and although it'll be a good career later on in life, it may not be the happiest/wisest way to deal with the situation.I know I'll get flamed for this, but it's simply my opinion:SMART people make good programmers. But in my opinion, WISE people do not.Would a WISE person decide to sit on a computer and figure out small problems and details that might possibly never apply to anything outside the computer?Crazy people, yes. WISE people? Hmm, largely debatable.Either way, I'm not trying to discourage him from learning to code, but if he does not deal with these bullies early on, it can lead to complications later on in life. At least from my observation. |
Boost + Visual Studio 8 problems | For Beginners | The main(and pretty much only) I want to use Boost is for the filesystem lib. After trying for a long time it appeared that it was finally working. However the "two minute tutorial" sample code gave me problems.I tried this and it worked: boost::filesystem::path p("mmicon.png");std::cout << p.leaf();The is_directory() and exists() functions also work. But when I try to declare a directory_iterator it gives me these errors when it compiles:Error1error LNK2001: unresolved external symbol "unsigned int boost::filesystem::detail::not_found_error" (?not_found_error@detail@filesystem@boost@@3IA)main.objError2fatal error LNK1120: 1 unresolved externalsC:\Documents and Settings\econobeing\My Documents\Visual Studio 2005\Projects\bt\Release\bt.exe1 | I'm not entirely sure what the problem might be, however since you are having linker errors I would guess that you either didn't compile Boost properly or your environment variables are not correctly setup (in VS). As you probably know most of Boost is header only code, but certain parts, including boost::filesystem, are libs. Did you compile Boost or are you just using the headers? ; This sounds exactly what the problem is.You need to,A) Have the libraries in the first place. Most likely, you'll be compiling them yourself. I, personally, found this to be a pain, but I hear they re-did their guide since then (with 1.34). And they've released bjam or whatever as a binary with Boost? I think it's easier now.B) Point VS to the right directories. This is under, um, Tools->Options->Projects And Solutions->VC++ Directories->Show Directories For: Library Files, and then add the correct directory (which should be "<where boost is>/lib" ).Hope that helps! ; I used that installer they have.The easiest way to get a copy of Boost is to use the installer provided by Boost Consulting. We especially recommend this method if you use Microsoft Visual Studio .NET 2003 or Microsoft Visual Studio 2005, because the installer can download and install precompiled library binaries, saving you the trouble of building them yourself.I did that, it gave me what looked like everything needed, it had a lib folder in it, which had .lib files, including some for filesystem, which i linked to.Before I linked the .lib, when I tried to declare a path, it would give me some errors, then I linked it, and declaring a path worked, "cout"ing the .leaf() function worked. But then I tried making a directory_iterator, and those new errors popped up.I'm re-doing the installer, and if that doesn't work I'll try this methodCompiling it all manually took a long time when I got it to work on linux, so I was hoping to save some time using the .exe installer(which they even said that they recommend).My environment might not be correctly set up though... I don't know how to set them up proper with Boost. ; Okay, declaring a directory_iterator works now, after re-installing with the .exe, linking the correct library(I assume)But when I tried to compile it gave me LNK2005 and LNK1169 errors, looked that up, and it said to put "/FORCE" in the linker console extra parameters, did that, it actually compiled without error, run the program, it gives me this:This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.When I run it with debugging (F5) it gives me this:Unhandled exception at 0x7c812a5b in bt2.exe: Microsoft C++ exception: boost::filesystem::basic_filesystem_error<boost::filesystem::basic_path<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,boost::filesystem::path_traits> > at memory location 0x0012f940..Here's my code, it's essentially the same as the two-minute example, except for variable names and i put boost::filesystem:: in front of everything because it won't let me use "using boost::filesystem" for some reason.//#include <boost/lambda/lambda.hpp>#include <iostream>#include <iterator>#include <algorithm>#include <string>#include <boost/filesystem.hpp>bool findFileRecursive(const boost::filesystem::path & searchPath, const std::string fileName, boost::filesystem::path & placePath);int main(int argv,char* args[]){boost::filesystem::path p("ReadMe.txt");std::cout << p.leaf() << std::endl;boost::filesystem::path pl("ReadMe.txt");std::string f("mt.dep");boost::filesystem::directory_iterator d;if(findFileRecursive(p,f,pl)) std::cout << pl.leaf() << std::endl;return 0;}bool findFileRecursive(const boost::filesystem::path & searchPath, const std::string fileName, boost::filesystem::path & placePath){if(!boost::filesystem::exists(searchPath)) return false;boost::filesystem::directory_iterator endIter;for(boost::filesystem::directory_iterator iter(searchPath);iter != endIter;++iter){if(boost::filesystem::is_directory(iter->status())){if(findFileRecursive(iter->path(),fileName,placePath)) return true;}else if(iter->path().leaf() == fileName){placePath = iter->path();return true;}}return false;}; If you have trouble getting the libraries for boost to work, you can try adding the source files to your project directly. You'll need edit boost/config/user.hpp and uncomment the #define BOOST_ALL_NO_LIBS line and then add the source files in the libs/filesystem/src directory to your project. ; I've re-compiled it for MinGW, installed Code::Blocks, and got as far as I did with VS2005, it gave me this error when trying to run it:This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.After taking apart the sample function provided I've found that it doesn't like declaring a directory_iterator and passing it a path object.e.g.:boost::filesystem::path p("main.cpp");boost::filesystem::directory_iterator iter(p);Declaring a path, cout'ing the .leaf() function works, as well as various other operations, but it doesn't like that ONE thing.... |
Stencil shadows with GL_TRIANGLE_STRIP : Strange artifacts | Graphics and GPU Programming;Programming | Hello everybody,I've followed lesson 27 of nehe's tutorials on creating shadows and customized the code to my needs. Seems that the shadow calculation works fine. But now I am having some strange artifacts on the shadow, It seems that there are some very small gaps between the triangles of the shadow, since it's drawn as a GL_TRIANGLE_STRIP.Here are some screenshots:Does anyone have an idea, how to get rid of this lines? Is this an OpenGL specific issue, or should I inspect my code more precisely? The code is completely taken from Nehe's tutorial, I just changed some variable names to fit it into my project, so I think it should be ok.Any help is really appreciated.Thanks in advanceMatthias[Edited by - Pudutzki on September 10, 2007 10:56:13 AM] | They look like tiny cracks, possibly because of subpixel precision artifacts.Is the strip indexed or not? ; What do you mean with "indexed"? ; What he means is: Do you send shared vertices (vertices that are used by multiple triangles that are not adjacent in the strip) multiple times or do you use indices into an array of vertices (where each vertex is contained once)?.Example:You have several triangles that are not directly connected by the strip.They share some vertices, say T1 (0, 1, 2), T2 (1, 4, 8), T3 (4, 8, 9).T1, T2, T3 are distributed over the strip and not directly connected!Note: the numbers in the vertex array represent the vertex number, in reality those have to be replaced by the real data. Numbers in the index array are the real data, i.e. indices into the vertex array.Non-indexed:Vertex array: 0, 1, 2, ... 1, 4, 8, ... 4, 8, 9IndexedVertex array: 0, 1, 2, ... 4, ... 8, 9, ...Index array : 0, 1, 2, ... 1, 4, 8, ... 4, 8, 9What could happen in the non-indexed case is that due to small imprecision errors in the vertex data calculation (e.g. when vertices are transformed) you could get slightly different positions for vertices that should be the same.Hope that helps. ;Quote:Original post by Lord_EvilWhat could happen in the non-indexed case is that due to small imprecision errors in the vertex data calculation (e.g. when vertices are transformed) you could get slightly different positions for vertices that should be the same.Sort of.Take for example the following values:512.0f512.0f + 256.0f = 768.0f512.0f + 512.0f = 1024.0f1024.0f - 256.0f = 768.0fThis is just what you expect. There's a reason if everything is ^2.The trouble is when you add more esoteric numbers, for example:delta = 123.456fThis probably won't hold true:14.0f + delta - delta == 14.0f(if it works with 14.0f, try using 0.14f or 0.000014)This happens because floating point math is approximated.In general, when you "go forward" and then you have a path "going back" you won't match the same thing in 99% of the time. Xforming makes the thing simply worse.Indexing by itself does not solve the problem - if you build the index list by looking at the float values you'll just screw'em as well.Indexing however usually helps in understanding better the problem domain and eliminates the need for "non-shared" shared vertices.This doesn't mean Func(5.0f) returns slightly different numbers on the various calls butparam=5.0 (in the Real Set)fparam=5.0f (in your favorite Float Set)Generally,Func(fparam) != IdealFunc(param)But given an fparam the error will always be the same, in other words,floatError = abs( Func(fparam) - IdealFunc(param) )is constant as well asdeviation = abs( Func(fparam) / IdealFunc(param) ).So, what about you?Let's say you're doing:A -> B| /| /| /v/CA -> B| /|| / || / |v/ vCc1 DIf you go down from B (spawn vertex D) and then go back (spawn c1), the edge BC1 may match... or not, depending on how lucky you are.Indexing just fixes this by allowing to recognize c1 shouldn't be computed in the first place.[Edited by - Krohm on September 10, 2007 9:31:41 AM]; Ok, first of all, thanks for your effort, but I just don't get it.I am using a list of vertices, and a list of faces. Each face has an array of indices which points to the according vertices (face_vertex), so I think I am using indexing.typedef struct t_vertex { float x; float y; float z; vertex_n normal;} vertex;/* * A face consists 3 vertices */typedef struct t_plane{GLfloat a, b, c, d;} Plane;typedef struct t_face { int face_vertex[3]; vertex normal; bool isVisible; Plane planeEquation; int neighbourIndices[3]; } face;The mesh data is loaded from a file which contains all vertices and all faces, it looks like this:v -0.650000 -0.179358 1.777216v -0.650000 1.127216 -0.470642v -0.650000 -1.120642 -1.777216v -0.650000 -2.427216 0.470642v 1.950000 -0.179358 1.777216v 1.950000 -2.427216 0.470642v 1.950000 -1.120642 -1.777216v 1.950000 1.127216 -0.470643f 5 1 4f 5 4 6f 3 7 6f 3 6 4f 2 8 3f 8 7 3f 1 5 2f 5 8 2f 5 6 7f 5 7 8f 1 2 3f 1 3 4All data is stored the following way:vector <vertex> obj_vertices;vector <face>obj_faces;According to Nehe's tutorial, I do the following:1) Calculate face to face connectivity, as far as I unserstand, this function determines which face has which neighbours.void MeshObject::setConnectivity(){cout << "Setting face-to-face connectivity" << endl;int p1i, p2i, p1j, p2j;int P1i, P2i, P1j, P2j;int i,j,ki,kj;for(i=0;i<obj_faces.size()-1;i++)for(j=i+1;j<obj_faces.size();j++)for(ki=0;ki<3;ki++)if(!obj_faces.neighbourIndices[ki]){for(kj=0;kj<3;kj++){p1i=ki;p1j=kj;p2i=(ki+1)%3;p2j=(kj+1)%3;p1i=obj_faces.face_vertex[p1i];p2i=obj_faces.face_vertex[p2i];p1j=obj_faces[j].face_vertex[p1j];p2j=obj_faces[j].face_vertex[p2j];P1i=((p1i+p2i)-abs(p1i-p2i))/2;P2i=((p1i+p2i)+abs(p1i-p2i))/2;P1j=((p1j+p2j)-abs(p1j-p2j))/2;P2j=((p1j+p2j)+abs(p1j-p2j))/2;if((P1i==P1j) && (P2i==P2j)){ //they are neighboursobj_faces.neighbourIndices[ki] = j+1; obj_faces[j].neighbourIndices[kj] = i+1; }}}}2) Calculate the planes for each facevoid MeshObject::calculatePlanes() {vertex v[4];for(int n=0;n<obj_faces.size();n++) {for (int i=0;i<3;i++){v[i+1].x = obj_vertices[obj_faces[n].face_vertex].x;v[i+1].y = obj_vertices[obj_faces[n].face_vertex].y;v[i+1].z = obj_vertices[obj_faces[n].face_vertex].z;}obj_faces[n].planeEquation.a = v[1].y*(v[2].z-v[3].z) + v[2].y*(v[3].z-v[1].z) + v[3].y*(v[1].z-v[2].z);obj_faces[n].planeEquation.b = v[1].z*(v[2].x-v[3].x) + v[2].z*(v[3].x-v[1].x) + v[3].z*(v[1].x-v[2].x);obj_faces[n].planeEquation.c = v[1].x*(v[2].y-v[3].y) + v[2].x*(v[3].y-v[1].y) + v[3].x*(v[1].y-v[2].y);obj_faces[n].planeEquation.d =-( v[1].x*(v[2].y*v[3].z - v[3].y*v[2].z) + v[2].x*(v[3].y*v[1].z - v[1].y*v[3].z) + v[3].x*(v[1].y*v[2].z - v[2].y*v[1].z) );}}Later, inside my renderloop, the shadows are being casted with:void MeshObject::castShadow(GLfloat lp[4]){unsigned inti, j, k, jj;unsigned intp1, p2;vertexv1, v2;floatside;//set visual parameterfor (i=0;i<obj_faces.size();i++){// chech to see if light is in front or behind the plane (face plane)side =obj_faces.planeEquation.a*lp[0]+obj_faces.planeEquation.b*lp[1]+obj_faces.planeEquation.c*lp[2]+obj_faces.planeEquation.d*lp[3];if (side > 0) obj_faces.isVisible = true;else obj_faces.isVisible = false;} glDisable(GL_LIGHTING);glDepthMask(GL_FALSE);glDepthFunc(GL_LEQUAL);glEnable(GL_STENCIL_TEST);glColorMask(0, 0, 0, 0);glStencilFunc(GL_ALWAYS, 1, 0xffffffff);// first pass, stencil operation decreases stencil valueglFrontFace(GL_CCW);glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);for (i=0; i<obj_faces.size();i++){if (obj_faces.isVisible)for (j=0;j<3;j++){k = obj_faces.neighbourIndices[j];if ((!k) || (!obj_faces[k-1].isVisible)){// here we have an edge, we must draw a polygonp1 = obj_faces.face_vertex[j];jj = (j+1)%3;p2 = obj_faces.face_vertex[jj];//calculate the length of the vectorv1.x = (obj_vertices[p1].x - lp[0])*100;v1.y = (obj_vertices[p1].y - lp[1])*100;v1.z = (obj_vertices[p1].z - lp[2])*100;v2.x = (obj_vertices[p2].x - lp[0])*100;v2.y = (obj_vertices[p2].y - lp[1])*100;v2.z = (obj_vertices[p2].z - lp[2])*100;//draw the polygonglBegin(GL_TRIANGLE_STRIP);glVertex3f(obj_vertices[p1].x, obj_vertices[p1].y, obj_vertices[p1].z);glVertex3f(obj_vertices[p1].x + v1.x, obj_vertices[p1].y + v1.y, obj_vertices[p1].z + v1.z);glVertex3f(obj_vertices[p2].x, obj_vertices[p2].y, obj_vertices[p2].z);glVertex3f(obj_vertices[p2].x + v2.x, obj_vertices[p2].y + v2.y, obj_vertices[p2].z + v2.z);glEnd();}}}// second pass, stencil operation increases stencil valueglFrontFace(GL_CW);glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);for (i=0; i<obj_faces.size();i++){if (obj_faces.isVisible)for (j=0;j<3;j++){k = obj_faces.neighbourIndices[j];if ((!k) || (!obj_faces[k-1].isVisible)){// here we have an edge, we must draw a polygonp1 = obj_faces.face_vertex[j];jj = (j+1)%3;p2 = obj_faces.face_vertex[jj];//calculate the length of the vectorv1.x = (obj_vertices[p1].x - lp[0])*INFINITY;v1.y = (obj_vertices[p1].y - lp[1])*INFINITY;v1.z = (obj_vertices[p1].z - lp[2])*INFINITY;v2.x = (obj_vertices[p2].x - lp[0])*INFINITY;v2.y = (obj_vertices[p2].y - lp[1])*INFINITY;v2.z = (obj_vertices[p2].z - lp[2])*INFINITY;//draw the polygonglBegin(GL_TRIANGLE_STRIP);glVertex3f(obj_vertices[p1].x, obj_vertices[p1].y, obj_vertices[p1].z);glVertex3f(obj_vertices[p1].x + v1.x, obj_vertices[p1].y + v1.y, obj_vertices[p1].z + v1.z);glVertex3f(obj_vertices[p2].x, obj_vertices[p2].y, obj_vertices[p2].z);glVertex3f(obj_vertices[p2].x + v2.x, obj_vertices[p2].y + v2.y, obj_vertices[p2].z + v2.z);glEnd();}}}glFrontFace(GL_CCW);glColorMask(1, 1, 1, 1);//draw a shadowing rectangle covering the entire screenglColor4f(0.0f, 0.0f, 0.0f, 0.4f);glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glStencilFunc(GL_NOTEQUAL, 0, 0xffffffff);glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);glPushMatrix();glLoadIdentity();glBegin(GL_TRIANGLE_STRIP);glVertex3f(-0.1f, 0.1f,-0.10f);glVertex3f(-0.1f,-0.1f,-0.10f);glVertex3f( 0.1f, 0.1f,-0.10f);glVertex3f( 0.1f,-0.1f,-0.10f);glEnd();glPopMatrix();glDisable(GL_BLEND);glDepthFunc(GL_LEQUAL);glDepthMask(GL_TRUE);glEnable(GL_LIGHTING);glDisable(GL_STENCIL_TEST);glShadeModel(GL_SMOOTH);}Obviously, the shadow volume is correctly calculated and I don't use double vertices.So what is going wrong here??? ;Quote:Original post by PudutzkiObviously, the shadow volume is correctly calculated and I don't use double vertices.Look, I'll take that for granted, but consider the problem here is not on the "hardware vertex" (opos, onorm and such) but on the vertex opos only.Take for example a cube: each face will have different indices because of normals but the vertices will match.FP may be a bit approximative, but it's not SO bad.Try a check: run a scan and collapse all the points near each other by a Eps to a single vertex.For example: if vertex B is near vertex A, then B=A. |
Any professional game developers here? | For Beginners | If so, could you please fill out this real quick? I don't know any game devs and I have to interview one for a business project. What are several of your normal job duties?What values are important for this career?Do you work with people, data, or things? Please explain.Do you work indoors or outdoors?Do you work at a desk, standing, or on the move?How much noise is there in the work area?Is your work dangerous in any way? If so, how? What are your normal working hours?How often do you work overtime? Do you ever work nights or weekends?What aptitudes and abilities are needed for your career?What education and training are required to enter and advance in your career area?What is the average beginning salary? How about what you earn after five years? Ten years? What types of benefits do workers in your career usually receive?How many workers are needed in your career area at the present time? Locally? Statewide? Nationwide?Do you think demand for workers will increase or decrease in the next five years?Do you work with people in other countries? How?Any additional comments?Thanks a ton. | >> What are several of your normal job duties?Programming, helping out artists that managed to fuck something up, meetings, and typing tech designs.>> What values are important for this career?You have to be a good programmer, and you should be good at working together with other people.>> Do you work with people, data, or things? Please explain.Data I guess. I write source code all day long, >> Do you work indoors or outdoors?indoors>> Do you work at a desk, standing, or on the move?sitting most of the time, but sometimes the animators from next door walk in, to ask if we can do some weird move for them as reference.>> How much noise is there in the work area?Just the usual talking, not much more.>> Is your work dangerous in any way? If so, how? You can get RSI>> What are your normal working hours?officially 10-6, but I work a couple of hours longer almost every day.>> How often do you work overtime? Do you ever work nights or weekends?Pretty often. Nights or weekends happen from time to time, but they do kill you, so I try to avoid them.>> What aptitudes and abilities are needed for your career?You need to be a good programmer, and have some experience in the subject (not per se professionally)>> What education and training are required to enter and advance in your career area?Education can be important for getting a job, but if you can show them that you have the required skills without the proper education, they are happy to hire you, as it's rather common that there are really good people that don't have the education.For advancing in your carrier, education is pretty much useless in any field, advancing in your carrier solily depends on how well you perform in the things you're doing already.>> What is the average beginning salary? How about what you earn after five years? Ten years? I don't really know what's average in the industry, and if you don't mind, I will keep my own salary a secret.>> What types of benefits do workers in your career usually receive?Bonusses depending on the sales of the game you worked on are quite common. >> How many workers are needed in your career area at the present time? Locally? Statewide? Nationwide?Our company has +- 200 peope at our location, of which about 80 are working on the project I'm working on now.>> Do you think demand for workers will increase or decrease in the next five years?I think (and hope) it will decrease, because the process of making a game will be streamlined more and more, so fewer people will be able to do bigger projects.>> Do you work with people in other countries? How?Our company has a dependency in beijing, but personally I don't have to deal with those people directly.>> Any additional comments?Not reallyThanks a ton. ;What are several of your normal job duties?Check the bug log. Attend daily meetings. Implement changes into the current project's code base. Work on whatever systems I may have currently assigned to me. Work with other programmers in the group to help solve problems.What values are important for this career?Problem solving, working well with a team, and being able to work under pressure.Do you work with people, data, or things? Please explain.Things? I guess some of the people here sure don't smell human but "thing" might be a little harsh. You constantly work with people. You are always in a team or a meeting and constantly having to collaborate.Do you work indoors or outdoors?Indoors.Do you work at a desk, standing, or on the move?Desk.How much noise is there in the work area?A lot. A good set of headphones does wonders though. :)Is your work dangerous in any way? If so, how?Only to my social life. Long hours, especially when coming upon a milestone, will basically kill any extracurricular activities you may have. What are your normal working hours?10 - 7How often do you work overtime? Do you ever work nights or weekends?Fairly often. Nights are a common occurance. Weekends depends on how close to a milestone we are. This last month I spent the last 3 weekends at work. What aptitudes and abilities are needed for your career?Logical thinking, problem solving, and obviously knowing the syntax of your coding language of choice is paramount.What education and training are required to enter and advance in your career area?Math, and Comp Sci are the big ones.What is the average beginning salary? How about what you earn after five years? Ten years?Hmmm...you can find that info out at the Game Developer's salary survey. Just google it. What types of benefits do workers in your career usually receive?Pretty basic. Health insurance, dental, etc. If you work for a large publisher like EA or whomever, you generally have access to a company store that lets you buy any title that publisher has published for a fraction of the normal cost.How many workers are needed in your career area at the present time? Locally? Statewide? Nationwide?I have no idea how to answer this one...Do you think demand for workers will increase or decrease in the next five years?Increase. For sure.Do you work with people in other countries? How?Sure, I've worked with publishers in Europe. It's no biggie besides the time differences. Setting up meetings can mean you are at work late or early (depending on time zone differences). Any additional comments?Hmmm. No. ; awww yeah there's my A+!; What are several of your normal job duties?-Developing game features (including programming and writing the technical specifications).-Fixing bugs.-Working with producers and artists to achieve their vision.What values are important for this career?-Hard work-Reliability-Drive and determinationDo you work with people, data, or things? Please explain.-All of them... Weird question.Do you work indoors or outdoors?-Indoors... another weird question.Do you work at a desk, standing, or on the move?-Desk.How much noise is there in the work area?-It's fairly noisy, not so noisy that you can't concentrate though. Lot's of talking with coworkers.Is your work dangerous in any way? If so, how?-Yes. I once faught a gorilla with knives for fingers. (honestly this is getting a bit ridiculous).What are your normal working hours?-October to April/May: 9am - 6 or 7pm (monday to friday)-Rest of year: 7am - 10pm (or later) (5-6 day week)How often do you work overtime? Do you ever work nights or weekends?-See above. Don't usually work 7 day weeks ever though(few exceptions).What aptitudes and abilities are needed for your career?-Understanding of programming concepts (various programming/scripting languages).-Problem solving skills.-Interpersonal skills for dealing with producers, artists, managers.What education and training are required to enter and advance in your career area?-None are REQUIRED, although a bachelor (or higher) of computer science, or software engineering make for MUCH MUCH better resumes.What is the average beginning salary? How about what you earn after five years? Ten years?-Not sure on the averages.What types of benefits do workers in your career usually receive?-Varies greatly from company to company.How many workers are needed in your career area at the present time? Locally? Statewide? Nationwide?-There are probably around 4000-5000 developers locally. Across the province (yes I'm Canadian), it's probably the same (dev studios are often concentrated in one location). Across the country it's probably around 2.5 times that (The US has a much larger number of studios though).(edit: I missread the question. My answer is regarding how many are currently employed. There doesn't seem to be a whole lot of jobs to fill at the moment, however that is expected to change)Do you think demand for workers will increase or decrease in the next five years?-A huge increase is planned (at least at my company). Games are becoming more expensive and time consuming to build. Experienced people are prefered, but there aren't enough around, so new grads have lots of opportunities ahead.Do you work with people in other countries? How?-Not directly, although we do outsource select things to Asia, and a lot of our marketing/legal departments are in the US.[Edited by - dashurc on September 11, 2007 12:53:18 AM];Quote:Original post by dashurc...Is your work dangerous in any way? If so, how?-Yes. I once faught a gorilla with knives for fingers. (honestly this is getting a bit ridiculous)....Knives for fingers? I can't wait until my first game programming job. the PHP web development work I did was nowhere near as interesting.;What are several of your normal job duties?Designing systems. Writing code. Reviewing code.What values are important for this career?Caring about your work.Do you work with people, data, or things? Please explain.I work with co-workers (people), code/assets (data) and office equipment (things).Do you work indoors or outdoors?Indoors, obviously. They don't let programmers out of the dungeon during the daytime...Do you work at a desk, standing, or on the move?At a desk. (Sometimes I stand at the desk, or pace in front of it...)How much noise is there in the work area?Not much conversation noise, but lots of environmental noise (my desk is next to the entire floors AC unit).Is your work dangerous in any way? If so, how?No, besides ergonomic / repetitive strain injury / regular office health/safety stuff. Maybe obesity too...What are your normal working hours?9:30 - 5:30How often do you work overtime? Do you ever work nights or weekends?Never (Unless I've been coming in late and going home early).What aptitudes and abilities are needed for your career?Logical thinking / problem solving, ability to learn and adapt, ability to work without being managed, general communication skills.What education and training are required to enter and advance in your career area?A degree relating to computers / experience with C++.What is the average beginning salary? How about what you earn after five years? Ten years?$40k, $60k, $70k.However, just because you've been somewhere for 10 years doesn't mean you will get a raise. What types of benefits do workers in your career usually receive?None. Sometimes we get a free barbecue or get to visit trade shows...How many workers are needed in your career area at the present time? Locally? Statewide? Nationwide?Ask a recruiter!Do you think demand for workers will increase or decrease in the next five years?Increase.Do you work with people in other countries? How?On occasion. Email / conference calls. ; >>> What are several of your normal job duties?Checking bug logs. Communicating with QA department. Programming.>>> What values are important for this career?You have to be able to work to a deadline and work well with other people.>>> Do you work with people, data, or things? Please explain.Data I guess, I'm a programmer.>>> Do you work indoors or outdoors?Indoors>>> Do you work at a desk, standing, or on the move?At a desk.>>> How much noise is there in the work area?There's a bit of ambient noise. As the person above said a pair of headphones are a real asset!>>> Is your work dangerous in any way? If so, how? No.>>> What are your normal working hours?9 - 6>>> How often do you work overtime? Do you ever work nights or weekends?Work from 9 - 9 (three times a week) during crunch time when we have a deadline looming. Don't work weekends.>>> What aptitudes and abilities are needed for your career?You need to be good at maths and programming, so you need a reasonably logical mind. You also need to be fast at solving problems and learning.>>> What education and training are required to enter and advance in your career area?A degree in maths/programming.>>> What is the average beginning salary? How about what you earn after five years? Ten years.No idea.>>> What types of benefits do workers in your career usually receive?Job satisfaction.>>> How many workers are needed in your career area at the present time? Locally? Statewide? Nationwide?We have around 80 people here at work... we're a reasonably small game development company in New Zealand.>>> Do you think demand for workers will increase or decrease in the next five years?Without a doubt demand will increase.>>> Do you work with people in other countries? How?Yes, we receive contracts that have to be fulfilled from overseas customers. Working and communicating with them as much as possible is essential to producing a satisfactory product.>>> Any additional comments?Not really. |
MFC - CString and binary data | General and Gameplay Programming;Programming | I'm working on a little editor, but I am having troubles with displaying binary data. My problem is, that I need to copy the binary data from a buffer to the CString, associated with that control. And since CString::operator= expects a nullterminated wchar_t*, there is a problem to copy all binary data to the cstring, since the data might continue after a 0.Do you know a way to achieve this? | You can construct a CString() for a LPCTSTR and a size, which should preserve the nulls in the middle of the data. Keep in mind that even if you do copy the data with a null into the control's CString, it still may not display anything after the null anyways. ; I tested it, you're right, it doesn't display anything after a zero. Is there a way to display binary data in a CEdit? Maybe a costum control you know?There has to be a way to do this, the windows editor for example is able to display such data. ; One thing you can do is substitute the null with a character of your choice when you display it. For example a space or a question mark. ; hm, thats right, thanks very much :) |
Need Help with Word 2007 | GDNet Lounge;Community | Hi guys! This is a strange question, but I really need some help. I've been typing up notes from my math class, and I've hit a snag: the logical negation operator (which Word terms an "option hyphen") will not correct display in my document. Specifically, if I click to insert it, it gets inserted but it is completely invisible. If I insert two, I need to backspace two times to get past it but I cannot see the character, and physically it looks like it isn't taking up any space in the document.Since the course is on mathematical logic, not being able to use the negation operator properly when typing is going to be a real pain. Any help would be most appreciated! | Have you tried a different font? Perhaps it's not available in Calibri. ; Thanks for the suggestion, but even after trying a few different fonts, it still won't show up. =( ; Hmm...that is strange - I can reproduce that. Looks like a bug?Maple has a fantastic font which has all the mathematical symbols, which includes the logical not. I can give this to you if you would like...although I'm not sure if this is legal? Let me know...Cheers ; That isn't the *actual* symbol; an "optional hyphen" is a normally-zero-width character that's intended to indicate, as you might guess, an *optional* *hyphen*. I.e., something that doesn't appear when the word is in the middle of a line, but is a legal point to break the word (and insert a hyphen) in order to wrap to the next line. This sort of thing can be very useful in typography when you don't yet know how things are going to wrap - you can put them at acceptable positions, and then play with the column width to your heart's content.If you want the mathematical symbol, copying and pasting it from charmap works for me. You can also use its keystroke, Alt+0172. ; Thank you all so very much!!! |
Java - fillPolygon HELP! | For Beginners | Hey Im trying to setup a method where I can pass in the values for the x and y points and have the polygon draw to the window.I am in cs1, and we are using Java to learn the basic features of OOP, and I am stuck. Can anyone help with this?Here is my 'driver' class:public class Driver{ private JFrame theWindow; private Shape t1, t2, t3; public Driver() { theWindow = new JFrame("Output"); theWindow.setBounds(10,10,256,256); theWindow.setLayout(null); theWindow.setVisible(true); /*t1=new Shape("box", 0,0,50,50); theWindow.add(t1,0); t2=new Shape("oval", 75,75,50,50); theWindow.add(t2,0);*/ int[] x={10,25,50}; int[] y={10,25,50}; t3=new Shape(x, y, 3,0,0,128,128); theWindow.add(t3,0); }}I am overloading the 'Shape' class, but I wanted to do it just for my own experience.This is the Shape class:mport javax.swing.*;import java.awt.*;/** Shape Supplier Class * Author: Brett Unzaga * Date: September, 2007 */public class Shape extends JComponent{ private String shape; private int[] polyX; private int[] polyY; private int polyN; public Shape(String s, int x, int y, int w, int h) { super(); setBounds(x, y, w, h); setBackground(Color.black); shape=s; } public Shape(int[] xPoints, int[] yPoints, int nPoints, int x, int y, int w, int h) { super(); shape="poly"; polyN=nPoints; int[] polyX=xPoints; int[] polyY=yPoints; setBounds(x, y, w, h); setBackground(Color.black); } public void paint(Graphics g) { g.setColor( getBackground() ); if(shape=="oval") { g.fillOval(0, 0, getWidth()-1, getHeight()-1); } if(shape=="box") { g.fillRect(0, 0, getWidth()-1, getHeight()-1); } if(shape=="poly") { g.fillPolygon(polyX, polyY, polyN); } paintChildren(g); }}Basically I get all kinds of errors:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExceptionat Shape.paint(Shape.java:46)at javax.swing.JComponent.paintChildren(JComponent.java:859)at javax.swing.JComponent.paint(JComponent.java:1031)at javax.swing.JComponent.paintChildren(JComponent.java:859)at javax.swing.JComponent.paint(JComponent.java:1031)at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)at javax.swing.JComponent.paintChildren(JComponent.java:859)at javax.swing.JComponent.paintToOffscreen(JComponent.java:5111)at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)at javax.swing.RepaintManager.paint(RepaintManager.java:1128)at javax.swing.JComponent.paint(JComponent.java:1008)at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)at java.awt.Container.paint(Container.java:1797)at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:734)at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:679)at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:659)at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExceptionat Shape.paint(Shape.java:46)at javax.swing.JComponent.paintChildren(JComponent.java:859)at javax.swing.JComponent.paint(JComponent.java:1031)at javax.swing.JComponent.paintChildren(JComponent.java:859)at javax.swing.JComponent.paint(JComponent.java:1031)at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)at javax.swing.JComponent.paintChildren(JComponent.java:859)at javax.swing.JComponent.paintToOffscreen(JComponent.java:5111)at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)at javax.swing.RepaintManager.paint(RepaintManager.java:1128)at javax.swing.JComponent.paint(JComponent.java:1008)at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)at java.awt.Container.paint(Container.java:1797)at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:734)at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:679)at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:659)at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)I tried to take out the 'setBounds' for the polygon method and I don't get the errors, but then I don't get any output on my window at all.Please let me know where I am going wrong!BUnzaga | I tried to change my classes to this and I just get a blank 256x256 window, but no errors...Driver Classimport javax.swing.*;import java.awt.*;/** * Write a description of class Driver here. * * @author (your name) * @version (a version number or a date) */public class Driver{ private JFrame theWindow; private Shape t1, t2, t3; public Driver() { theWindow = new JFrame("Output"); theWindow.setBounds(10,10,256,256); theWindow.setLayout(null); theWindow.setVisible(true); /*t1=new Shape("box", 0,0,50,50); theWindow.add(t1,0); t2=new Shape("oval", 75,75,50,50); theWindow.add(t2,0);*/ int[] x={10,25,50}; int[] y={10,0,30}; t3=new Shape(x, y, 3); theWindow.add(t3,0); }}Shape classimport javax.swing.*;import java.awt.*;/** Shape Supplier Class * Author: Brett Unzaga * Date: September, 2007 */public class Shape extends JComponent{ public String shape; public int[] polyX; public int[] polyY; public int polyN; public Shape(String s, int x, int y, int w, int h) { super(); setBounds(x, y, w, h); setBackground(Color.black); shape=s; } public Shape(int[] xPoints, int[] yPoints, int nPoints) { super(); shape="poly"; polyN=nPoints; int[] polyX=xPoints; int[] polyY=yPoints;// setBounds(x, y, w, h); setBackground(Color.black); } public void paint(Graphics g) { g.setColor( getBackground() ); if(shape=="oval") { g.fillOval(0, 0, getWidth()-1, getHeight()-1); } if(shape=="box") { g.fillRect(0, 0, getWidth()-1, getHeight()-1); } if(shape=="poly") { Polygon polygon = new Polygon(polyX, polyY, polyN); g.fillPolygon(polygon); } paintChildren(g); }} |
display lists | For Beginners | Hi,Im making a display list but im having some troubleThis is how I create it:snowfieldDL = glGenLists(1);glNewList(snowfieldDL, GL_COMPILE);/*glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, snowTextures.data[0]);*/for(int z = 0; z < depth-1; z++){glBegin(GL_TRIANGLE_STRIP);for(int x = 0; x < width; x++){int ind1 = (z+1)*width + x;int ind2 = z*width + x;Vector n1 = vertexNormals[ind1];Vector n2 = vertexNormals[ind2];glNormal3f(n1.getX(), n1.getY(), -n1.getZ()); glVertex3f(x*scale, (getHeight(x, z+1)/255.0)*maxHeight, -(z+1)*scale);glNormal3f(n2.getX(), n2.getY(), -n2.getZ()); glVertex3f(x*scale, (getHeight(x, z)/255.0)*maxHeight, -z*scale);}glEnd();}glEndList()This is how I call it:glCallList(snowfieldDL);But when I run it I get the error:GL_INVALID_VALUE everytime it tries to render. Wat am I doing wrong? | |
Opinions on using this GPL'ed library | GDNet Lounge;Community | My client wants me to use #ziplib to add ZIP file support to our project. I'm have some concerns and questions, all based on the fact that #ziplib is released under the GPL.This project is not being publically released. It's an internal project, so this may not be an issue at all (however, I do know that Google used to get flack from the FSF for their proprietary changes to Linux that they did not release, even though they only use it internally).This is the license statement for #ziplib:Quote:LicenseThe library is released under the GPL with the following exception: Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination.As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. Note The exception is changed to reflect the latest GNU Classpath exception. Older versions of #ziplib did have another exception, but the new one is clearer and it doesn't break compatibility with the old one. Bottom line In plain English this means you can use this library in commercial closed-source applicationsfor reference, here is a link to the GPL v3.Now, I know that normally, using a GPL'ed DLL in your project will require your project to also be GPL'ed. The IC#Code developers say that, as long as you don't modify the project, you can use the DLL without GPL'ing your project. It doesn't seem likely that the IC#Code developers can make that exception. If they say "we're releasing under the GPL," shouldn't they have to require full adherence to the GPL? It sounds like they are intending use of the LGPL, but don't mention it.At this point, I'm thinking we should just get a waiver of responsibility, having the client claim it fully in case this isn't kosher. | That's a rather confusing exception. I can't quite parse it. BTW, if you want a slightly less encumbering (I think) license, 7-zip can process a gigantic range of formats, and is available under the LGPL. ; Something doesn't rhyme:Quote:This project is not being publically released. It's an internal project, so this may not be an issue at allQuote:At this point, I'm thinking we should just get a waiver of responsibility, having the client claim it fully in case this isn't kosher.So, is it an internal project or is it work for a client? If it's internal (to *your* company) then it doesn't matter. GPL only applies to distribution and internal use is not distribution. If you build it for a client then it's more complicated, because it depends on who's contracting who. It your client hired you for some kind of internal (for the client) project, i.e. you're a "hired hand" then it's okay. OTOH, If it's your company selling a product (even if it's a one-off custom product) then it's distribution and the full GPL applies.But for ziplib it doesn't matter. As you quoted, they have an exception that allows you to link with it. As long as you don't change the source of ziplib, and give your client a GPL license + source of ziplib (not your entire app, just ziplib) then you're good.Oh, IANAL ofcourse and this ain't legal advice. But this is how I understand it (and I deal with GPL a lot). ;Quote:Original post by SanderIf your client hired you for some kind of internal (for the client) project, i.e. you're a "hired hand" then it's okay.Yes, this is the situation. It's part of their internal systems.Quote:But for ziplib it doesn't matter. As you quoted, they have an exception that allows you to link with it. As long as you don't change the source of ziplib, and give your client a GPL license + source of ziplib (not your entire app, just ziplib) then you're good.Oh, IANAL ofcourse and this ain't legal advice. But this is how I understand it (and I deal with GPL a lot).It's kind of crappy that they have to say "based on the GPL, gotta GPL your stuff if you dynamically link, but if you don't change the code, you don't have to GPL." It seems like they make the assumption that people are going to change the code before using it. I just want ZIP support for my .NET app, why would I change it?My understanding was that the GPL didn't permit "mixing and matching" licenses that were not compatible with the GPL. Having this proviso that one my dynamically link an unmodified version without fear seems to indicate that the IC#Code developers didn't do their own homework on what is and is not kosher with the GPL. My client says "I don't care, we use it all the time, just do it," but I know he tends to jump the gun on stuff and do whatever he pleases. I'd really rather not have a lawsuit open up just because someone couldn't be bothered to stop and ask "can we actually get away with doing this?"Oh hell, I might as well develop my own library in my spare time just to be sure. ; I was under the impression .NET already had basic functionality for reading from ZIP-compressed archives.The classpath exception in the GNU GPL exists because of the Java open-source project; they want to GPL everything (JVM, JDK standard library) but the ability to link non-GPL programs to the Java standard library is not compromised.You will be fine. In your case, you are dynamically linking to the Classpath-licensed library, but your project is not covered under the GPL as a result. You do have to provide the GPL source to #ziplib if someone asks, and you have to provide any modifications you made to #ziplib, but I doubt this will occur.IIRC, you can mix LGPL and GPL inside the same project (and in fact, LGPL exists for this very reason), so I'm not quite sure why the classpath license exists. I assume the classpath license allows for static linking, which LGPL certainly doesn't.I would email the authors asking them why they picked Classpath instead of LGPL.Edit: System.IO.Compression ; wouldn't a workaround for this is to make a service that provides the functionality, then just have your application communicate with the service. This way you only have to provide the source for the service rather than entire project. ;Quote:Original post by RavuyaI would email the authors asking them why they picked Classpath instead of LGPL.If I had to guess, I'd point to strong signing. The crux of the LGPL is that you (the end user) should be able to replace the library in question and have the application run on top of the new version. Strong signing makes this impossible to do, by design. By my reading, the GNU Classpath exception does not require this ability. ;Quote:Original post by PromitQuote:Original post by RavuyaI would email the authors asking them why they picked Classpath instead of LGPL.If I had to guess, I'd point to strong signing. The crux of the LGPL is that you (the end user) should be able to replace the library in question and have the application run on top of the new version. Strong signing makes this impossible to do, by design. By my reading, the GNU Classpath exception does not require this ability.Oh! Good point. I hadn't considered that, but you're probably right. ;Quote:Original post by RavuyaEdit: System.IO.CompressionI should have mentioned that there is a specific need for the PKZIP scheme, as we are only reading from ZIP files, and not writing anything. I had checked that out before. It comes with DeflatorStream and GZipStream. I don't know much about compression, but I tried the examples for both, and neither of them work on my test data from my client. GZipStream complains about a missing magic number, and DeflatorStream complains about buffer sizes not being matched, or something. I'll look into it a little more, but it doesn't appear to be working too well.The ZIP spec is "only" 52 pages long, and that includes a changelog for the majority of the life of ZIP, as well as uncommon extensions. I know I won't be supporting things like password protection, so implementing a cut-down version wouldn't be hard.We had a long discussion about this with the client today. They are of the perspective that the project is private-use, not being publically released, so there are no issues. Someone mentioned that the FSF was unsuccesful in doing anything to Google over changes to Linux, so that sounds like it's okay. At any rate, I have advised them of my opinion, I got my letter authorizing the use of the library from the client, so my company is officially off the hook. ;Quote:I assume the classpath license allows for static linking, which LGPL certainly doesn't.correct |
How low is a beginner here? | For Beginners | I'm in high school, and I'm taking a class on this stuff. I thought it would be good to join this website to learn more about game design, but now that I've taken a look around some of the threads, some of these subjects seem really advanced. So this forum's supposed to be for beginners, but exactly how low would a beginner be? Are there any other high schoolers here, or is this all for college or post-graduate people? (Please don't flame at me if I'm supposed to already know some things I don't). | You are the perfect person for "For Beginners" don't worry. A lot of us just use it for things like "I'm a beginner in collision programming so i'll start in the For Beginners forum". It's kind of a catch-all low-hanging-fruit forum.Don't worry that a lot of it seems "advanced"-me ;Quote:Original post by KorishobaI'm in high school, and I'm taking a class on this stuff. I thought it would be good to join this website to learn more about game designYou've made a good choice! There are plenty of articles to read, as well as a very active group of users waiting to answer your questions.Quote:... now that I've taken a look around some of the threads, some of these subjects seem really advanced. So this forum's supposed to be for beginners, but exactly how low would a beginner be?We're all beginners in one area or another. Reading around, asking questions, and practicing are the best ways to change this, for all of us.Quote:Are there any other high schoolers here, or is this all for college or post-graduate people? (Please don't flame at me if I'm supposed to already know some things I don't).There are indeed other high schoolers, as well as college-aged folk, as well as established professionals.In short, don't worry about being a beginner. Keep an open mind, take the advice you're given to heart, and don't stop practicing.Welcome to GameDev!-jouley; A beginner here can be anyone, from people who have never programmed in their life to seasoned veterans who are just learning a new language. Welcome to the forums. ; Hey buddy. I asked the same thing when I joined like a week or two ago. Im a sophmore in high school, and my only programming experience was a semester class where we made games with visual basic (in 9th grade). I thought it was easy, so I looked into doing some out of class. This year Im taking some AP Comp Sci class which works with Java.On here Im trying to learn C++ because it seems to be pretty popular (please dont get mad for that last thing)....Yeah I really dont know very much at all, but am trying now to make tictactoe.... ; Unlike some forums, people don't get flamed here for asking anything, even if inappropriate, as long as it's within the rules. ;Quote:Original post by FlyingMudPuppyHey buddy. I asked the same thing when I joined like a week or two ago. Im a sophmore in high school, and my only programming experience was a semester class where we made games with visual basic (in 9th grade). I thought it was easy, so I looked into doing some out of class. This year Im taking some AP Comp Sci class which works with Java.On here Im trying to learn C++ because it seems to be pretty popular (please dont get mad for that last thing)....Yeah I really dont know very much at all, but am trying now to make tictactoe....By the way thanks guys. I was kind of worried I was stepping out of my league. Cool you're a sophomore? Me too! The only real experience I have is with Game Maker. I'm making my own Mario game (I've done 3 levels working on the 4th). I'm also getting used to 3DS Max.Cool I know about C++ but I don't think my school has it. I do know a kid who uses it though. In Game Maker I know how to make a basic scrolling shooter and platformers, but I really want to get into the 3D stuff. ; I rarely come to gamedev anyomre because the topics are so advanced, I spend most of my time at allegro.cc. But I can almost understand a few of the topics here. ; Some of the stuff may seem advanced, but thats just because you don't understand what it means. If you were studying that area you would understand it right away. In this forum you get questions ranging from "why does this hello world program in c# not compile" to "how do I do a jacobi transform on this vector". You get a lot of questions like "should I use <acronym #1> or <acronym #2> as my collision detection library", and if you don;t recognise the acronyms then the question may seem advanced. Because its the Beginners forum, you don't get mocked or laughed at.;Quote:Original post by KorishobaBy the way thanks guys. I was kind of worried I was stepping out of my league. Cool you're a sophomore? Me too! The only real experience I have is with Game Maker. I'm making my own Mario game (I've done 3 levels working on the 4th). I'm also getting used to 3DS Max.Cool I know about C++ but I don't think my school has it. I do know a kid who uses it though. In Game Maker I know how to make a basic scrolling shooter and platformers, but I really want to get into the 3D stuff.It sounds like you have something that is designed for making games. We just learned the basics (like really really really basic) of programming and problem solving that is involved. The most complicated thing I did in visual Basic was make Snake and a program that would read in Sudoku files and would correct the player and give hints to the answer. It was a lot easier because we had a form, and could make our objects on it. I mean we could drag and drop timers.... It was all so easy... C++ and Java seem to be different in that with just a compiler I don't know how to make objects yet. Because of that I'm stuck making word games on the DOS prompt (and that is about as fancy with the lingo as I can get now).My goal is to be able to make some 2D games (using physics, which I am taking this year) by around Christmas. Im just planning on getting some books from a library, and then just working my way up starting simple..... |
Translate camera not object | Math and Physics;Programming | This is probably a really easy question but anyways...I need to find the distance from the center of a (translated) triangle to the camera. To do this I need to manually translate each vertex into the correct position without hardware acceleration which isn't exactly fast. So instead I was thinging I would apply the opposite translations to the camera because the distances to all the vertices would be the same that way. Like this.And it would have to include scaling as well. So basically the camera is in the same relative position to the object if it were the object that would have moved.How do I do this with matrices? Thanks. | You do the opposite transformation on the camera's location by multiplying it by the inverse of the triangle's transformation matrix. ; Oh... well that sounds really easy! Thanks. |
[XNA] Use and Implementation of XACT | Graphics and GPU Programming;Programming | Can someone explain to me why I have to use exact for creating games in XNA? Why can't I just load in a wave file and play sounds (asking more for the benefits of using XACT), thanks. | XACT allows a sound designer to work on the sound aspect of the game, and the programmer to easily apply hooks for events for when the sounds are to be played. That's the theory, at least. As far as implementation goes, it's lacking, to say the least. ; Is there an alternative to using XACT? I really don't like the file size of wave files. ; If you want your code to run on the XBox360, then there is no alternative. The announcement of XNA 2.0 (here) mentions a new XACT editor, but unfortunately it gives no further details. If you are planning to stick to the Windows platform though, you can pretty much go with whatever you like. I heard the FMOD package is very good; it's free for non-commercial use, it comes with a supported C# API and it supports numerous formats. |
FBO: Performance issues with G_TEXTURE_2D and color + depth/stencil | Graphics and GPU Programming;Programming | Hi, during writing my fbo code part I came across a problem. I create my fbo, color and depth/stencil target with the follorwin code part//creating FboGLuint mFboId;glGenFramebuffersEXT(1, &mFboId);glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFboId);//creating color targetGLuint mGlTextureId;GLenum mGlTexTarget = GL_TEXTURE_RECTANGLE_ARB;glGenTextures(1, &mGlTextureId);glBindTexture(mGlTexTarget, mGlTextureId);glTexImage2D(mGlTexTarget, mMipLevel, GL_RGBA8, mWidth, mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);glTexParameterf(mGlTexTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameterf(mGlTexTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);glTexParameteri(mGlTexTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameteri(mGlTexTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);glGenerateMipmapEXT(mGlTexTarget);glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, mGlTexTarget, mGlTextureId, 0 );//creating depth targetGLuint mGLDepthId;glGenTextures(1, &mGLDepthId);glBindTexture(GL_TEXTURE_RECTANGLE_ARB, mGLDepthId);glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_DEPTH24_STENCIL8_EXT, mWidth, mHeight, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL);glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_RECTANGLE_ARB, mGLDepthId, 0);glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_RECTANGLE_ARB, mGLDepthId, 0);This code snipped works very good when it comes to performance, but if I change every occurance from GL_TEXTURE_RECTANGLE_ARB to GL_TEXTURE_2D the performance drops from ~200fps to 25fps.This strange behavior doesn't change if I change the depth attachment to a renderbuffer or remove the stencil part and use GL_DEPTH_COMPONENT. When I use texture_2d the framerate drops immediately if the depth buffer is attached (when I'm only rendering into the color buffer, the framerate is as fast as it is with rectangle and depth buffer).This occurs with a nvidia 7600Gt and a Quadro FX 3400 with the latest nvidia drivers. only on a 8800gtx the fps stay the same with both options.Does anybody know why, the rectangle version is faster, or do i have some wrong parameters in my code snippet, that makes my application perform that slow on non 8series gforce?yoursg3k | i dont think GL_TEXTURE_RECTANGLE_ARB supports mipmapsthus i assumewhen u update the FBO wih texture2d all the mipmaps are created each frame (hence the slowdown); My home video card had a massive slow down if i use non-power-of-2 with GL_TEXTURE_2D as opposed to GL_TEXTURE_RECTANGLE_ARB, so it could be a case of NPOT2 not being handled as desired, or as zedz said, auto mipmap generation.If you're using the fbo for fullscreen effects, you would be better of disabling mip-mapping altogether for those textures regardless (although there is potential for simple Depth-of-feild from using mipmaps) |
Official Iron Man Trailer | GDNet Lounge;Community | Forget the crappy YouTube version, see it in HD baby! | Nice! It just had to have Black Sabbath in there. ; I'm still crapping my pants over the Hitman trailer I saw in the theater last week! ; ^^I hope you mean that in a bad way. The Hitman movie looks terrible. I mean come on, Agent 47 looks like a baby. I have a feeling they cast him before shaving him bald and going "uh oh...this isn’t tough at all".The girl on the left scares me more than him.As for the Iron Man trailer, that looks pretty bloody good! The music seemed a bit out of place, but I think Robert Downey Jr fits the role of Tony Stark really well. ;Quote:Original post by boolean^^I hope you mean that in a bad way. The Hitman movie looks terrible. I mean come on, Agent 47 looks like a baby. I have a feeling they cast him before shaving him bald and going "uh oh...this isn’t tough at all".The girl on the left scares me more than him.As for the Iron Man trailer, that looks pretty bloody good! The music seemed a bit out of place, but I think Robert Downey Jr fits the role of Tony Stark really well.Black sabbath will never be out of place! Shame on you. Even though, in recent years, Ozzie Osborn has lost all his talent.; btw, what's with the noise when he flies past the camera the second time with the planes behind him and it makes that 'ZoooOOOO' kinda noise? It sounds fricken awesome! ;Quote:Original post by boolean^^I hope you mean that in a bad way. The Hitman movie looks terrible. I mean come on, Agent 47 looks like a baby. I have a feeling they cast him before shaving him bald and going "uh oh...this isn’t tough at all"....For being one of my favorite games of all time I can't help but feel a little fanboyism. And it doesn't look terrible, it's just your standard action flick (don't worry, I can see the jokes from a mile away). Although I do agree on the slightly poor casting.At least it looks better than DOOM. I don't have to smell what the Rock is cooking this time around. ;Quote:Original post by shotgunnutterQuote:Original post by boolean^^I hope you mean that in a bad way. The Hitman movie looks terrible. I mean come on, Agent 47 looks like a baby. I have a feeling they cast him before shaving him bald and going "uh oh...this isn’t tough at all".The girl on the left scares me more than him.As for the Iron Man trailer, that looks pretty bloody good! The music seemed a bit out of place, but I think Robert Downey Jr fits the role of Tony Stark really well.Black sabbath will never be out of place! Shame on you. Even though, in recent years, Ozzie Osborn has lost all his talent.I wouldn't say all of his talent. He might not be able to say a damn word, but he can still sing (for the most part). I saw him live at ozzfest in 2005. |
Chaotic Realms - Need spriter and music composer | Old Archive;Archive | Thread title - Chaotic Realms*Canceled*Team name:N/AProject name:Chaotic RealmsBrief description:Intro of the Idea:You are <player selected name>, a boy/girl from the town of <town>, on the continent of <continent>. A long time ago the world was in danger, a terrible man has gained incredibly power, he was a god himself. To save the people of the continent the most powerful Sages came and took <continent> it self, out of time and space, into a different dimension. A warp hole appears from the normal dimension. You get sucked into it and go into a random place at a random time....Idea:The game would have it so the player can enter the warp hole and go into a random dungeon at a random time. The dungeon would be completely random. Once you gain up more holes will appear leading to new times and dungeons. Once you beat them all you will face the final boss.The game would go into the future and past times from the prehistoric age to the future times. Guns won't be in the game only swords and basic stuff like that.Target aim:freewareCompensation:Possibly paying, depending on skill.Technology:Engine - Game MakerThats what im using to make it.Talent needed:Spriter - To sprite tilesets for dungeons and characters along with monsters.Music Composer - To make music for it, obviously.Team structure:Warriorccc0, only person.Contacts:If you want to contact me its a good idea just to PM meor better yet add me on msn/live messenger: '[email protected]'Previous Work by Team:I've done several projects: http://www.yoyogames.com/user/warriorccc0[Edited by - Warriorccc0 on September 13, 2007 8:05:54 PM] | |
Game Flickers on Vista | Graphics and GPU Programming;Programming | My C++ OpenGL game flickers in release mode. It is a full screen game.It was originally flickering as both debug and release build. But after specifying the PFD_SUPPORT_COMPOSITION flag to temporarily disable Aero, it no longer flickers in debug.However, it still flickers as a release build.Perhaps there is another setting somewhere that could affect this??I am using MS Visual Studio Express with the Windows SDK.Thanks. | |
Freeworld3D 2.3.0 now supports Second Life RAW heightmap format | Your Announcements;Community | The latest release of Freeworld3D 2.3.0 now supports editing Second Life RAW heightmap files. All other channels are left in tact when importing/exporting the data. See the website for details.Freeworld3D Website | |
Did DevImg.net die? | GDNet Lounge;Community | www.DevImg.netI'm a long-term fan of this site; while it used to have a fair bit of activity, it seems to be dead right now. Do people here know about it? It's a great place to upload screenshots and demos for free, and it would be cool to see GameDev users there more. It's the creation of a member of this site, after all... | i remember back in the day, they had some ads up here on gamedev.. hasnt seen those run inna while.. i stopped visiting it once i stopped game deving '=/ ; I've seen sites that look deader than this one. I'd say it's become less traveled by people, but certainly still functional. I remember a few months ago (maybe longer, my sense of time is horrible) it was having some problems - tho I think it was just that CGameProgrammer forgot to renew his domain name. That may have caused a hit on the site's traffic it still hasn't recovered from.Still, if I had any dev shots to post I'd def post them up there as well as other sites. |
Programming logic question | General and Gameplay Programming;Programming | I am a newbie at programming, well kinda. I have dabbed in freebasic and c++, and java at school. I even started making some simple 2d games, but never finished them. So here is my question.In a game like for example space invaders, there are multiple bad guys on screen at same time. I'm not quite sure how you go about making a bunch of different AI npcs move around to different places all at same time. I mean making one move around is one thing, but like 30? Is it done using multithreading? or what I dont know. | it is done really fast in between each frame render. sort of like this:mainLoop: while user has not quit: handle user input update enemy positions draw world (including enemies) to screenwhere your update enemy positions would be you iterating over a collection of enemies and updating their position one at a time. ;Quote:Original post by neal8929I'm not quite sure how you go about making a bunch of different AI npcs move around to different places all at same time.One at a time, but you create the impression of moving at the same time by doing all the moves in between drawing operations. |
Studying overseas - where do I even start? | GDNet Lounge;Community | If everything goes to plan by December, I may be moving from the sunny coasts of Queensland to the moose infested ice covered wastelands of Canada mid next year for a total of 4 years.There is a course in Canada for video game concept art with a wee bit of animation, and if everything goes to plan, I’ll get a reply from them in December as to wether or not I am in (the good thing is that I can always switch over to sequential art / 'teh comics pew pew pew' if its full). This presents the fun of moving overseas to study, something I have no fucking clue where to start planning.I've got a million questions like what do I do with all my stuff here, how do I find work and how much can I work, how do I find a place to stay, how do student visas work? bla bla blaBut rather than write out a checklist 5 pages long, I'm wondering if anyone else here has ever moved overseas to study and could explain how you did you it? Is it mind bendingly complicated as it seems? Do the moose in Canada really rip doors of with their teeth?Cheers lads! | I won't be able to answer your main question, but I can give you a few tips about where you're moving to. Which province/city is the school in? As long as you can stay away from the Atlantic provinces, you're safe from meese [Grin] ; I'll be heading to Toronto, right near Queen Street.edit - oh hey, your from Toronto! =D The good part is that I'll probably be heading there June/July (not sure when you can first head over if you are on a student visa), which are the warmer months thank God =P ; Where in Canada is a rather important bit, and seeing as you are going to Toronto, things shouldn't be too bad for you. (unless they get mild snowfall again,...)Quote:Original post by Karan BhanguiWhich province/city is the school in? As long as you can stay away from the Atlantic provinces, you're safe from meese [Grin]Meese? You mean Moose? You do know those are found basically everywhere in Canada right? If you don't want to risk running into one in the woods, go to Newfoundland, the far north, or possibly Prince Edward Island, but I'm not sure if we actually have them here or not.As for working, you'll have to check your paper's, and possibly apply for student work permit if you aren't given one. I don't suggest working without one. I know several students from abroad here that work full time in the summer and part time in the winter, so working shouldn't be a problem as far as the law goes.As for a place to stay, can't really help you there, try contacting student services at whatever school you are going to.For your stuff, how much do you have, and how much is it worth? Figure out how much the bulk of it is worth, and then figure out the costs of bringing it with you, or the cost of putting it in storage for 4 years. Likely both these costs will be more than the value, in which case you take the junk to the dump, and the decent stuff is dropped off at a local university town.Don't bother with getting too much material wealth in life, remember, it usually just ends up being a bitch to move, and you will move in life. ;Quote:Original post by TalrothWhere in Canada is a rather important bit, and seeing as you are going to Toronto, things shouldn't be too bad for you. (unless they get mild snowfall again,...)Quote:Original post by Karan BhanguiWhich province/city is the school in? As long as you can stay away from the Atlantic provinces, you're safe from meese [Grin]Meese? You mean Moose? You do know those are found basically everywhere in Canada right? If you don't want to risk running into one in the woods, go to Newfoundland, the far north, or possibly Prince Edward Island, but I'm not sure if we actually have them here or not.Yeah I know it's Moose (hence the grin). If he's moving to Toronto (Queen Street being proper downtown), he won't see a moose lol. Boolean, Toronto is very far south, even compared to parts of Northern USA. So the snow fall here is very minimal in winter (esp in the past few years, i guess it can be attributed to global warming). If you're going to University of Toronto, best bet is to PM Saruman ;) ; Cheers! Thanks for the help guys. Quote:Original post by TalrothAs for working, you'll have to check your paper's, and possibly apply for student work permit if you aren't given one. I don't suggest working without one. I know several students from abroad here that work full time in the summer and part time in the winter, so working shouldn't be a problem as far as the law goes.That's cool that people can work full time on a student work permit. I was worried I might be stuck with a few hours a fortnight max or something. Quote:Original post by TalrothAs for a place to stay, can't really help you there, try contacting student services at whatever school you are going to.How would it work if you wanted to rent with people? I'm guessing the schools would not help with that, would they? It might seem a bit odd to ring someone up 'yeah hi, is that room still free? Come by sometime? Can't, I'm in Australia", so I have no idea how I'm going to get all that to work Quote:Original post by TalrothFor your stuff, how much do you have, and how much is it worth?I wouldn't even know where to start. Not a whole lot of stuff though I guess since I only moved 5 months ago. I'm guessing shipping anything over costs roughly the same as the yearly income of a small country? I think the real tricky part is what to do with my PC (near brand new and rocks peoples faces off), my 360 and Wii =/ ;Quote:Original post by booleanQuote:Original post by TalrothFor your stuff, how much do you have, and how much is it worth?I wouldn't even know where to start. Not a whole lot of stuff though I guess since I only moved 5 months ago. I'm guessing shipping anything over costs roughly the same as the yearly income of a small country? I think the real tricky part is what to do with my PC (near brand new and rocks peoples faces off), my 360 and Wii =/You can try to bring as much as you can in your departure flight. You are usually allowed to check-in two bags that will go in the cargo bay and two smaller bags that you carry with you (must fit under a seat). Though if you try to fit a computer, a 360 and a Wii in one luggage, it might be overweight.But that's all at no additionnal cost once you have a ticket. Contact the airline company you will be travelling with for more information. ; We don't get much snow or moose down here in Vancouver, either. Actually, it didn't snow at all last winter. ; Shipping your computer and that shouldn't be all that expensive, basic air freight really only gets painful when you start looking at that great couch that is just so comfortable and perfect, and 9 feet long,...Just please remember!Before You Turn On Your Computer in Canada, CHECK THE SETTINGS OF YOUR PSU! You know that little switch on the back you're not suppose to play with else you get magic smoke rolling out of your system? I think you have to play with it in the case of moving. (at least I think you are on a different power style than here)Quote:Original post by Oberon_CommandWe don't get much snow or moose down here in Vancouver, either. Actually, it didn't snow at all last winter.Wasn't the island hit with a massive snow storm last winter? How did you manage to avoid that? You are a long way from the island I know, but it isn't all that far. ;Quote:Original post by Talrothbasic air freight really only gets painful when you start looking at that great couch that is just so comfortable and perfect, and 9 feet long,...*backs away as Talroth breaks down into tears over his couch*hehe, nah I won't have anything that big. Mainly just my consoles and PC with games, my books and probably other odds and ends. I think most stuff (like half my clothes) I'll just rebuy when I get over there. I guess what's still my #1 concern though is finding a place to stay. The college I am (hopefully) going to has no onsite housing, so I'm buggerd if I know what to do. If any current or past students have any advice, please post! =D |
What books did developer read for game development in the 1990s? | For Beginners | I want to make a game But I wonder how game developers worked in the 1990s, how they made games, how they learning before the Internet became as widespread as it is today. etc.how do they know how to build game mechanics as character ability power up system?how they know to reverse engineering game competitor company.what book I should read? | As far as I know (not being a programmer myself), books on the subject started appearing in the early 2000s. Up to that point, it was “learn by doing” and tips from one another. ;The first book that came to mind was Tricks of the Game-Programming Gurus: Lamothe, Andre, Ratcliff, John, Tyler, Denise: 9780672305078: Amazon.com: Books, which was geared toward beginners/students/amateurs. There were others, but that's the best selling pre-2000. After that point in time, game development became a hot topic in the book publishing world. Even GameDev.net has a series - Beginning Game Programming: A GameDev.net Collection (Course Technology Cengage Learning): 9781598638059: Computer Science Books @ Amazon.com.Otherwise, in the professional realm a lot was “learn by doing” as Tom said, or through word of mouth on early Usenet/IRC/websites (pre-GameDev.net in 1999 - see About GameDev.net). ;Computers in that era didn't have an OS like we have today. The machine booted, and you were dropped in a command shell or in an interactive BASIC interpreter. You basically programmed directly at the metal. Video memory was directly accessible, by writing in a known address range you could make pixels appear at the screen in various colors. The “OS” had a corner in the memory too for its data, but nothing prevented you from poking around there. Lua, Python, C#, C++ didn't exist, ANSI-C was just invented (K&R book about that was in 1989 iirc). Assembly language of course did exist (with books) and was used.Monthly computer magazines were published for all types of home computers. Tips and tricks were exchanged in that way, also program listings were printed in those magazines that you could then enter at your own computer. Studying those listings, and trying things for yourself is how you learned. There was also technical documentation about the computer.If you want to enjoy that stuff, today there is a retro-computing movement, that lives in that era, except with slight more modern hardware but still no OS, etc.;Alberth said:Computers in that era didn't have an OS like we have today.In the 1990s there was MSDOS, Several versions of Windows, and of MacOS. And that's not all the operating systems of the nineties, most likely.Like Linux, for instance.;Tom Sloper said:Alberth said:Computers in that era didn't have an OS like we have today.In the 1990s there was MSDOS, Several versions of Windows, and of MacOS. And that's not all the operating systems of the nineties, most likely.Like Linux, for instance.Yep. There were things like Windows 95, Win 98, and at the time I was still using a Commodore Amiga (AmigaOS) .To deal with the original question “what game dev books was I reading in the 90s?” Back in that era, one of my favorites was : The Black Art of 3D Game Programming by André LaMothe. ;Abrash was the guy who did the Windows NT graphics subsystem and worked on Quake.https://www.drdobbs.com/parallel/graphics-programming-black-book/184404919 ;There are a couple of" history of video games" books, that track the rise of the medium and genre.Just google for them. ;GeneralJist said:There are a couple of" history of video games" booksThat's not what the OP is looking for.;Thanks all |
Choosing a career in AI programmer? | Games Career Development;Business | Hello everyone, my name is Ramon Diaz; I am currently studying Game development and programming at SNHU. I have taken the initiative to learn about a professional career in AI programming. I have a lot of gaps in my development in the short term. I have blueprint experience with AI but not enough to choose a career in this profession. I would like to know how I can be competitive leaving the university in 5 months after finishing my studies. I am looking for knowledge from all of you who have been in the industry for years. | Entry level? Know your algorithms, it will help you at interviews. If you have made demos it can help you get jobs, but the market is wide open right now and should be relatively easy to find work for the foreseeable future. Overall, it reads like you are on the right path. When you graduate and start looking for work, be open to any positions rather than just an AI specialty. Once you have a job it is easier to transition into whatever specialty you prefer.;Thank you. ;I would like to know how I can be competitive leaving the university in 5 months after finishing my studies.Talk about last minute. Create AI projects? Or A game with character behaviors? Pathfinding examples. Crowd movements. Anything really. Learn how navigation meshes work.;@dpadam450 Character Behavior is what I doing in the project at this moment. Everything related to AI programming.;@dpadam450 Is it the same when learning C++ in AI as visual scripting Blueprint? If I were to make a demo, what kind of programming should I focus on my attention? ;@frob It is important to have a portfolio? ;Not for programming. You will need to show you know how to do the work, but it is usually some interview questions and writing some code of their choice. If you have something you want to share with them, you can do it if you want. Having done fancy demos can sometimes help get interviews, and can help show your interest and abilities, but it is generally not needed. It does not hurt, unless you do it badly and therefore becomes a cautionary warning. Build it if you want. I have interviewed and hired bunches of programmers without portfolios. ;I'm studying AI at the moment, in terms of statistical learning. I've learned so much about AI over the past few weeks. Check out: https://hastie.su.domains/ISLR2/ISLRv2_website.pdfandMachine Learning with R: Expert techniques for predictive modeling, 3rd Edition |
Newbie desperate for advice! | Games Business and Law;Business | Hi allI'm new to the game development community and need some advice.I've created 2 educational games with a simple idea but are sufficiently challenging for all ages. These could be played on pcs or phones.Is it worth patenting any parts of the games?What would be the best way to monetize?How should I market the games? | hendrix7 said:I'm new to the game development communityReally? Your profile shows that you've been a member here since 2004, and your last activity was in 2007, asking about raycasting.hendrix7 said:Is it worth patenting any parts of the games?Probably not. Expensive and there will be hurdles, and possible lawsuits after the patent is granted (if it is).hendrix7 said:What would be the best way to monetize? How should I market the games?There are several threads here in the Business and Law forum about that. While you wait for more replies from the community, you can read up on those previous answers to those questions. Mainly, “you should have thought about that before you finished your games.” (You wouldn't be “desperate” now.) Good luck with your sales!;@hendrix7 Filing for a patent can be expensive, and you need to document the solution and how it separates from anything else. I have developed software that solved problems in a way that no other software does, but there is only a very small portion of that that can actually be patented. Even though you can file an application yourself, I would recommend hiring an experienced IP attorney. This too is very expensive, though, so you are best off doing this if this idea can provide millions in income. If it can't, then it's actually not that harmful if anybody copies it.You could look at registering trademarks, design and other parts of the games. This is cheaper, but it will protect you brand more than your idea or solution.Again, if this is something that could turn a real profit, it might be worth looking into. If not, it's a very costly waste of time.As for marketing - my day job is actually creating videos and commercials etc., so naturally that's the first thing that comes to mind.Make videos for social media or other platforms where your target audience is likely to see it. Oh, and you need to define a target audience. Know where they are, what they respond to, what their struggles are and how your product will solve their problems, enhance their life experience or in other ways contribute positively to their life.There are several other ways to do this, but the list exceeds my level of expertise in the area.;patenting is costly, and time intensive. As said above, it depends on a lot if it's worth it. ;@hendrix7 Nothing is worth patenting unless you're willing and able to defend your patent. There is no patent police; you're responsible for finding and prosecuting infrigement.What you're patenting has to be novel and non-obvious to a person skilled in the art. You called your idea ‘simple’ which makes me wonder if it's obvious or already in use.;@Tom Sloper Thanks TomI have been programming for a while but not games until now.Thanks for getting back and your advice, particularly patents.;@scott8 Thanks for your reply.I see. The play of the game utilises basic maths skills so I'm guessing it'll be difficult to identify anything that's unique. I suppose, in a similar way, it would be difficult to patent something like ‘Wordle’. Am I right? |
Hi I'm new. Unreal best option ? | For Beginners | Hallo everyone. My name is BBCblkn and I'm new on this forum. Nice to virtually meet you 🙂. One of my biggest dreams is to make my own videogame. I love writing design as in text on how my dream game would be. Now I got no skills to create it. But who knows what life will bring. Is Unreal the best program to have fun with an experience ? Obviously I prefer a simple but capable program. Not pre designed auto drop. Why not install Unreal and roam into it and see if anything happens.My favorite games are in the genre of Fantasy, usually stone age with magic. Dota, Homm, Diablo and the odd one out is the genius Starcraft 1. But I played plenty of different games, especially when I way younger. I don't game currently at all but designing gets my creative juices flowing and is so inspiring and fun. Thanks for having me guys | BBCblkn said:My name is BBCblknI am truly sorry for you. Even Elons daughter has a better name than that.BBCblkn said:Is Unreal the best program to have fun with an experience ?Give it a try, but it's not meant for total beginners.Starting small always is a good idea. 2D is easier than 3D. You could try GameMaker, learn some programming language, learn some math, move on to more advanced engines like UE or Unity… ;There's honestly no perfect program for beginners. If I had to compare Unreal though at my skill level, I would probably pick Unity. However, It really comes down to your needs, and how much programming you want to learn. Furthermore, I would also keep in mind other engines.;@BBCblkn I'd recommend Gamemaker studio 2 as a first engine. It's easy to learn and I haven't had a problem making my game ideas in it yet.There are some good tutorials on YouTube to follow to learn it. Do note you'll be limited to 2D games with GMS2.Bit late to the post, but I hope it helps;gamechfo said:Bit late to the postTwo months late. Always consider whether you honestly believe that a question asked long in the past is still awaiting an answer. Thread locked. |
How to publish a book? | GDNet Lounge;Community | Hello, So, over the holidays I finished my 1st book. Do any of yall writer types know where I can find:an editorpublisherIt's like 99% done, just need to know what to do next. Also, it's cross genre, so it doesn't necessarily fit the standard model. | You've given nowhere near enough information to get a final answer, but I can suggest next steps for you. (For background, I've worked as an author, co-author, editor, and ghostwriter on 9 books so far.)Publishing is a business deal. You need to figure out what business services you need.Do you even need a publisher? Do you need a distributor? You already mention needing an editor. Do you need marketing? Do you need retail agreements? Digital or physical? If physical, POD or offset, how many each of hard or soft, what size of print run can you afford? What business services do you need? Publishers have an awful lot of potential features of what they can provide and what those services cost.Once you know the list of services you actually need, your favorite bookstore will have books that have listings of all the major publishers and hundreds of minor publishers, along with the services they provide and the specialties they work with. Work through the listings methodically, and talk to them all until you've got a deal. You'll also want to start shopping around for a lawyer at that point, both because they have connections and because they'll be working with the contracts you'll be signing.Once you know what you need and have talked with your lawyer the first few times, you will be ready to start shopping around. It's far better if you have more money and are using the publisher as a paid service. That is, you pay them for the services they provide up front. It will cost you many thousand dollars but you'll require far fewer sales to reach profitability. It can be better to do an online plus POD service starting out if you're self funded. If they need to front any of the money there will be two phases to the deal, one phase before it's profitable and another after a threshold is reached and it's profitable. The exact terms will depend on your needs and the services they'll be providing. Before you sign with anyone, you'll need to work back and forth more than once with your lawyer to help you negotiate what's fair in the agreement. Good lawyers understand the costs of the various services and can help you get fair rates.Just like publishing games, the more you need from them the harder your pitch becomes. If you need a lot of services the more it will cost you. If you're looking for them to invest in you, front you money, and pay for the books, don't expect a lot of money from the deal, and in addition your pitch needs to be amazing and you'll be rejected many times. If you've got the money to self-publish and are only looking for retail agreements that's rather easy. ;hmmmWell Self publish might work too. I'm looking for:an editor publishing distribution for ebookNo hard cover or physical book planned at this timemaking cover art. Future Audio book production. I think that's it. I'd be willing to do physical print if needed, but I don't really want to pay for that at this time. frob said:You've given nowhere near enough information to get a final answer The issue is I don't know what questions or criteria I should be asking or looking for. ;Have you considered publishing with Packt?https://www.packtpub.com/;GeneralJist said:2. publishing distribution for ebook 3. No hard cover or physical book planned at this timeFor distribution of an ebook there are plenty of options. Amazon is the biggest with kindle direct publishing requiring little more than an html file and an image for the title. If you are comfortable with software tools you can use that same document to build/compile every other format out there. You're on the hook for everything else with the business if you go that route, but it can work well if you are marketing through your own channels.There are many ebook publishers out there targeting specific platforms and specific readers or specific genres. I mentioned publisher lists, they also include electronic-only publishers. Understand the tools they use against piracy are also helpful since otherwise anybody with access to the file can make unlimited copies.Be careful of contracts, you almost certainly want something that has a non-exclusive agreement since you've done all the work yourself already. If a publisher wants an exclusive deal they need to be putting quite a lot on the negotiating table.GeneralJist said:4. making cover art.Find an artist with the style you like and contact them. Often it's in the range of a couple hundred bucks, especially for ‘unknown’ artists when they're starting with something that wouldn't have seen the light of day otherwise. Artist friends are best, and asking around at local art schools is inexpensive.GeneralJist said:5. Future Audio book production.If you don't need it now, it's something easily done later.GeneralJist said:1. an editorThis one is the most difficult. Skilled editors are amazing. If you go with a publishing house they'll provide professional editors, at professional rates. ;taby said:Have you considered publishing with Packt?https://www.packtpub.com/hmmm 1st time hearing of them.Looks like they are more of an educational option?My book is a mix of mental health journey auto bio, and Sci Fi elements. It's not really a standard “how to” for game dev. ;so I just heard back from my 1st publisher submission.https://triggerhub.org/And they essentially say they be willing to look at it deeper, and have extensive edits to focus on the mental health angle. but they would want me to cut a lot. From what they are hinting at, It sounds like they want to cut a lot of the Game dev and gaming journey, as they are a publisher focused on mental health.So, now I need to decide what to do.I sent them back an email saying I'm open to continued dialogue.Without knowing exactly what they want to cut, and edit, I don't know how to proceed.Also, would it be better to hold out, and find a publisher that is willing to accept most of the game dev journey, as I'm looking for a continued publisher to work with, aka accept most of the book as is. Any advice would be helpful.Thanks yall. ;GeneralJist said:Any advice would be helpful.Look into your own mind and heart.;hmmmok,So I've submitted to a few other places.We shall see.I submitted to this place called author House, and they got back to me really quick, but it looks like they want me to pay a couple thousand for a package:https://www.authorhouse.com/en/catalog/black-and-white-packagesI personally find that a bit frustrating.I mean, really, I wrote the book, I thought traditional publishers get paid from a % of sales?@frobWhat do you think?Is the above package a good deal?I was also a little put off, as it seems the person who called me didn't even read anything about my book, and asked me “so what's your book about?"beyond the above, how does this usually work? Edit: so, after a bit of basic research, it seems the above organization is a bit scamy. The hunt continues. ;You're unlikely to get a publisher deal, where the publisher pays you an advance and distributes your book to retail outlets.You'll have to self-publish, meaning you have to bear all the costs for printing, and nobody will distribute it for you. https://en.wikipedia.org/wiki/Vanity_press |
First-person terrain navigation frustum clipping problem | General and Gameplay Programming;Programming | I am trying to develop first-person terrain navigation. I am able to read a terrain and render it as well as to move around the terrain by interpolating the location of the camera every time I move around. The main problem I have is that depending on the terrain, i.e. moving on a sloping terrain, the near plane clips my view (see below). What is the best way to avoid this? Presumably, I can interpolate the heights for the bottom corners of the near plane … any help would be appreciated. | I believe this can aways be an issue. I mean if you are clipping to a near plane and that plane passes through geometry, it has to do something. That being said you technically don't have to clip to a near plane at all, however many graphics APIs require it. Another other thing to consider is once you have collision working, you can put your camera, including your near clipping plane inside a collidable object, for instance a sphere, such that this problem will never occur. If you are eventually going to make this a real first-person game, that should take care of the problem since your camera will be inside the players head. Even in a 3rd person game you can put them inside a floating sphere. ;Gnollrunner said:That being said you technically don't have to clip to a near plane at all, however many graphics APIs require it.The near clip plane is always needed, even if you use a software rasterizer. If you don't do the clipping, vertices would flip behind the camera, causing glitches way worse than what we get from clipping.mllobera said:What is the best way to avoid this? Presumably, I can interpolate the heights for the bottom corners of the near plane … any help would be appreciated.Yes, basically you want to ensure that the camera is in empty space (above the hightmap), not in solid space (below the heightmap).But in general you can not treat the camera as a simple point, because the front clip plane requires a distance larger than zero. So ideally you build a sphere around the camera which bounds the front clip rectangle of the frustum, and then you make sure the sphere is entirely in empty space, for example. In the specific case of your terrain not having too steep slopes however, it should work well enough to sample height below camera, add some ‘character height’, and place the camera there. That's pretty simple and usually good enough for terrain.It's quite a difficult problem mainly for 3rd person games in levels made from architecture. It's difficult to project the camera out of solid space in ways so the motion still feels smooth and predictable.Some games additionally fade out geometry which is too close, attempting to minimize the issue.Imo, the ‘true’ solution to the problem would be to let the clipping happen, but rendering the interior volume of the geometry as sliced by the clipping plane.That's pretty hard with modern rendering, which usually lacks a definition of solid or empty space. But it was easy to do in the days of Doom / Quake software rendering. When i did such engine, it was possible to render clipped solid walls in simple black color. This felt really robust and not glitchy, so while it does not solve all related problems, i wonder why no game ever did this. ;@undefinedJoeJ said:The near clip plane is always needed, even if you use a software rasterizer. If you don't do the clipping, vertices would flip behind the camera, causing glitches way worse than what we get from clipping.You can clip to a pyramid instead of a frustum. I used to do this many years ago on old hardware. So there is no near clipping plane. In fact you don't need a far clipping plane either.Edit: Just wanted to add as far as I know the near and far clipping planes mostly have to do with optimizing your Z resolution. If you are dealing with that in other ways, I think they aren't strictly necessary. I currently don't even deal with the far plane and let LOD solve Z-fighting issues.;Gnollrunner said:You can clip to a pyramid instead of a frustum.I see. You still have front clip. It is a point, formed indirectly as the intersection of the other other frustum planes.I've misunderstood your claim to be ‘you don't need a front clip’. But you didn't say say that. Sorry. But now i'm curious about the experience with z precision you have had. I guess it just worked? Which then would probably mean: All those painful compromises of ‘make front plane distant so you get acceptable depth precision for large scenes’, are a result of a bad convention being used by APIs?Or did you use no z-Buffer? ;@undefined My whole engine is based on aggressive LOD and culling. I don't do projection in the matrix. It's a post step. My Z coordinates are world distances. My current project does have a near clipping plane mainly because DirectX wants one, but it's not that relevant for my application.;Ah, so you use the pyramid for culling only. But for rasterization, the usual front clip plane at some distance i guess.Still an interesting question if ‘some distance’ is really needed, but i guess yes.I did some experiment about point splatting. It uses spherical projection, which is simple than planar projection:auto WorldToScreen = [&](Vec4 w){Vec4 local = camera.inverseWorld * w;if (local[2] < .1f) return (Vec3(-1)); // <- front clip at some distance of 0.1Vec3 screen = (Vec3&)local;screen[2] = length(screen); // if it was zero, i'd get NaN herescreen[0] = (1 + screen[0] / (screen[2] * camera.fov)) / 2;screen[1] = (1 + screen[1] / (screen[2] * camera.fov)) / 2;return screen;}; Planar projection would cause division by zero too, i guess.;Thanks for all your comments! I will need to investigate how to do what Gnollrunner proposed (about putting the camera inside of a sphere). ;This may be obvious, but in case it helps:Let me note that, as a first-person camera may be more likely than a third-person camera to draw very close to geometry, it likely makes some sense to have a smaller near-plane distance for the former than the latter.Now, this only ameliorates the problem, it doesn't remove it entirely: it means that the problem will still appear, but only if the player gets very close indeed to a surface. It's intended to be used in conjunction with one or another means of preventing the camera from approaching quite so near to a surface (such as the sphere-approach mentioned by others above).;Thaumaturge said:This may be obvious, but in case it helps:Let me note that, as a first-person camera may be more likely than a third-person camera to draw very close to geometry, I'm not sure that's so true. I mean in both cases you have to take care of the problem somehow. The case of a first-person camera is a bit easier because it should always be in the collision boundary of the player (sphere(s), ellipsoid, capsule etc.). As along as the near plane is also within that boundary, the problem should never occur. So if you have a 10cm radius sphere and put the camera in the back of it, that gives you maybe a 10 to 15 cm camera to near clipping plane distance to play with depending on the field of view you are going for. With a 3rd person camera, you can also get very close to terrain, in fact your camera can end up within terrain or some object if you don't do anything to solve that problem, and this will happen very often without separate camera collision. One typical way to handle this is just implement your following camera, ignoring terrain considerations. Then to figure out your camera's actual position, project a line back from the head of the avatar to the camera's ostensible position, and see if it intersects anything to get the camera's true position. In reality you should project a cylinder and not a line since your camera will need its own bounding sphere to contain the near clipping plane. In any case this means that as you move around your camera can jump forward to clear terrain and objects. I've seen this in a few MMOs. However, when you leave blocking terrain you have the option of implementing smooth movement back to the cameras desired location. If you want to get really fancy, I guess you could try to predict when your camera will need to jump forward ahead of time and try to do smooth moment forward too. Maybe you can have a second camera bounding sphere which is somewhat larger, that would trigger smooth movement, but I think you would still need a fallback camera jump routine to be safe. |
starting out, yet lot's of questions | For Beginners | So I wanted to learn (some) other languages. Apart from gamemaker, and I would really like some advice on these!First of all please let me explain what my "goals" are: I will create the basic/interface with gamemaker (I like the way events work, and collision detection is actually pretty good), and then use dlls to execute processor heavy tasks like AI..Now my gamemaker skills are actually pretty good, the sole reason I want to learn another language is because the code I create with gamemaker is too slow - not (only) because of bad management, but mostly because it simply is processor heavy.I also have some other experience with programming in JAVA - with visual cafe, a very limited visual environment. So I know how to declare variables etc.well my first question is: what kind of program should I use to create these kind of dlls? C++ based, JAVA (if it's possible and fast please tell, I really liked JAVA), or maybe another 1 (except for basic based languages). And which compiler should I get?I tried making something in Dev-C++ already but I really couldn't get even a simple "hello world" working (while following the help - it complained about a function (printf) not found). Then I installed wxDev-C++, a visual environment for it, I WAS able to get at least hello world working, however I couldn't find any good tutorials for that. So can anybody lighten me up here? - I tried looking at the c++ workshop, but that requires you too buy a book, and I think I don't really need a book for this: Once I understand the very basics (creating simple functions and displaying/outputting things), I think I can easily find out the rest. (I'm now at the funny position at which I know how to actually make A* pathfinding and influence maps etc. in gamemaker/pseudo code yet I have completely no idea on how to implement it in C++). Also 1 thing which I'm really missing is a complete list of all possible functions and how they're implemented, gamemaker had a nice pdf with it which I spent reading, and I just tested them all 1 by 1.Ow I guess you all think I'm a noob by saying this: but please, I really want to test out lot's of places so I don't really want to spent much (any) money on it. Also I don't even know if I will ever be able to understand C yet so it might all be a waste :P.thanks in advance,paul23 | Quote:I will create the basic/interface with gamemaker (I like the way events work, and collision detection is actually pretty good), and then use dlls to execute processor heavy tasks like AI..You expect the DLLs to interface with GameMaker? This requires the DLLs conform to whatever plug-in mechanism GameMaker requires. This probabably means C, or C++ using C to expose the DLL.Quote:well my first question is: what kind of program should I use to create these kind of dlls? C++ based, JAVA (if it's possible and fast please tell, I really liked JAVA), or maybe another 1 (except for basic based languages). And which compiler should I get?In the absence of your GameMaker interop requirement, I'd recommend C# or Python. For C#, get Visual C# Express, for Python, get the Python distribution from the Python homepage (python.org).Quote:I tried making something in Dev-C++ already but I really couldn't get even a simple "hello world" working (while following the help - it complained about a function (printf) not found). Then I installed wxDev-C++, a visual environment for it, I WAS able to get at least hello world working, however I couldn't find any good tutorials for that. So can anybody lighten me up here? - I tried looking at the c++ workshop, but that requires you too buy a book, and I think I don't really need a book for this: Once I understand the very basics (creating simple functions and displaying/outputting things), I think I can easily find out the rest. (I'm now at the funny position at which I know how to actually make A* pathfinding and influence maps etc. in gamemaker/pseudo code yet I have completely no idea on how to implement it in C++).You should use Visual C++ Express, and you should find the free online e-books Thinking in C++ and C++: A Dialog and read them.Quote:Ow I guess you all think I'm a noob by saying this: but please, I really want to test out lot's of places so I don't really want to spent much (any) money on it. Also I don't even know if I will ever be able to understand C yet so it might all be a waste :P.All of the above is free. However, it does sound like what you're trying to do (interop with GameMaker) is not a particularly great goal. It's practically going to force you to do things their way, which tends to be C (as I previously mentioned), and it sounds like your familiar with "pure" languages (again, those without associated construction tools) is limited to the extent that I would basically categorize you as the kind of beginner I would warn off C or C++ as strenuously as possible, because it's really a very poor beginners language.So that begs the question - is this GameMaker interop really that important to you? Because if you can abandon it, you should persue Python or C#. Otherwise, you're going to have to at least put it off for a while while you get up to speed with C or C++, which may take you some months. ; well I won't have to interact with the interface (well not directly, I'm skilled enough to write the interface interaction myself in gamemaker) - and for what I need in my current game I'm making the dll just have to return a coordination of points. (if you know gamemaker: I have created the scripts already, and it needs a few "reals" and it returns a "real", real=non integer 64bit number). So my first real "goal" is to translate those scripts to any other faster language..C# is only a 30 day free trial as far as I can see :S - and with my current amount of free time (on average 15-30 mins a day) I won't be able to learn it in that short period (I plan to actually create something once I leave the university: 5 years from now). - about python: never looked into it, will try it out, is it a compiled language (or fast)?ow and I really got to learn C,C++ at one point :PBut I won't really move on from gamemaker (at the moment at least - if I would move on I would go to JAVA anyway), sorry for not having a particular great goal there :P - It's just that I'm too used to it's interface, and I don't want to ditch my games yet, and the problem with all those other languages is: I really like to make AI's but I HATE to create interfaces etc, gamemaker does this automatically for you, but with other languages it's hard to do so. So are those visual languages (visual C# / python) capable of creating dlls?ow and what's the actual difference between C# and C++ (and C)?;Quote:well I won't have to interact with the interface (well not directly, I'm skilled enough to write the interface interaction myself in gamemaker) - and for what I need in my current game I'm making the dll just have to return a coordination of points. (if you know gamemaker: I have created the scripts already, and it needs a few "reals" and it returns a "real", real=non integer 64bit number). So my first real "goal" is to translate those scripts to any other faster language..See, this is problem #1. I don't think you're quite aware of what's going on here -- it's not as simple as just "returning a real" or just "translating scripts." If you're writing a DLL to extend the features or functionality of GameMaker or a program built with GameMaker, you must conform to the interface GameMaker expects -- assuming it is even built to expect such an interface. You can't just drop a DLL in a folder and tell it to work. Writing DLLs correctly in another programming language is not a beginners topic, either.Quote:C# is only a 30 day free trial as far as I can see :SYour experience with GameMaker (a construction tool that supports a proprietary language and compiler/interpreter) is skewing your perspective. C# is just a language; there are number of tools that allow you to compile C#. One of them is Visual C# Express, which is not a 30-day trial. Languages and the tools that allow you compile or use them are not the same thing.Quote:ow and I really got to learn C,C++ at one point :PWhy? There's no real compelling reason to, unless you plan on getting a job as a professional game developer in the immediate future. Which doesn't seem likely at this stage.Quote:But I won't really move on from gamemaker (at the moment at least - if I would move on I would go to JAVA anyway), sorry for not having a particular great goal there :P - It's just that I'm too used to it's interface, and I don't want to ditch my games yet, and the problem with all those other languages is: I really like to make AI's but I HATE to create interfaces etc, gamemaker does this automatically for you, but with other languages it's hard to do so.I think that what you want to do may simply not be possible. You want the ease of GameMaker, you need to stay in GameMaker.Quote:So are those visual languages (visual C# / python) capable of creating dlls?ow and what's the actual difference between C# and C++ (and C)?You can create DLLs with most other languages, yes. Not so much with Python. They are not "visual languages," you are confusing the tools and the language again. The difference between C# and C++ is like the difference between English and French. They are different languages, although they have some of the same letters in their names. ; i've got a slight feeling I'm working on your nerves by confusing the compiler and the tools (and posting this supposely noobish questions). Original post by jpetrieQuote:See, this is problem #1. I don't think you're quite aware of what's going on here -- it's not as simple as just "returning a real" or just "translating scripts." If you're writing a DLL to extend the features or functionality of GameMaker or a program built with GameMaker, you must conform to the interface GameMaker expects -- assuming it is even built to expect such an interface. You can't just drop a DLL in a folder and tell it to work. Writing DLLs correctly in another programming language is not a beginners topic, either.Well starting to become aware... But I must e able to learn that in 5 years >:). Well 1 last argument why dlls shouldn't be that easily:Quote:In those cases were the functionality of GML is not enough for your wishes, you can actually extend the possibilities by using plug-ins. A plug-in comes in the form of a DLL file (a Dynamic Link Library). In such a DLL file you can define functions. Such functions can be programmed in any programming language that supports the creation of DLL's (e.g. Delphi, C, C++, etc.) You will though need to have some programming skill to do this. Plug-in functions must have a specific format. They can have between 0 and 11 arguments, each of which can either be a real number (double in C) or a null-terminated string. (For more than 4 arguments, only real arguments are supported at the moment.) They must return either a real or a null-terminated string.What I understood about this thing is that the dll structure isn't that hard. Isn't it a black box which you give some things, it handles those things and then report a few things back? -- well I'll give up on this for the time being ;)Quote:Why? There's no real compelling reason to, unless you plan on getting a job as a professional game developer in the immediate future. Which doesn't seem likely at this stage.true, but the main problem is that I like to join in the discussion about AI/pathfinding - this was also the main reason I moved away from gm - and people sadly look down on you if you post examples in gml (game maker's scripting language). And to have good communication, everybody should always talk in the same languageQuote:I think that what you want to do may simply not be possible. You want the ease of GameMaker, you need to stay in GameMaker. Well in the end I want to give the dlls for others: I'm can't make sprites and sounds (and even my game design is bad) so the only thing I ever do is creating scripts which help others with game making :P - though creating libraries might be good too :P (I guess that's easier?)Quote:You can create DLLs with most other languages, yes. Not so much with Python. They are not "visual languages," you are confusing the tools and the language again.sorry, but even with visual cafe they were closely integrated.. Well maybe this is the biggest problem I'm facing noweverywhere I read something they always expect you to use 1 "tool" (guess you mean by tool the interface?)Quote:The difference between C# and C++ is like the difference between English and French. They are different languages, although they have some of the same letters in their names.well let's ask it in a (better) way: why should anybody use C++ over C#? (since C# is supposed to be easier to use?)sorry if I work on your nerves, just say whenever I'm assuming something really noobish :P. Ow and tanks a lot already, I appreciate it!; Hey paul23, I thought this name looked familiar :D. Anyway, I would recomend C#. I chose to start with it because of how the syntax reminded me of GML. Also, if you like Java you should like C#. I've always been told they were extremely similar. I recently downloaded the newest JDK and a good IDE and it is a lot like C#. C# and Java are probably your best bets as far as coming remotely close to Game Maker (though it's still a big leap as far as the difference). As far as DLL's go, I know that C# can create DLL's (not so sure about Java). Should you want to delve into the world of C++, i would recomend either Microsoft Visual C++ or Code:Blocks, as your compiler/IDE (just make sure you choose to download Code:Blocks with the compilers it comes with, should you download it at all). I'm afraid I can't give you too much info on the compattabillity of the DLL's with GM, but I don't see why it wouldn't work. You could always look into Delphi as well(considering that's what GM was written with). Hope that helps. If you'd like the links to some of the resources I gave you, just ask and I'll track them down and post them. Good luck with your language search.~TDOT> ;Quote:well let's ask it in a (better) way: why should anybody use C++ over C#? (since C# is supposed to be easier to use?)C++ is the industry standard, and C# is the new kid on the block. Most commercial games today are written in C++ (though C# is gaining popularity). Looking at your situation, I would also recommend C# or Python.It seems that you are hanging on to game maker because it eases the process of actually making a playable game, allowing you to focus more on the code while using game maker to do the "art" area. For the time being, this may satisfy your goals at making games, but eventually you probably will want to make a more advanced game without the restrictions from game maker; allowing you to be more creative with the games you make.In the long run, learning C#/Python or another language will be helpful; especially if you plan on pursuing a career in game programming.Quote:C# is only a 30 day free trial as far as I can see :S - and with my current amount of free time (on average 15-30 mins a day) I won't be able to learn it in that short period (I plan to actually create something once I leave the university: 5 years from now). - about python: never looked into it, will try it out, is it a compiled language (or fast)?You won't be able to do much at all with only a half-hour a day to work with. I suggest you re-prioritize your time :] |
Room with balls | Math and Physics;Programming | Sorry for the noobish question. I have a 2D Flash game that contains a room with balls that collide with the walls and among themselves. I've used a circle-circle CD algorithm from Gamasutra (http://www.gamasutra.com/features/20020118/vandenhuevel_01.htm) and a line-circle CD algorithm from a Flash tutorial (http://www.tonypa.pri.ee/vectors/tut07.html). I have problems when a ball collides with other balls at the room edges (simultaneous line-circle and circle-circle collisions). I think that happens because the circle-circle algorithm moves the balls to avoid penetration and afterwards the circle-line collision moves the ball again to avoid intersection with the line and, doing this, the balls may intersect again. Doing this, the collision response is run several times and the balls act weird. Some times, the balls cross the wall and exit the room, I guess this problem has the same cause. The basic question is: how do I handle several collisions at the same time step?Could someone help (possibly with a reference to a tutorial)? | |
PHP/MySQL MMORPG | For Beginners | Hi All!Just signed up! Thought I should introduce myself.I'm a full-time web developer and have always wanted to make an MMORPG.This is my 3rd attempt, and I think I'll be able to pull through this time. I've gotten farther than ever before!I've created the map engine, registration and character creation process, in game chat, and GUI from scratch so far.It's amazing how intense and complex the code can become, especially with browser-based games and security. I'm double checking and srubbing input like crazy.Anyway, just shoutin'-Spikku | Quote:Original post by spikkuI'm a full-time web developer and have always wanted to make an MMORPG.This makes about as much sense as "I'm a conductor and I've always wanted to write an opera".;Quote:Original post by ZahlmanQuote:Original post by spikkuI'm a full-time web developer and have always wanted to make an MMORPG.This makes about as much sense as "I'm a conductor and I've always wanted to write an opera".Yet he's written Prelude, Act I and designed the costumes. Which is more than most composers manage.; Welcome!Don't mind Zahlman. People here get cranky when somebody announces they are going to make an MMORPG. Usually only a total newb would even consider making an MMORPG.But in your case, I'll give you the benefit of the doubt since this is your third try, and you have acknowledged how complex the project has already become without getting very far into it. ;Quote:Original post by ZahlmanQuote:Original post by spikkuI'm a full-time web developer and have always wanted to make an MMORPG.This makes about as much sense as "I'm a conductor and I've always wanted to write an opera".There's actually a couple of MMORPGs written in PHP. KoL is bloody awesome, and you should definitely try it if you haven't. Another one that comes to mind is Urban Dead, which wasn't nearly as fun (though #gamedev was kind of into it a couple years ago). Then there's the hundreds of really really shitty web "MMORPGs" which are basically just "Log into the site once a day, click some buttons, and be done".To the OP - there's really no point to this thread. Next time post in "Your Announcements" if you just want to shout out [razz] |
Looking to upgrade, would like advice. | Hardware Discussion;Technical | I'm looking to upgrade or replace my current rig:Athlon64 3800Asus A8v1gbX1600 proWith something that is top end. Price isn't an issue because im still weighing up how much i would like to spend, however i do have an idea of the kind of machine i want. My current rig i spent £800 about 3/4 years ago on the top 3 components there, they have lasted me well with only the GPU needing upgrading. I would like to do a similar thing, with the target machine being a good gaming rig but not one that is going to be OTT. For example no SLI and no components that are vastly more expensive due to being brand new.So i have been looking at one of these bundles...hereNow i can't see the point in going for the top priced bundle, its only slightly faster but for a hell of alot more money. I'm thinking the second bundle looks alright.Do you have any views on that bundle? Yes, no, maybe so?Secondly i don't know which version of the nVidia 8800 i want to go for. Is there anything coming out soon that will drop the price of the 8800 series? Is the 768mb version really worth the ridiculous £370 price tag?What would you go for if you didnt want to spend a fortune but wanted a nice spec?Cheers,Dave | If you're going the 8800 route, I'd suggest getting the 8800 GTS with 320 MB of RAM if you play at anything lower than 1600x1200, and the 640 MB version if you plan on playing above. The Ultra isn't worth it as you can overclock an 8800 GTX to those speeds, but price to performance, the GTS is the better value. The 640 GTS will save you roughly £100 over the GTX, and the 320 will save you ~£50 over the 640 MB version. The only difference is really how much caching will happen with the RAM difference with the GTS (there is a difference in the amount of shaders, and some speed when comparing the GTS to the GTX, but you can overclock the GTS to make up for the speed difference, not the shader count though). In November, NVidia's releasing it's next video card which should provide 2-3x the speed of the GTX, provided you have PCI Express 2.0 (but you'll have to wait until October to get boards that support it). So, in the end, I'd suggest the 320 MB 8800 GTS for £169.99. Provided you're not playing above 1600x1200, you'll only notice a 15-20% drop in your fps. Trust me, 15% isn't that big of a deal if you're talking 100 fps, and you'll barely notice it if your game was playing at 40 fps.I'd suggest similar for the processor. 6600 Dual core is good enough for most people. If you want the 1333 FSB, step up to maybe a 6850, but I'd keep it at that. If you want quad core, 6600 quad is good enough.Saving £1000+ for 30% slower machine and upgrade in the future. ; Hmm, i understand what you are saying.I have been told that overclockers.co.uk were overpriced but having scouted around for a total price for the individual parts in their bundle i only saved £7. Since i dont need the fan but i do want a 8800 i might negotiate a new bundle deal with them over the phone.Has anyone got anythoughts on the bundle i should get and/or negotiating prices? ;Quote:In November, NVidia's releasing it's next video card which should provide 2-3x the speed of the GTX, provided you have PCI Express 2.0<offtopic (sorry)>Where'd you see that? I consider myself quite hip with the new hardware stuff, but I haven't seen anything like that...</offtopic> |
converting 3x3 matrix to 3 axis and angle? | Math and Physics;Programming | Iv looked around on google, and im starting to wonder if its possible..Is it possible to convert a 3 by 3 matrix to and from an axis and angle representation? For example if my matrix was representing the y axis rotated pi/4 radians, the angle axis repesentation would be:axis(0,1,0)angle(pi/4)I know it can be done with a single axis easily (and i already have functions to do that), but how can it be done using 3 axis?I dont know much about quaternions, but is this angle axis representation the same as a quaternion? if it is then ill just look that up instead | You're probably using the wrong search terms.I typed "matrix to axis angle" into google and got thisA quaternion is not the same as the axis-angle representation. Unit-quaternion rotation is quite complicated to explain (to do with 4-dimension spheres), quaternions are useful because its cheaper to perform certain operations with them, such as interpolation than it is with a matrix for example. ;Quote:I know it can be done with a single axis easily (and i already have functions to do that), but how can it be done using 3 axis?Just to help clarify things a bit, what do you mean by 'converting a matrix to 3 axis and angle'?Can you give an example? ; May I ask why you want to do this in the first place?There is really no way to do this in a general sense with any reliability. Rotations are encoded in the matrix and are almost impossible to retrieve. If you want this data in order to do something like glRotate3f(...), then you need to buff up your knowledge of whatever graphics API you are using.If you have a 3x3 rotation matrix, you can easily rotate the model view matrix of your scene by that matrix using the function glMatrixMult(float*), where the parameter is a 16 entry array of values representing a 4x4 transformation matrix given by the following format:[ R.x.x R.y.x R.z.x 0 ][ R.x.y R.y.y R.z.y 0 ][ R.x.z R.y.z R.z.z 0 ][ 0001 ]where R is the rotation matrix, R.x, R.y, R.z are column vectors of that matrix. ;Quote:Original post by jykQuote:I know it can be done with a single axis easily (and i already have functions to do that), but how can it be done using 3 axis?Just to help clarify things a bit, what do you mean by 'converting a matrix to 3 axis and angle'?I think he might mean 3-axis as in 3D axis, but I'm not sure. ; yes, i mean 3-axis / angleIm not really sure of the correct terminology for this but 3-axis / angle is basically what i needdmatter, thanks for the link, that basically tells me just what i neededThanks ; Once again, may I ask why you need this information?I highly recommend avoiding any sort of euler/axis angle representations of rotations. It will only result in unreliable code that doesn't always work. It will be subject to problems like gimbal lock, and plus it is a lot slower than just accepting the matrix as a total representation of any rotation.The rotation matrix is a highly useful construct and should be taken advantage of whenever possible. Quaternions are also a valid solution with a few specific advantages, but they are hard to visualize and understand and require slightly more calculations, because in order to rotate a point through a quaternion, one must first convert it to a 3x3 rotation matrix. This is why I just use 3x3 rotation matrices instead.The key point is that any sort of axis angle representation of rotations has degenerate cases which will either break your code or will have to be detected and handled individually. Ironically, once you get an axis angle representation, it will more than likely be converted back into rotation matrix form in whatever application you need it for. This is because rotation matrices are extrememly useful and easily and quickly handle rotations. ; Do you mean this (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rotate.html)? ( xx(1-c)+cxy(1-c)-zs xz(1-c)+ys 0 ) | | | yx(1-c)+zsyy(1-c)+c yz(1-c)-xs 0 | | xz(1-c)-ysyz(1-c)+xs zz(1-c)+c 0 | | | ( 00 0 1 ) Wherec = cos(angle),s = sine(angle), and ||( x,y,z )|| = 1The x, y, and z are the axis.EDIT: Though that is from x/y/z/angle to matrix, not sure if you want the other way around. ; There is no specific reason why i wanted 3-axis and angle representation; I was working on my math library and I thought it would just feel more complete if I had this representation avaliable. I totaly agree that matricies are a better way to store rotations, and thats how I do store rotations already.Its just another thing that might make certain things easier, for example when setting the rotation of a rigid body. If i wanted my rigid body rotated 45 degrees on x and y, its easier to pass an axis and and angle to the constructor than it is to pass a matrix. Actually, I plan on making a constructor in the matrix class that takes axis angle as parametersAlso i think that axis angle thing on the opengl page is basically what im after (though thats not how i plan to pass rotations to opengl) ;Quote:Original post by GumgoDo you mean this (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rotate.html)? ( xx(1-c)+cxy(1-c)-zs xz(1-c)+ys 0 ) | | | yx(1-c)+zsyy(1-c)+c yz(1-c)-xs 0 | | xz(1-c)-ysyz(1-c)+xs zz(1-c)+c 0 | | | ( 00 0 1 ) Wherec = cos(angle),s = sine(angle), and ||( x,y,z )|| = 1The x, y, and z are the axis.EDIT: Though that is from x/y/z/angle to matrix, not sure if you want the other way around.Yes, that's an 'axis-angle' rotation matrix.I think your use of the term '3-axis' may still be causing some confusion. If you indeed mean a '3d axis', you can drop the '3' and just use the term 'axis'. This will be less confusing, as the term 'axis-angle' is common and will be better understood.Aressera might have been talking about something else, but just to be clear, the axis-angle representation doesn't suffer from any degeneracies or singularities to speak of. However, as noted, it isn't the easiest representation to work with. |
double **d dynamic allocation c++ | For Beginners | Hello,Im feeling a little bit stupid.How do you allocate a 2d array of size mxn in c++? The only way I can do it is by using malloc calls. But your not supposed to use malloc calls in c++...How do you do it using new double() ??? | In C++ std tools are preferred to dynamic memory allocation.For a true 2D array one generally uses Boost::MultiArrayIf you don't want to use boost then you could consider usingstd::vector<std::vector<double> >This is actually a ragged array not a 2D array - but that's what you've asked to create anyway so it might work in your case.If you have a good reason to acually do manual dynamic memory allocation then stop and make sure you really have a good reason to do manual dynamic memory allocation. If after that you're still sure then you can do one of the following:For a ragged arraydouble ** array = new double*[XSize];for (int i=0; i<XSize; i++){ array = new double[YSize];}and then deletefor (int i=0; i<XSize; i++){ delete[] array;}delete[] array;For a 1D array accessed as a 2D arraydouble * array = new double[XSize*YSize];you can access like so:array[x][y] = array[XSize*y+x];delete:delete[] array;I think all that's right - and if it isn't then it just proves my initial argument - dynamic memory allocation is prone to error and annoying - just use the std containers and boost. ; Ok so say I used a vector...Wat is the size of the vector intialised to?Can I just randomly index it where ever I want?; http://www.cplusplus.com/reference/stl/vector/http://www.cplusplus.com/reference/stl/vector/reserve.html |
Ranking system problem | General and Gameplay Programming;Programming | I'm sure this something tackled by thousands before me, but I'm looking for a ranking system. I can find plenty of player vs. player ranking systems on the net, but this is pure win/loss based on picks. So, I'd like to rank based on win/loss record, number of games participated in, and maybe factor in total number of games possible. So, 5-0 would not beat 30-10. A person that has picked that many winners should rank higher than someone who has gotten lucky and picked 5 winners. Anyone have a good algorithm or points system for a win/loss ranking such as this? | Have you considered simply stealing the one that is used for chess? [EDIT] Decided to save you the trouble of looking it up. Only thing is it's only appropriate for 1v1 type games. You might be able to adapt it or take the basic ideas though. ; Yeah, I've looked at several chess systems, and football ranking systems. Problem is, a main factor is the strength of the opponent. In my game, no one plays anyone else. They simply pick winners, and get a win if their pick wins. ; The simplest likely-to-work-reasonably-well solution I can think of (justifying it involves, of course, a lot of statistical handwaving) is to simply subtract a factor proportional to the square root of total games:Score = (wins / (wins + losses)) - K(sqrt(wins + losses)) ; This is a reply I got on another board:Quote:I think we are thinking about this wrong. Some how we need to give a win/loss some sort of weighting as i had based on total number of games playedLike if you have played 50 games a win is worth 1 and a loss is worth .5 but if u have 100 games then a win is worth .85 and a loss is .45 or some sort. then we figure out that sum. An equation for that is like$factor_w = 100;$factor_l = 85;$games = 50;$wins = 25;$losses = 25;$total = ($wins/($factor_w/$games))-($losses/($factor_l/$games));So this generates a value that will be put in to $a*exp($k*$total); Where $k is to keep the values realistic and $a is to create more significance to the outputted value. However this results in an issue because $total could be <0 which means if you have more losses than wins you are going to be really low down. Somehow it has to be exponential, but somehow it has to take into account games and wins vs loss ratio. we could just use that outputted $wins/$games which si your wining percentage. then take exp($wins/$games) which takes into account losses. You seem to be worried about combining all three leagues together, but that isn't nessecary until after you get the inital values create. Then its easy. but the problem at hand is creating an equation where 25-0 is equal to 75-4 but less than 101-7 for example. |
I ruined SDL? | For Beginners | I wanted to quickly finish this sliding puzzle game. So instead of going with OpenGL I decided to try SDL. However, here is the problem. I am getting like 2 FPS if I blit 16 squares!!!! I get 30 FPS if I blit 4 squares. I looked over the code, it looks just way too simple and yet it works not.Can someone please look over this and tell me where I did it wrong?I am 100% that the error will be obvious to anyone who is a little better than me.Here is the pastebin link to the code (I think it is easier to read it that way) http://pastebin.com/d6568a09eHere is the direct code:#include <SDL/SDL.h>#include <cstdio>#include <cstdlib>#include <ctime>#include <SDL/SDL_gfxPrimitives.h>// SDL_gfx Primitives#include <SDL/SDL_framerate.h>// SDL_gfx Framerate Manager#include <SDL/SDL_ttf.h>#include <windows.h>const int SQUARE=8; // Number of squares to cut the picture inconst int RESOL=512; // Resolution of screen to useint main(int argc, char *argv[]){int frames=0; int fps=0; unsigned long tim=0;// Initialize SDLif(SDL_Init(SDL_INIT_VIDEO) == -1){fprintf(stderr, "Failed to initialize SDL: %s\n", SDL_GetError());exit(1);}atexit(SDL_Quit);// Initilize the screenSDL_Surface *screen = SDL_SetVideoMode(RESOL, RESOL, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);if(screen == NULL){fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError());exit(1);}// Load the imageSDL_Surface* image = SDL_LoadBMP("sampleM.bmp"); // a 512x512 pictureSDL_Surface* square[SQUARE*SQUARE]; // array to keep the square x square imageSDL_Rect rectS; // SOURCErectS.w=RESOL/SQUARE;rectS.h=RESOL/SQUARE;SDL_Rect rectD; // DESTINATIONrectD.x=0;rectD.y=0;for(int y=0;y < SQUARE; y++) // Cut the 512x512 picture into SquarexSquare images. for(int x=0;x<SQUARE; x++) { square[x+y*SQUARE]=SDL_CreateRGBSurface(SDL_HWSURFACE, RESOL/SQUARE,RESOL/SQUARE, 32,0,0,0,0); rectS.x= x*rectS.w; rectS.y= y*rectS.h; SDL_BlitSurface(image,&rectS,square[x+y*SQUARE],&rectD); square[x+y*SQUARE]=SDL_DisplayFormat(square[x+y*SQUARE]); } if(image == NULL)fprintf(stderr, "Unable to load image: %s\n", SDL_GetError());// FRAME RATE MANAGER EXAMPLE// Initialize Frame Rate ManagerFPSmanager fpsm;SDL_initFramerate(&fpsm);SDL_setFramerate(&fpsm, 60); // 60 Frames Per Second TTF_Init(); atexit(TTF_Quit);TTF_Font *fntArial12 = TTF_OpenFont( "arial.ttf", 12 );bool isRunning = true; while(isRunning){// Clear the screen//SDL_FillRect(screen, NULL, 0);// Draw the rotated imagefor(int y=0;y < SQUARE; y++) for(int x=0;x<SQUARE; x++) { rectS.x= x*rectS.w; rectS.y= y*rectS.h; SDL_BlitSurface(image,NULL,screen,&rectD); }// GRAPHICS PRIMATIVES EXAMPLEfilledCircleRGBA(screen, 200, 200, 50, 255, 0, 0, 150);SDL_Color clrBlack = { 0,122,0, 0 };char *buffer=(char*)malloc(128*sizeof(char));buffer=itoa(fps,buffer,10);SDL_Surface *sText = TTF_RenderText_Solid( fntArial12, buffer, clrBlack );// Step 3: Blit that to the screen:SDL_Rect rcDest = { 20,50, 0,0 };// (or use newSDL_Rect( 20,50, 0,0 );)SDL_BlitSurface(sText,NULL, screen,&rcDest ); frames++; // Output to the screenSDL_Flip(screen);//Sleep(10);// FRAME RATE MANAGER EXAMPLE// Delay using the frame rate manager//SDL_framerateDelay(&fpsm);// Check if user quitsSDL_Event event;while(SDL_PollEvent(&event)){switch(event.type){case SDL_QUIT:isRunning = false;break;case SDL_KEYDOWN:if(event.key.keysym.sym == SDLK_ESCAPE)isRunning = false;break;}}float elapsed = abs(clock()-tim)/CLOCKS_PER_SEC;if (elapsed > 1.0) {fps=frames/(int)(elapsed+.5); frames=0; tim=clock();}}// Clean up the loaded imagereturn 0;} | I don't mean to be rude, so if I come across that way then I am sorry.Did gamedev do this, or what. As your code is very hard to understand due to poor formatting. I've never seen gamedev screw up a format that bad. Yea...I lost track where I was, so I couldn't even try to see what was causing the problem.Also, may I ask why EVERYTHING is in main?Again, sorry if I came across rude. If I did then I will edit my post.;Quote:Original post by Chad SmithAlso, may I ask why EVERYTHING is in main?Looks like me, before I understood the benefits of OOP.Sorry I'm not able to read your code because I've never done anything in C++, but I can tell you, your code is a lot more readable if you put things into classes and methods.Hope someone can debug your project, might want to try some SDL specific sites.; It could be to do with how your using malloc in the middle of your game loop, then fill it up:char *buffer=(char*)malloc(128*sizeof(char));buffer=itoa(fps,buffer,10);If you move the char* allocation outside the main loop, but keep the second line inside, you should save some time.[edit: I found another example of this:SDL_Surface *sText =TTF_RenderText_Solid( fntArial12, buffer, clrBlack );try putting the declaration outside of the game loop./ edit ]Also:screen = SDL_SetVideoMode(RESOL, RESOL, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);There is no 32 bit color mode as far as graphics cards are concerned. they only work with rgb. The fourth 8 bytes in a 32 bit color image is used to calculate transparency. Try 24. IF you use 0, SDL will decide for itself. ;Quote:Original post by Chad SmithI don't mean to be rude, so if I come across that way then I am sorry.Did gamedev do this, or what. As your code is very hard to understand due to poor formatting. I've never seen gamedev screw up a format that bad. Yea...I lost track where I was, so I couldn't even try to see what was causing the problem.Also, may I ask why EVERYTHING is in main?Again, sorry if I came across rude. If I did then I will edit my post.It would have been more readable, despite everything being in main, if the formatting had been correct. Try using either a single tab (my favorite, controversial i know) or a fixed number of spaces, to indent code blocks. ;Quote:Original post by shotgunnutterIt could be to do with how your using malloc in the middle of your game loop, then fill it up:char *buffer=(char*)malloc(128*sizeof(char));buffer=itoa(fps,buffer,10);If you move the char* allocation outside the main loop, but keep the second line inside, you should save some time.Also:screen = SDL_SetVideoMode(RESOL, RESOL, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);There is no 32 bit color mode as far as graphics cards are concerned. they only work with rgb. The fourth 8 bytes in a 32 bit color image is used to calculate transparency. Try 24. IF you use 0, SDL will decide for itself.Thanks! The 32 slowed it down 6x times! It still only works at 13 FPS :/Next time I will have to format it nicer and move everything to methods. Thank you everyone for pointing that out. ; Some general remarks regarding performance in SDL:- make sure your surfaces are in the same format as the display surface, see SDL_DisplayFormat for that.- avoid using surfaces with an alpha channel set and a hardware display surface (when using alpha channel's, just make a software display surface)- the topic of performance in SDL comes up often, search gamedev.net for some more tips. Now regarding your code, I have just skimmed over it but it looks like you're doing more than blitting 16 sprites. Doesn't this result in 64 blits?for(int y=0;y < SQUARE; y++) for(int x=0;x<SQUARE; x++) /*blit*/ You haven't posted the circle drawing code, you could try checking what that does. Also, make sure the code that checks the frame rate is good too, not implying it isn't but that's the kind of thing that I always check first since a mistake there renders everything else useless. ;Quote:Original post by ShadowPhoenixQuote:Original post by shotgunnutterIt could be to do with how your using malloc in the middle of your game loop, then fill it up:char *buffer=(char*)malloc(128*sizeof(char));buffer=itoa(fps,buffer,10);If you move the char* allocation outside the main loop, but keep the second line inside, you should save some time.Also:screen = SDL_SetVideoMode(RESOL, RESOL, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);There is no 32 bit color mode as far as graphics cards are concerned. they only work with rgb. The fourth 8 bytes in a 32 bit color image is used to calculate transparency. Try 24. IF you use 0, SDL will decide for itself.Thanks! The 32 slowed it down 6x times! It still only works at 13 FPS :/Next time I will have to format it nicer and move everything to methods. Thank you everyone for pointing that out.13? Did we make progress then?OK. I have a few suggestions for how to structure such a program in future. I would make it look something like this:INITIALIZE_SUBSYSTEMS//this section includes SDL_init, TTF_init, etc. Libraries are initialized at this stage. Bare minimum use of variables.ALLOCATE POINTERS//anything which is a pointer to something is allocated here. This includes any pointer which is allocated by a function; set it to NULL here just to be safe, SDL_Surface*'s included.INITIALIZE VARS//anything which is set to a starting value is initialize here. This is where you call functions such as SDL_SetVideoMode(RESOL, RESOL, 24, SDL_HWSURFACE|SDL_DOUBLEBUF); You would also put your loop which you say is to "// Cut the 512x512 picture into SquarexSquare images."START GAME LOOP HANDLE_EVENTS UPDATE OBJECTS DRAW GET FRAMERATEEND GAME LOOPDELETE POINTERS.SDL_Quit();;Quote:Original post by shotgunnutterQuote:Original post by ShadowPhoenixQuote:Original post by shotgunnutterIt could be to do with how your using malloc in the middle of your game loop, then fill it up:char *buffer=(char*)malloc(128*sizeof(char));buffer=itoa(fps,buffer,10);If you move the char* allocation outside the main loop, but keep the second line inside, you should save some time.Also:screen = SDL_SetVideoMode(RESOL, RESOL, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);There is no 32 bit color mode as far as graphics cards are concerned. they only work with rgb. The fourth 8 bytes in a 32 bit color image is used to calculate transparency. Try 24. IF you use 0, SDL will decide for itself.Thanks! The 32 slowed it down 6x times! It still only works at 13 FPS :/Next time I will have to format it nicer and move everything to methods. Thank you everyone for pointing that out.13? Did we make progress then?OK. I have a few suggestions for how to structure such a program in future. I would make it look something like this:*** Source Snippet Removed ***Thanks! I will certainly try that for future!As for progress... I just can't think of a reason why 64 blits result in 13 FPS. In OpenGL I could get millions!Quote:Some general remarks regarding performance in SDL:- make sure your surfaces are in the same format as the display surface, see SDL_DisplayFormat for that.- avoid using surfaces with an alpha channel set and a hardware display surface (when using alpha channel's, just make a software display surface)- the topic of performance in SDL comes up often, search gamedev.net for some more tips.Now regarding your code, I have just skimmed over it but it looks like you're doing more than blitting 16 sprites.Doesn't this result in 64 blits?for(int y=0;y < SQUARE; y++)for(int x=0;x<SQUARE; x++)/*blit*/You haven't posted the circle drawing code, you could try checking what that does. Also, make sure the code that checks the frame rate is good too, not implying it isn't but that's the kind of thing that I always check first since a mistake there renders everything else useless.FPS counter: checked, works flawlessly, accurate to within ~2FPS. I tried setting the surfaces to software, it doesn't help. I do have the DisplayFormat there already :/. ; Thank you everyone for support! I got it! :DWhen blitting I did SDL_BlitSurface(image,NULL,screen,&rectD; instead of SDL_BlitSurface(square[x+y*8],NULL,screen,&rectD;!This way I had the whole screen copy over itself 64 times instead of little squares! |
Lists | General and Gameplay Programming;Programming | I am doing a setup of my game engine and need some help.I am storing all of my mesh data in an object and need a list of them. Each model has a name string and a pointer to the respective data. I was thinking of using a set or map template (I don't remember how they work but I know they had searching by keywords) or none and have the developer keep track of his own models.Which do you think would be more efficient? More friendly? Easier to manage? | Quote:Original post by ShlaklavaI am doing a setup of my game engine and need some help.I am storing all of my mesh data in an object and need a list of them. Each model has a name string and a pointer to the respective data. I was thinking of using a set or map template (I don't remember how they work but I know they had searching by keywords) or none and have the developer keep track of his own models.Which do you think would be more efficient? More friendly? Easier to manage?The map. (Sets are for when you don't need to look things up, just keep them unique according to a "key" that's already embedded in the object". Pull out the name, and just make the "model" be a *wrapped* pointer (typically an already existing smart pointer, such as boost::shared_ptr) to the mesh data.Also, be aware that "list" typically implies a *linked* list; the more general term is "container" (for all of these things) or "sequence" (for those which are ordered, rather than being sorted or providing a key-lookup). ; If performance is an issue, consider handles.Rather than mapping from name to pointer, resolve the name to handle, then use the handle to look up the pointer.Looking up by string requires comparison between strings, which will result in quite inefficient iteration. If your handles are integers, they'll result in an int comparison.This is only relevant if you do lookups frequently. If you do it once only, there's no benefit. ; Zahlman's right, use a map:typedef boost::shared_ptr<Model> ModelPointer;typedef std::map< std::string, ModelPointer > ModelMap;ModelMap models;ModelPointer myModel( new Model() );models["DougThePlumber"] = myModel;// Later on...ModelPointer doug = models["DougThePlumber"];Ofcourse you don't have to use a string, you could use integer handles instead, inwhich case a vector would be more adequate than a map. ;Quote:Original post by ZahlmanThe map. (Sets are for when you don't need to look things up, just keep them unique according to a "key" that's already embedded in the object". Pull out the name, and just make the "model" be a *wrapped* pointer (typically an already existing smart pointer, such as boost::shared_ptr) to the mesh data.That sounds nice. Thank you for the quick reply.Quote:Original post by ZahlmanAlso, be aware that "list" typically implies a *linked* list; the more general term is "container" (for all of these things) or "sequence" (for those which are ordered, rather than being sorted or providing a key-lookup).That is pretty good to know, never knew that distinction so I just stated them all as lists, I'll make sure to make the proper distinctions next time. |
Problem compiling last version 2.10.0 Rev 196 | AngelCode;Affiliates | Hi!I've downloaded the last revision 196 from the SVN using TortoiseSVN, and the compiler says that as_gcobject.cpp and as_gcobject.h don't exist. Thanks! :) | Did you read the change list? ;)These files have been removed from the library as they are no longer used. ; Oops. sorry! ;) My fault... I've removed those files from the VC8 project and it works... thanks! :) |
looking for driver for linux | GDNet Lounge;Community | Looking for drivers for:BP PLL E186014PN: 1242-0000115-020i got a decompiled one here:static const char *version ="fealnx.c:v2.20 9/1/00\n";static const char *version1 =" http://cesdis.gsfc.nasa.gov/linux/drivers/ethercard.html\n";static int debug=0;/* 1-> print debug message */static int max_interrupt_work = 20;static int min_pci_latency = 32;/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). */static int multicast_filter_limit = 32;/* Set the copy breakpoint for the copy-only-tiny-frames scheme. *//* Setting to > 1518 effectively disables this feature.*/static int rx_copybreak = 0;/* Used to pass the media type, etc. *//* Both 'options[]' and 'full_duplex[]' should exist for driver *//* interoperability. *//* The media type is usually passed in 'options[]'. */#define MAX_UNITS 8/* More are supported, limit only on options */static int options[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};/* Operational parameters that are set at compile time. *//* Keep the ring sizes a power of two for compile efficiency. *//* The compiler will convert <unsigned>'%'<2^N> into a bit mask. *//* Making the Tx ring too large decreases the effectiveness of channel *//* bonding and packet priority. *//* There are no ill effects from too-large receive rings.*/// 88-12-9 modify,// #define TX_RING_SIZE 16// #define RX_RING_SIZE 32#define TX_RING_SIZE 6#define RX_RING_SIZE 12/* Operational parameters that usually are not changed. *//* Time in jiffies before concluding the transmitter is hung. */#define TX_TIMEOUT (2*HZ)#define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer.*//* Include files, designed to support most kernel versions 2.0.0 and later. */#include <linux/config.h>#include <linux/version.h>#ifdef MODULE#ifdef MODVERSIONS#include <linux/modversions.h>#endif#include <linux/module.h>#else#define MOD_INC_USE_COUNT#define MOD_DEC_USE_COUNT#endif#include <linux/kernel.h>#include <linux/sched.h>#include <linux/string.h>#include <linux/timer.h>#include <linux/errno.h>#include <linux/ioport.h>#include <linux/malloc.h>#include <linux/interrupt.h>#include <linux/pci.h>#include <linux/netdevice.h>#include <linux/etherdevice.h>#include <linux/skbuff.h>#include <asm/processor.h> /* Processor type for cache alignment. */#include <asm/bitops.h>#include <asm/io.h>/* This driver was written to use PCI memory space, however some x86 systems work only with I/O space accesses. */#ifndef __alpha__#define USE_IO#endif#ifdef USE_IO#undef readb#undef readw#undef readl#undef writeb#undef writew#undef writel#define readb inb#define readw inw#define readl inl#define writeb outb#define writew outw#define writel outl#endif/* Kernel compatibility defines, some common to David Hinds' PCMCIA package. *//* This is only in the support-all-kernels source code. */#define RUN_AT(x) (jiffies + (x))#if (LINUX_VERSION_CODE >= 0x20100)char kernel_version[] = UTS_RELEASE;#else#ifndef __alpha__#define ioremap vremap#define iounmap vfree#endif#endif#if defined(MODULE) && LINUX_VERSION_CODE > 0x20115MODULE_AUTHOR("Jao Ching Chen");MODULE_DESCRIPTION("100/10M Ethernet PCI Driver");MODULE_PARM(max_interrupt_work, "i");MODULE_PARM(min_pci_latency, "i");MODULE_PARM(debug, "i");MODULE_PARM(rx_copybreak, "i");MODULE_PARM(multicast_filter_limit, "i");MODULE_PARM(options, "1-" __MODULE_STRING(MAX_UNITS) "i");MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");#endif#if LINUX_VERSION_CODE < 0x20123#define test_and_set_bit(val, addr) set_bit(val, addr)#endif#if LINUX_VERSION_CODE <= 0x20139#define net_device_stats enet_statistics#else#define NETSTATS_VER2#endif#if LINUX_VERSION_CODE < 0x20155 || defined(CARDBUS)/* Grrrr, the PCI code changed, but did not consider CardBus... */#include <linux/bios32.h>#define PCI_SUPPORT_VER1#else#define PCI_SUPPORT_VER2#endif#if LINUX_VERSION_CODE < 0x20159#define dev_free_skb(skb) dev_kfree_skb(skb, FREE_WRITE);#else#define dev_free_skb(skb) dev_kfree_skb(skb);#endif/* PCI probe table. */static struct device *fealnx_probe1(int pci_bus, int devfn, struct device *dev, long ioaddr, int irq, int chp_idx, int fnd_cnt);#ifdef USE_IO#define fealnx_FLAGS (PCI_USES_IO | PCI_ADDR0 | PCI_USES_MASTER)#else#define fealnx_FLAGS (PCI_USES_MEM | PCI_ADDR1 | PCI_USES_MASTER)#endifenum pci_flags_bit { PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4, PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3,};struct pci_id_info { const char *name; u16 vendor_id, device_id, device_id_mask, flags; int io_size; struct device *(*probe1)(int pci_bus, int pci_devfn, struct device *dev, long ioaddr, int irq, int chip_idx, int fnd_cnt);};static struct pci_id_info pci_tbl[] = { {"MTD800", 0x1516, 0x0800, 0xffff, /* NIC only */ fealnx_FLAGS, 136, fealnx_probe1}, {"MTD803", 0x1516, 0x0803, 0xffff, /* 3-in-1 */ fealnx_FLAGS, 136, fealnx_probe1}, {"MTD891", 0x1516, 0x0891, 0xffff, /* G-bit */ fealnx_FLAGS, 136, fealnx_probe1}, {0,}, /* 0 terminated list. */};/* A chip capabilities table, matching the entries in pci_tbl[] above. */enum chip_capability_flags { HAS_MII_XCVR, HAS_CHIP_XCVR,};/* 89/6/13 add, *//* for different PHY */enum phy_type_flags { PHY=1, AhdocPHY=2, SeeqPHY=3, MarvellPHY=4, MTD981=5, OtherPHY=10,};struct chip_info { char *chip_name; int io_size; int flags; void (*media_timer)(unsigned long data);};static struct chip_info skel_netdrv_tbl[] = { {"100/10M Ethernet PCI Adapter", 136, HAS_MII_XCVR, }, {"100/10M Ethernet PCI Adapter", 136, HAS_CHIP_XCVR, }, {"1000/100/10M Ethernet PCI Adapter", 136, HAS_MII_XCVR, },};/* Offsets to the Command and Status Registers. */enum fealnx_offsets { PAR0=0x0,/* physical address 0-3 */ PAR1=0x04, /* physical address 4-5 */ MAR0=0x08, /* multicast address 0-3 */ MAR1=0x0C, /* multicast address 4-7 */ FAR0=0x10, /* flow-control address 0-3 */ FAR1=0x14, /* flow-control address 4-5 */ TCRRCR=0x18, /* receive & transmit configuration */ BCR=0x1C,/* bus command */ TXPDR=0x20, /* transmit polling demand */ RXPDR=0x24, /* receive polling demand */ RXCWP=0x28, /* receive current word pointer */ TXLBA=0x2C, /* transmit list base address */ RXLBA=0x30, /* receive list base address */ ISR=0x34,/* interrupt status */ IMR=0x38,/* interrupt mask */ FTH=0x3C,/* flow control high/low threshold */ MANAGEMENT=0x40, /* bootrom/eeprom and mii management */ TALLY=0x44, /* tally counters for crc and mpa */ TSR=0x48,/* tally counter for transmit status */ BMCRSR=0x4c, /* basic mode control and status */ PHYIDENTIFIER=0x50,/* phy identifier */ ANARANLPAR=0x54, /* auto-negotiation advertisement and linkpartner ability */ ANEROCR=0x58, /* auto-negotiation expansion and pci conf. */ BPREMRPSR=0x5c, /* bypass & receive error mask and phy status */};/* Bits in the interrupt status/enable registers. *//* The bits in the Intr Status/Enable registers, mostly interrupt sources. */enum intr_status_bits { RFCON=0x00020000, /* receive flow control xon packet */ RFCOFF=0x00010000, /* receive flow control xoff packet */ LSCStatus=0x00008000, /* link status change */ ANCStatus=0x00004000, /* autonegotiation completed */ FBE=0x00002000, /* fatal bus error */ FBEMask=0x00001800,/* mask bit12-11 */ ParityErr=0x00000000, /* parity error */ TargetErr=0x00001000, /* target abort */ MasterErr=0x00000800, /* master error */ TUNF=0x00000400, /* transmit underflow */ ROVF=0x00000200, /* receive overflow */ ETI=0x00000100, /* transmit early int */ ERI=0x00000080, /* receive early int */ CNTOVF=0x00000040, /* counter overflow */ RBU=0x00000020, /* receive buffer unavailable */ TBU=0x00000010, /* transmit buffer unavilable */ TI=0x00000008,/* transmit interrupt */ RI=0x00000004,/* receive interrupt */ RxErr=0x00000002, /* receive error */};/* Bits in the NetworkConfig register. */enum rx_mode_bits { RxModeMask=0xe0, PROM=0x80, /* promiscuous mode */ AB=0x40, /* accept broadcast */ AM=0x20, /* accept mutlicast */ ARP=0x08, /* receive runt pkt */ ALP=0x04, /* receive long pkt */ SEP=0x02, /* receive error pkt */};/* The Tulip Rx and Tx buffer descriptors. */struct fealnx_desc { s32 status; s32 control; u32 buffer; u32 next_desc; struct fealnx_desc *next_desc_logical; struct sk_buff *skbuff; u32 reserved1; u32 reserved2;};/* Bits in network_desc.status */enum rx_desc_status_bits { RXOWN=0x80000000, /* own bit */ FLNGMASK=0x0fff0000, /* frame length */ FLNGShift=16, MARSTATUS=0x00004000, /* multicast address received */ BARSTATUS=0x00002000, /* broadcast address received */ PHYSTATUS=0x00001000, /* physical address received */ RXFSD=0x00000800, /* first descriptor */ RXLSD=0x00000400, /* last descriptor */ ErrorSummary=0x80, /* error summary */ RUNT=0x40, /* runt packet received */ LONG=0x20, /* long packet received */ FAE=0x10,/* frame align error */ CRC=0x08,/* crc error */ RXER=0x04, /* receive error */};enum rx_desc_control_bits { RXIC=0x00800000, /* interrupt control */ RBSShift=0,};enum tx_desc_status_bits { TXOWN=0x80000000, /* own bit */ JABTO=0x00004000, /* jabber timeout */ CSL=0x00002000, /* carrier sense lost */ LC=0x00001000,/* late collision */ EC=0x00000800,/* excessive collision */ UDF=0x00000400, /* fifo underflow */ DFR=0x00000200, /* deferred */ HF=0x00000100,/* heartbeat fail */ NCRMask=0x000000ff,/* collision retry count */ NCRShift=0,};enum tx_desc_control_bits { TXIC=0x80000000, /* interrupt control */ ETIControl=0x40000000,/* early transmit interrupt */ TXLD=0x20000000, /* last descriptor */ TXFD=0x10000000, /* first descriptor */ CRCEnable=0x08000000, /* crc control */ PADEnable=0x04000000, /* padding control */ PKTSMask=0x3ff800, /* packet size bit21-11 */ PKTSShift=11, TBSMask=0x000007ff, /* transmit buffer bit 10-0 */ TBSShift=0,};/* BootROM/EEPROM/MII Management Register */#define MASK_MIIR_MII_READ 0x00000000#define MASK_MIIR_MII_WRITE 0x00000008#define MASK_MIIR_MII_MDO 0x00000004#define MASK_MIIR_MII_MDI 0x00000002#define MASK_MIIR_MII_MDC 0x00000001/* ST+OP+PHYAD+REGAD+TA */#define OP_READ 0x6000 /* ST:01+OP:10+PHYAD+REGAD+TA:Z0 */#define OP_WRITE 0x5002 /* ST:01+OP:01+PHYAD+REGAD+TA:10 *//* ------------------------------------------------------------------------- *//* Constants for PHY *//* ------------------------------------------------------------------------- */#define PHYID 0xd0000302/* 89-7-27 add, (begin) */#define PHYID00x0302#define StatusRegister 18#define SPEED100 0x0400 // bit10#define FULLMODE 0x0800 // bit11/* 89-7-27 add, (end) *//* ------------------------------------------------------------------------- *//* Constants for Seeq 80225 PHY *//* ------------------------------------------------------------------------- */#define SeeqPHYID0 0x0016#define MIIRegister18 18#define SPD_DET_1000x80#define DPLX_DET_FULL 0x40/* ------------------------------------------------------------------------- *//* Constants for Ahdoc 101 PHY *//* ------------------------------------------------------------------------- */#define AhdocPHYID00x0022#define DiagnosticReg 18#define DPLX_FULL 0x0800#define Speed_100 0x0400/* 89/6/13 add, *//* -------------------------------------------------------------------------- *//* Constants *//* -------------------------------------------------------------------------- */#define MarvellPHYID0 0x0141#define MII1000BaseTControlReg 9#define MII1000BaseTStatusReg 10/* for 1000BaseT Control Register */#define PHYAbletoPerform1000FullDuplex 0x0200#define PHYAbletoPerform1000HalfDuplex 0x0100#define PHY1000AbilityMask 0x300#define SpecificReg17#define SpeedMask 0x0c000#define Speed_1000M0x08000#define Speed_100M 0x4000#define Speed_10M 0#define Full_Duplex0x2000/* for 3-in-1 case */#define PS10 0x00080000#define FD 0x00100000#define PS10000x00010000#define LinkIsUp20x00040000/* for PHY */#define LinkIsUp 0x0004struct netdev_private { /* Descriptor rings first for alignment. */ struct fealnx_desc rx_ring[RX_RING_SIZE]; struct fealnx_desc tx_ring[TX_RING_SIZE]; /* Link for devices of this type. */ struct device *next_module; const char *product_name; struct net_device_stats stats; /* Media monitoring timer. */ struct timer_list timer; /* Frequently used values: keep some adjacent for cache effect. */ int chip_id; int flags; unsigned char pci_bus, pci_devfn; unsigned long crvalue; unsigned long bcrvalue; struct fealnx_desc *cur_rx; struct fealnx_desc *lack_rxbuf; int really_rx_count; struct fealnx_desc *cur_tx; struct fealnx_desc *cur_tx_copy; int really_tx_count; int free_tx_count; unsigned int rx_buf_sz; /* Based on MTU+slack. */ /* These values are keep track of the transceiver/media in use. */ unsigned int linkok; unsigned int line_speed; unsigned int duplexmode; unsigned int full_duplex:1;/* Full-duplex operation requested. */ unsigned int duplex_lock:1; unsigned int medialock:1; /* Do not sense media. */ unsigned int default_port:4; /* Last dev->if_port value. */ unsigned int PHYType; /* MII transceiver section. */ int mii_cnt;/* MII device addresses. */ unsigned char phys[2];/* MII device addresses. */ u32 pad[4]; /* Used for 32-byte alignment */};static uint mdio_read(struct device *dev, int phy_id, int location);static void mdio_write(struct device *dev, int phy_id, int location, int value);static int netdev_open(struct device *dev);static void getlinktype(struct device *dev);static void getlinkstatus(struct device *dev);static void netdev_timer(unsigned long data);static void tx_timeout(struct device *dev);static void init_ring(struct device *dev);static int start_tx(struct sk_buff *skb, struct device *dev);static void intr_handler(int irq, void *dev_instance, struct pt_regs *regs);static int netdev_rx(struct device *dev);static inline unsigned ether_crc(int length, unsigned char *data);static void set_rx_mode(struct device *dev);static struct net_device_stats *get_stats(struct device *dev);static int mii_ioctl(struct device *dev, struct ifreq *rq, int cmd);static int netdev_close(struct device *dev);void stop_nic_tx(long ioaddr, long crvalue){ writel(crvalue & (~0x40000), ioaddr+TCRRCR); /* wait for tx stop */ { int i=0, delay=0x1000; while ( (!(readl(ioaddr+TCRRCR)&0x04000000)) && (i<delay) ) { ++i; } }}void stop_nic_rx(long ioaddr, long crvalue){ writel(crvalue & (~0x1), ioaddr+TCRRCR); /* wait for rx stop */ { int i=0, delay=0x1000; while ( (!(readl(ioaddr+TCRRCR)&0x00008000)) && (i<delay) ) { ++i; } }}/* A list of our installed devices, for removing the driver module. */static struct device *root_net_dev = NULL;/* Ideally we would detect all network cards in slot order. That would be best done a central PCI probe dispatch, which wouldn't work well when dynamically adding drivers. So instead we detect just the cards we know about in slot order. */static int pci_etherdev_probe(struct device *dev,struct pci_id_info pci_tbl[]){ int cards_found = 0; int pci_index = 0; unsigned char pci_bus, pci_device_fn; if (!pcibios_present())return -ENODEV; for (;pci_index < 0xff; pci_index++) { u16 vendor, device, pci_command, new_command; int chip_idx, irq; long pciaddr; long ioaddr; if (pcibios_find_class(PCI_CLASS_NETWORK_ETHERNET << 8, pci_index, &pci_bus, &pci_device_fn) != PCIBIOS_SUCCESSFUL) break; pcibios_read_config_word(pci_bus, pci_device_fn, PCI_VENDOR_ID, &vendor); pcibios_read_config_word(pci_bus, pci_device_fn, PCI_DEVICE_ID, &device); for (chip_idx = 0; pci_tbl[chip_idx].vendor_id; chip_idx++) if (vendor == pci_tbl[chip_idx].vendor_id && (device & pci_tbl[chip_idx].device_id_mask) == pci_tbl[chip_idx].device_id)break; if (pci_tbl[chip_idx].vendor_id == 0) /* Compiled out! */ continue; /* get the system resources, IO/Memory Address, IRQ */ {#if defined(PCI_SUPPORT_VER2) struct pci_dev *pdev = pci_find_slot(pci_bus, pci_device_fn);#ifdef USE_IO pciaddr = pdev->base_address[0] & ~3;#else pciaddr = pdev->base_address[1];#endif irq = pdev->irq;#else u32 pci_memaddr; u8 pci_irq_line; pcibios_read_config_byte(pci_bus, pci_device_fn, PCI_INTERRUPT_LINE, &pci_irq_line);#ifdef USE_IO pcibios_read_config_dword(pci_bus, pci_device_fn,PCI_BASE_ADDRESS_0, &pci_memaddr); pciaddr = pci_memaddr & ~1;#else pcibios_read_config_dword(pci_bus, pci_device_fn,PCI_BASE_ADDRESS_1, &pci_memaddr); pciaddr = pci_memaddr;#endif irq = pci_irq_line;#endif } if ((pci_tbl[chip_idx].flags & PCI_USES_IO)) { /* use I/O access method */ if (check_region(pciaddr, pci_tbl[chip_idx].io_size)) continue; ioaddr = pciaddr; } else { /* use memory access method */ if ((ioaddr = (long)ioremap(pciaddr & ~0xf, 0x400)) == 0) { printk(KERN_INFO "Failed to map PCI address %#lx.\n", pciaddr); continue; } } /* check the command register */ pcibios_read_config_word(pci_bus, pci_device_fn, PCI_COMMAND, &pci_command); new_command = pci_command | (pci_tbl[chip_idx].flags & 7); if (pci_command != new_command) { printk(KERN_INFO " The PCI BIOS has not enabled the" " device at %d/%d! Updating PCI command %4.4x->%4.4x.\n", pci_bus, pci_device_fn, pci_command, new_command); pcibios_write_config_word(pci_bus, pci_device_fn, PCI_COMMAND,new_command); } dev = pci_tbl[chip_idx].probe1(pci_bus, pci_device_fn, dev, ioaddr, irq, chip_idx, cards_found); /* check the latency value */ if (dev && (pci_tbl[chip_idx].flags & PCI_COMMAND_MASTER)) { u8 pci_latency; pcibios_read_config_byte(pci_bus, pci_device_fn, PCI_LATENCY_TIMER, &pci_latency); if (pci_latency < min_pci_latency) { printk(KERN_INFO " PCI latency timer (CFLT) is " "unreasonably low at %d. Setting to %d clocks.\n", pci_latency, min_pci_latency); pcibios_write_config_byte(pci_bus, pci_device_fn, PCI_LATENCY_TIMER, min_pci_latency); } } dev = 0; cards_found++; } /* end of for loop */ return cards_found ? 0 : -ENODEV;}static struct device *fealnx_probe1(int pci_bus, int devfn, struct device *dev, long ioaddr, int irq, int chip_id, int card_idx){ struct netdev_private *np; int i, option = card_idx < MAX_UNITS ? options[card_idx] : 0; dev = init_etherdev(dev, sizeof(struct netdev_private)); printk(KERN_INFO "%s: %s at 0x%lx, ",dev->name, skel_netdrv_tbl[chip_id].chip_name, ioaddr); /* read ethernet id */ for (i=0;i<6;++i)dev->dev_addr=readb(ioaddr+PAR0+i); for (i = 0; i < 5; i++)printk("%2.2x:", dev->dev_addr); printk("%2.2x, IRQ %d.\n", dev->dev_addr, irq);#ifdef USE_IO request_region(ioaddr, pci_tbl[chip_id].io_size, dev->name);#endif /* Reset the chip to erase previous misconfiguration. */ writel(0x00000001, ioaddr + BCR); dev->base_addr = ioaddr; dev->irq = irq; /* Make certain the descriptor lists are aligned. */ np = (void *)(((long)kmalloc(sizeof(*np), GFP_KERNEL) + 15) & ~15); memset(np, 0, sizeof(*np)); dev->priv = np; np->next_module = root_net_dev; root_net_dev = dev; np->pci_bus = pci_bus; np->pci_devfn = devfn; np->chip_id = chip_id; np->flags = skel_netdrv_tbl[np->chip_id].flags; /* find the connected MII xcvrs */ if (np->flags==HAS_MII_XCVR) { int phy, phy_idx = 0; for (phy = 1; phy < 32 && phy_idx < 4; phy++) { int mii_status = mdio_read(dev, phy, 1); if (mii_status != 0xffff && mii_status != 0x0000) { np->phys[phy_idx++] = phy; printk(KERN_INFO "%s: MII PHY found at address %d, status " "0x%4.4x.\n", dev->name, phy, mii_status); /* get phy type */ {unsigned int data;data=mdio_read(dev, np->phys[0], 2);if (data==SeeqPHYID0) np->PHYType=SeeqPHY;else if (data==AhdocPHYID0) np->PHYType=AhdocPHY;else if (data==MarvellPHYID0) np->PHYType=MarvellPHY;else if (data==PHYID0) np->PHYType=MTD981;else np->PHYType=OtherPHY; } } } np->mii_cnt = phy_idx; if (phy_idx == 0) { printk(KERN_WARNING "%s: MII PHY not found -- this device may " "not operate correctly.\n", dev->name); } } else { np->phys[0] = 32;/* 89/6/23 add, (begin) */ /* get phy type */ if (readl(dev->base_addr+PHYIDENTIFIER)==PHYID) np->PHYType=PHY; else np->PHYType=OtherPHY; } if (dev->mem_start)option = dev->mem_start; /* The lower four bits are the media type. */ if (option > 0) { if (option & 0x200) np->full_duplex = 1; np->default_port = option & 15; if (np->default_port) np->medialock = 1; } if (card_idx < MAX_UNITS && full_duplex[card_idx] > 0)np->full_duplex = full_duplex[card_idx]; if (np->full_duplex) { printk(KERN_INFO "%s: Media type forced to Full Duplex.\n", dev->name);/* 89/6/13 add, (begin) */ if (np->PHYType==MarvellPHY) { unsigned int data; data=mdio_read(dev, np->phys[0], 9); data=(data&0xfcff)|0x0200; mdio_write(dev, np->phys[0], 9, data); }/* 89/6/13 add, (end) */ if (np->flags==HAS_MII_XCVR) mdio_write(dev, np->phys[0], 4, 0x141); else writel(0x141, dev->base_addr+ANARANLPAR); np->duplex_lock = 1; } /* The chip-specific entries in the device structure. */ dev->open = &netdev_open; dev->hard_start_xmit = &start_tx; dev->stop = &netdev_close; dev->get_stats = &get_stats; dev->set_multicast_list = &set_rx_mode; dev->do_ioctl = &mii_ioctl; return dev;}uint m80x_read_tick()/* function: Reads the Timer tick count register which decrements by 2 from *//* 65536 to 0 every 1/36.414 of a second. Each 2 decrements of the */ /* count represents 838 nsec's. *//* input : none. *//* output : none. */{ unsigned char tmp; int value; writeb((char)0x06, 0x43); // Command 8254 to latch T0's count // now read the count. tmp=(unsigned char)readb(0x40); value=((int)tmp)<<8; tmp=(unsigned char)readb(0x40); value|=(((int)tmp)&0xff); return (value);}void m80x_delay(uint interval)/* function: to wait for a specified time.*//* input : interval ... the specified time. *//* output : none. */{ uint interval1, interval2, i=0; interval1=m80x_read_tick(); // get initial value do { interval2=m80x_read_tick(); if (interval1<interval2) interval1=interval2; ++i; } while ( ((interval1-interval2)<(ushort)interval)&&(i<65535) );}static ulong m80x_send_cmd_to_phy(long miiport, int opcode, int phyad, int regad){ ulong miir; int i; uint mask, data; /* enable MII output */ miir=(ulong)readl(miiport); miir&=0xfffffff0; miir|=MASK_MIIR_MII_WRITE+MASK_MIIR_MII_MDO; /* send 32 1's preamble */ for (i=0;i<32;i++) { /* low MDC; MDO is already high (miir) */ miir&=~MASK_MIIR_MII_MDC; writel(miir, miiport); /* high MDC */ miir|=MASK_MIIR_MII_MDC; writel(miir, miiport); } /* calculate ST+OP+PHYAD+REGAD+TA */ data=opcode|(phyad<<7)|(regad<<2); /* sent out */ mask=0x8000; while (mask) { /* low MDC, prepare MDO */ miir&=~(MASK_MIIR_MII_MDC+MASK_MIIR_MII_MDO); if (mask & data) miir|=MASK_MIIR_MII_MDO; writel(miir, miiport); /* high MDC */ miir|=MASK_MIIR_MII_MDC; writel(miir, miiport); m80x_delay(30); /* next */ mask>>=1; if (mask==0x2 && opcode==OP_READ) miir&=~MASK_MIIR_MII_WRITE; } return miir;}static uint mdio_read(struct device *dev, int phyad, int regad){ long miiport = dev->base_addr + MANAGEMENT; ulong miir; uint mask, data; miir=m80x_send_cmd_to_phy(miiport, OP_READ, phyad, regad); /* read data */ mask=0x8000; data=0; while (mask) { /* low MDC */ miir&=~MASK_MIIR_MII_MDC; writel(miir, miiport); /* read MDI */ miir=readl(miiport); if (miir & MASK_MIIR_MII_MDI) data|=mask; /* high MDC, and wait */ miir|=MASK_MIIR_MII_MDC; writel(miir, miiport); m80x_delay((int)30); /* next */ mask>>=1; } /* low MDC */ miir&=~MASK_MIIR_MII_MDC; writel(miir, miiport); return data;}static void mdio_write(struct device *dev, int phyad, int regad, int data){ long miiport = dev->base_addr + MANAGEMENT; ulong miir; uint mask; miir=m80x_send_cmd_to_phy(miiport, OP_WRITE, phyad, regad); /* write data */ mask=0x8000; while (mask) { /* low MDC, prepare MDO */ miir&=~(MASK_MIIR_MII_MDC+MASK_MIIR_MII_MDO); if (mask&data) miir|=MASK_MIIR_MII_MDO; writel(miir, miiport); /* high MDC */ miir|=MASK_MIIR_MII_MDC; writel(miir, miiport); /* next */ mask>>=1; } /* low MDC */ miir&=~MASK_MIIR_MII_MDC; writel(miir, miiport); return;}static int netdev_open(struct device *dev){ struct netdev_private *np = (struct netdev_private *)dev->priv; long ioaddr = dev->base_addr; writel(0x00000001, ioaddr + BCR); /* Reset */ if (request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev))return -EAGAIN; MOD_INC_USE_COUNT; init_ring(dev); writel(virt_to_bus(np->rx_ring), ioaddr + RXLBA); writel(virt_to_bus(np->tx_ring), ioaddr + TXLBA); /* Initialize other registers. */ /* Configure the PCI bus bursts and FIFO thresholds. 486: Set 8 longword burst. 586: no burst limit. Burst length 5:3 0 0 0 1 0 0 1 4 0 1 0 8 0 1 1 16 1 0 0 32 1 0 1 64 1 1 0 128 1 1 1 256 Wait the specified 50 PCI cycles after a reset by initializing Tx and Rx queues and the address filter list. */#if defined(__powerpc__)// 89/9/1 modify, // np->bcrvalue=0x04 | 0x0x38; /* big-endian, 256 burst length */ np->bcrvalue=0x04 | 0x0x10; /* big-endian, tx 8 burst length */a np->cralue=0xe00; /* rx 128 burst length */ #elif defined(__alpha__)// 89/9/1 modify, // np->bcrvalue=0x38; /* little-endian, 256 burst length */ np->bcrvalue=0x10; /* little-endian, 8 burst length */ np->cralue=0xe00; /* rx 128 burst length */ #elif defined(__i386__)#if defined(MODULE)// 89/9/1 modify, // np->bcrvalue=0x38; /* little-endian, 256 burst length */ np->bcrvalue=0x10; /* little-endian, 8 burst length */ np->crvalue=0xe00; /* rx 128 burst length */ #else /* When not a module we can work around broken '486 PCI boards. */#if (LINUX_VERSION_CODE > 0x2014c)#define x86 boot_cpu_data.x86#endif// 89/9/1 modify, // np->bcrvalue=(x86 <= 4 ? 0x10 : 0x38); np->bcrvalue=0x10; np->crvalue=(x86 <= 4 ? 0xa00 : 0xe00); if (x86 <= 4)printk(KERN_INFO "%s: This is a 386/486 PCI system, setting burst " "length to %x.\n", dev->name, (x86 <= 4 ? 0x10 : 0x38));#endif#else// 89/9/1 modify,// np->bcrvalue=0x38; np->bcrvalue=0x10; np->cralue=0xe00; /* rx 128 burst length */ #warning Processor architecture undefined!#endif writel(np->bcrvalue, ioaddr + BCR); if (dev->if_port == 0)dev->if_port = np->default_port; dev->interrupt = 0; writel(0, dev->base_addr + RXPDR);// 89/9/1 modify,// np->crvalue = 0x00e40001; /* tx store and forward, tx/rx enable */ np->crvalue |= 0x00e40001; /* tx store and forward, tx/rx enable */ np->full_duplex = np->duplex_lock; getlinkstatus(dev); if (np->linkok)getlinktype(dev); set_rx_mode(dev); dev->start = 1; /* Clear and Enable interrupts by setting the interrupt mask. */ writel(FBE|TUNF|CNTOVF|RBU|TI|RI, ioaddr + ISR); writel(FBE|TUNF|CNTOVF|RBU|TI|RI, ioaddr + IMR); if (debug)printk(KERN_DEBUG "%s: Done netdev_open().\n", dev->name); /* Set the timer to check for link beat. */ init_timer(&np->timer); np->timer.expires = RUN_AT(3*HZ); np->timer.data = (unsigned long)dev; np->timer.function = &netdev_timer; /* timer handler */ add_timer(&np->timer); return 0;}static void getlinkstatus(struct device *dev)/* function: Routine will read MII Status Register to get link status. *//* input : dev... pointer to the adapter block. *//* output : none. */{ struct netdev_private *np = (struct netdev_private *)dev->priv; uint i, DelayTime=0x1000; np->linkok=0; if (np->PHYType==PHY) { for (i=0;i<DelayTime;++i) { if (readl(dev->base_addr+BMCRSR)&LinkIsUp2) { np->linkok=1; return; } // delay m80x_delay(100); } } else { for (i=0;i<DelayTime;++i) { if (mdio_read(dev, np->phys[0], 1)&0x4) { np->linkok=1; return; } // delay m80x_delay(100); } }}static void getlinktype(struct device *dev){ struct netdev_private *np = (struct netdev_private *)dev->priv; if (np->PHYType==PHY) { /* 3-in-1 case */ if (readl(dev->base_addr+TCRRCR)&FD) np->duplexmode=2; /* full duplex */ else np->duplexmode=1; /* half duplex */ if (readl(dev->base_addr+TCRRCR)&PS10) np->line_speed=1; /* 10M */ else np->line_speed=2; /* 100M */ } else { if (np->PHYType==SeeqPHY) { /* this PHY is SEEQ 80225 */ uint data; data=mdio_read(dev, np->phys[0], MIIRegister18); if (data & SPD_DET_100) np->line_speed=2;/* 100M */ else np->line_speed=1;/* 10M */ if (data & DPLX_DET_FULL) np->duplexmode=2; /* full duplex mode */ else np->duplexmode=1; /* half duplex mode */ } else if (np->PHYType==AhdocPHY) { uint data; data=mdio_read(dev, np->phys[0], DiagnosticReg); if (data & Speed_100) np->line_speed=2;/* 100M */ else np->line_speed=1;/* 10M */ if (data & DPLX_FULL) np->duplexmode=2; /* full duplex mode */ else np->duplexmode=1; /* half duplex mode */ }/* 89/6/13 add, (begin) */ else if (np->PHYType==MarvellPHY) { uint data; data=mdio_read(dev, np->phys[0], SpecificReg); if (data & Full_Duplex) np->duplexmode=2; /* full duplex mode */ else np->duplexmode=1; /* half duplex mode */ data&=SpeedMask; if (data==Speed_1000M) np->line_speed=3;/* 1000M */ else if (data==Speed_100M) np->line_speed=2;/* 100M */ else np->line_speed=1;/* 10M */ }/* 89/6/13 add, (end) *//* 89/7/27 add, (begin) */ else if (np->PHYType==MTD981) { uint data; data=mdio_read(dev, np->phys[0], StatusRegister); if (data & SPEED100) np->line_speed=2; else np->line_speed=1; if (data & FULLMODE) np->duplexmode=2; else np->duplexmode=1; }/* 89/7/27 add, (end) */ // chage crvalue // np->crvalue&=(~PS10)&(~FD); np->crvalue&=(~PS10)&(~FD)&(~PS1000); if (np->line_speed==1) np->crvalue|=PS10; else if (np->line_speed==3) np->crvalue|=PS1000; if (np->duplexmode==2) np->crvalue|=FD; }}static void allocate_rx_buffers(struct device *dev){ struct netdev_private *np = (struct netdev_private *)dev->priv; /* allocate skb for rx buffers */ while (np->really_rx_count!=RX_RING_SIZE) { struct sk_buff *skb; skb = dev_alloc_skb(np->rx_buf_sz); np->lack_rxbuf->skbuff = skb; if (skb == NULL) break;/* Better luck next round. */ skb->dev = dev; /* Mark as being used by this device. */ np->lack_rxbuf->buffer = virt_to_bus(skb->tail); np->lack_rxbuf = np->lack_rxbuf->next_desc_logical; ++np->really_rx_count; }}static void netdev_timer(unsigned long data){ struct device *dev = (struct device *)data; struct netdev_private *np = (struct netdev_private *)dev->priv; long ioaddr = dev->base_addr; int next_tick = 10*HZ; int old_crvalue=np->crvalue; unsigned int old_linkok=np->linkok; if (debug)printk(KERN_DEBUG "%s: Media selection timer tick, status %8.8x " "config %8.8x.\n", dev->name, readl(ioaddr + ISR), readl(ioaddr + TCRRCR)); if (np->flags==HAS_MII_XCVR) { getlinkstatus(dev); if ((old_linkok==0)&&(np->linkok==1)) { /* we need to detect the media type again */ getlinktype(dev); if (np->crvalue != old_crvalue) { stop_nic_tx(ioaddr, np->crvalue); stop_nic_rx(ioaddr, np->crvalue&(~0x40000)); writel(np->crvalue, ioaddr + TCRRCR); } } } allocate_rx_buffers(dev); np->timer.expires = RUN_AT(next_tick); add_timer(&np->timer);}static void tx_timeout(struct device *dev){ struct netdev_private *np = (struct netdev_private *)dev->priv; long ioaddr = dev->base_addr; printk(KERN_WARNING "%s: Transmit timed out, status %8.8x,"" resetting...\n", dev->name, readl(ioaddr + ISR));#ifndef __alpha__ { int i; printk(KERN_DEBUG " Rx ring %8.8x: ", (int)np->rx_ring); for (i = 0; i < RX_RING_SIZE; i++) printk(" %8.8x", (unsigned int)np->rx_ring.status); printk("\n"KERN_DEBUG" Tx ring %8.8x: ", (int)np->tx_ring); for (i = 0; i < TX_RING_SIZE; i++) printk(" %4.4x", np->tx_ring.status); printk("\n"); }#endif /* Perhaps we should reinitialize the hardware here. Just trigger a Tx demand for now. */ writel(0, dev->base_addr + TXPDR); dev->if_port = 0; /* Stop and restart the chip's Tx processes . */ dev->trans_start = jiffies; np->stats.tx_errors++; return;}/* Initialize the Rx and Tx rings, along with various 'dev' bits. */static void init_ring(struct device *dev){ struct netdev_private *np = (struct netdev_private *)dev->priv; int i; /* initialize rx variables */ np->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32); np->cur_rx = &np->rx_ring[0]; np->lack_rxbuf = NULL; np->really_rx_count = 0; /* initial rx descriptors. */ for (i = 0; i < RX_RING_SIZE; i++) { np->rx_ring.status = 0; np->rx_ring.control = np->rx_buf_sz<<RBSShift; np->rx_ring.next_desc = virt_to_bus(&np->rx_ring[i+1]); np->rx_ring.next_desc_logical = &np->rx_ring[i+1]; np->rx_ring.skbuff = NULL; } /* for the last rx descriptor */ np->rx_ring[i-1].next_desc = virt_to_bus(&np->rx_ring[0]); np->rx_ring[i-1].next_desc_logical = &np->rx_ring[0]; /* allocate skb for rx buffers */ for (i = 0; i < RX_RING_SIZE; i++) { struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz); if (skb == NULL) { np->lack_rxbuf = &np->rx_ring; break; } ++np->really_rx_count; np->rx_ring.skbuff = skb; skb->dev = dev; /* Mark as being used by this device. */ np->rx_ring.buffer = virt_to_bus(skb->tail); np->rx_ring.status = RXOWN; np->rx_ring.control |= RXIC; } /* initialize tx variables */ np->cur_tx = &np->tx_ring[0]; np->cur_tx_copy = &np->tx_ring[0]; np->really_tx_count = 0; np->free_tx_count = TX_RING_SIZE; for (i = 0; i < TX_RING_SIZE; i++) { np->tx_ring.status = 0; np->tx_ring.next_desc = virt_to_bus(&np->tx_ring[i+1]); np->tx_ring.next_desc_logical = &np->tx_ring[i+1]; np->tx_ring.skbuff = NULL; } /* for the last tx descriptor */ np->tx_ring[i-1].next_desc = virt_to_bus(&np->tx_ring[0]); np->tx_ring[i-1].next_desc_logical = &np->tx_ring[0]; return;}static int start_tx(struct sk_buff *skb, struct device *dev){ struct netdev_private *np = (struct netdev_private *)dev->priv; if (np->free_tx_count<=2) { if (jiffies - dev->trans_start > TX_TIMEOUT) tx_timeout(dev); return 1; } np->cur_tx_copy->skbuff = skb; np->cur_tx_copy->buffer = virt_to_bus(skb->data);#define one_buffer#define BPT 1022#if defined(one_buffer) np->cur_tx_copy->control = TXIC|TXLD|TXFD|CRCEnable|PADEnable; np->cur_tx_copy->control |= (skb->len<<PKTSShift); /* pkt size */ np->cur_tx_copy->control |= (skb->len<<TBSShift); /* buffer size */ np->cur_tx_copy->status = TXOWN; np->cur_tx_copy = np->cur_tx_copy->next_desc_logical; --np->free_tx_count;#elif defined(two_buffer) if (skb->len > BPT) { struct fealnx_desc *next; /* for the first descriptor */ np->cur_tx_copy->control = TXIC|TXFD|CRCEnable|PADEnable; np->cur_tx_copy->control |= (skb->len<<PKTSShift); /* pkt size */ np->cur_tx_copy->control |= (BPT<<TBSShift); /* buffer size */ /* for the last descriptor */ next = (struct fealnx *)np->cur_tx_copy.next_desc_logical; next->skbuff = skb; next->control = TXIC|TXLD|CRCEnable|PADEnable; next->control |= (skb->len<<PKTSShift);/* pkt size */ next->control |= ((skb->len-BPT)<<TBSShift);/* buf size */ next->buffer = virt_to_bus(skb->data) + BPT; next->status = TXOWN; np->cur_tx_copy->status = TXOWN; np->cur_tx_copy = next->next_desc_logical; np->free_tx_count-=2; } else { np->cur_tx_copy->control = TXIC|TXLD|TXFD|CRCEnable|PADEnable; np->cur_tx_copy->control |= (skb->len<<PKTSShift); /* pkt size */ np->cur_tx_copy->control |= (skb->len<<TBSShift); /* buffer size */ np->cur_tx_copy->status = TXOWN; np->cur_tx_copy = np->cur_tx_copy->next_desc_logical; --np->free_tx_count; }#endif ++np->really_tx_count; writel(0, dev->base_addr + TXPDR); dev->trans_start = jiffies; return 0;}void free_one_rx_descriptor(struct netdev_private *np){ if (np->really_rx_count==RX_RING_SIZE)np->cur_rx->status = RXOWN; else { np->lack_rxbuf->skbuff = np->cur_rx->skbuff; np->lack_rxbuf->buffer = np->cur_rx->buffer; np->lack_rxbuf->status = RXOWN; ++np->really_rx_count; np->lack_rxbuf = np->lack_rxbuf->next_desc_logical; } np->cur_rx = np->cur_rx->next_desc_logical;}void reset_rx_descriptors(struct device *dev){ struct netdev_private *np = (struct netdev_private *)dev->priv; stop_nic_rx(dev->base_addr, np->crvalue); while (!(np->cur_rx->status&RXOWN))free_one_rx_descriptor(np); allocate_rx_buffers(dev); writel(virt_to_bus(np->cur_rx), dev->base_addr + RXLBA); writel(np->crvalue, dev->base_addr + TCRRCR);}/* The interrupt handler does all of the Rx thread work and cleans up after the Tx thread. */static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs){ struct device *dev = (struct device *)dev_instance; struct netdev_private *np; long ioaddr, boguscnt = max_interrupt_work; writel(0, dev->base_addr + IMR);#ifndef final_version /* Can never occur. */ if (dev == NULL) { printk (KERN_ERR "Netdev interrupt handler(): IRQ %d for unknown " "device.\n", irq); writel(FBE|TUNF|CNTOVF|RBU|TI|RI, dev->base_addr + IMR); return; }#endif ioaddr = dev->base_addr; np = (struct netdev_private *)dev->priv;#if defined(__i386__) /* A lock to prevent simultaneous entry bug on Intel SMP machines. */ if (test_and_set_bit(0, (void*)&dev->interrupt)) { printk(KERN_ERR"%s: SMP simultaneous entry of an interrupt handler.\n", dev->name); dev->interrupt = 0;/* Avoid halting machine. */ writel(FBE|TUNF|CNTOVF|RBU|TI|RI, ioaddr + IMR); return; }#else if (dev->interrupt) { printk(KERN_ERR "%s: Re-entering the interrupt handler.\n", dev->name); writel(FBE|TUNF|CNTOVF|RBU|TI|RI, ioaddr + IMR); return; } dev->interrupt = 1;#endif do { u32 intr_status = readl(ioaddr + ISR); /* Acknowledge all of the current interrupt sources ASAP. */ writel(intr_status, ioaddr + ISR); if (debug) printk(KERN_DEBUG "%s: Interrupt, status %4.4x.\n", dev->name,intr_status); if ((intr_status & (TUNF|CNTOVF|FBE|RBU|TI|RI)) == 0) break; if (intr_status & FBE) { /* fatal error */stop_nic_tx(ioaddr, 0);stop_nic_rx(ioaddr, 0);break; }; if (intr_status & TUNF) writel(0, ioaddr + TXPDR); if (intr_status & CNTOVF) { /* missed pkts */ np->stats.rx_missed_errors += readl(ioaddr + TALLY) & 0x7fff; /* crc error */ np->stats.rx_crc_errors += (readl(ioaddr + TALLY) & 0x7fff0000) >> 16; } if (intr_status & (RI | RBU)) { if (intr_status & RI) netdev_rx(dev); else reset_rx_descriptors(dev); } while (np->really_tx_count) { long tx_status = np->cur_tx->status; long tx_control = np->cur_tx->control; if (!(tx_control & TXLD)) { /* this pkt is combined by two tx descriptors */ struct fealnx_desc *next; next = np->cur_tx->next_desc_logical; tx_status = next->status; tx_control = next->control; } if (tx_status & TXOWN) break; if (tx_status &(CSL|LC|EC|UDF|HF)) { np->stats.tx_errors++; if (tx_status & EC) np->stats.tx_aborted_errors++; if (tx_status & CSL) np->stats.tx_carrier_errors++; if (tx_status & LC) np->stats.tx_window_errors++; if (tx_status & UDF) np->stats.tx_fifo_errors++; if ((tx_status & HF) && np->full_duplex == 0) np->stats.tx_heartbeat_errors++;#ifdef ETHER_STATS if (tx_status & EC) np->stats.collisions16++;#endif } else {#ifdef ETHER_STATS if (tx_status & DFR) np->stats.tx_deferred++;#endif#if LINUX_VERSION_CODE > 0x20127 np->stats.tx_bytes += ((tx_control & PKTSMask) >> PKTSShift);#endif np->stats.collisions += ((tx_status & NCRMask)>>NCRShift); np->stats.tx_packets++; } /* Free the original skb. */ dev_free_skb(np->cur_tx->skbuff); np->cur_tx->skbuff = NULL; --np->really_tx_count; if (np->cur_tx->control&TXLD) { np->cur_tx = np->cur_tx->next_desc_logical; ++np->free_tx_count; } else { np->cur_tx = np->cur_tx->next_desc_logical; np->cur_tx = np->cur_tx->next_desc_logical; np->free_tx_count+=2; } } /* end of for loop */ if (np->free_tx_count>=2) mark_bh(NET_BH); if (--boguscnt < 0) { printk(KERN_WARNING "%s: Too much work at interrupt, " "status=0x%4.4x.\n", dev->name, intr_status); break; } } while (1); /* read the tally counters */ /* missed pkts */ np->stats.rx_missed_errors += readl(ioaddr + TALLY) & 0x7fff; /* crc error */ np->stats.rx_crc_errors += (readl(ioaddr + TALLY) & 0x7fff0000) >> 16; if (debug)printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n", dev->name, readl(ioaddr + ISR));#if defined(__i386__) clear_bit(0, (void*)&dev->interrupt);#else dev->interrupt = 0;#endif writel(FBE|TUNF|CNTOVF|RBU|TI|RI, ioaddr + IMR); return;}/* This routine is logically part of the interrupt handler, but seperated for clarity and better register allocation. */static int netdev_rx(struct device *dev){ struct netdev_private *np = (struct netdev_private *)dev->priv; /* If EOP is set on the next entry, it's a new packet. Send it up. */ while (!(np->cur_rx->status & RXOWN)) { s32 rx_status = np->cur_rx->status; if (np->really_rx_count==0) break; if (debug) printk(KERN_DEBUG " netdev_rx() status was %8.8x.\n", rx_status); if ((!((rx_status&RXFSD)&&(rx_status&RXLSD))) || (rx_status&ErrorSummary)) { if (rx_status & ErrorSummary) { /* there was a fatal error */ if (debug) printk(KERN_DEBUG "%s: Receive error, Rx status %8.8x.\n", dev->name, rx_status); np->stats.rx_errors++; /* end of a packet.*/ if (rx_status & (LONG|RUNT)) np->stats.rx_length_errors++; if (rx_status & RXER) np->stats.rx_frame_errors++; if (rx_status & CRC) np->stats.rx_crc_errors++; } else { int need_to_reset=0; int desno=0; if (rx_status & RXFSD) { /* this pkt is too long, over one rx buffer */struct fealnx_desc *cur;/* check this packet is received completely? */cur = np->cur_rx;while (desno<=np->really_rx_count){ ++desno; if ((!(cur->status&RXOWN)) && (cur->status&RXLSD))break; /* goto next rx descriptor */ cur = cur->next_desc_logical;}if (desno>np->really_rx_count) need_to_reset = 1; } else /* RXLSD did not find, something error */ need_to_reset = 1; if (need_to_reset==0) {int i;np->stats.rx_length_errors++;/* free all rx descriptors related this long pkt */for (i=0;i<desno;++i) free_one_rx_descriptor(np);continue; } else { /* something error, need to reset this chip */reset_rx_descriptors(dev); } break; /* exit the while loop */ } } else /* this received pkt is ok */ { struct sk_buff *skb; /* Omit the four octet CRC from the length. */ short pkt_len = ((rx_status&FLNGMASK)>>FLNGShift) -4;#ifndef final_version if (debug) printk(KERN_DEBUG " netdev_rx() normal Rx pkt length %d" " status %x.\n", pkt_len, rx_status);#endif /* Check if the packet is long enough to accept without copying to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { skb->dev = dev; skb_reserve(skb, 2); /* 16 byte align the IP header */ /* Call copy + cksum if available. */#if ! defined(__alpha__) eth_copy_and_sum(skb, bus_to_virt(np->cur_rx->buffer), pkt_len, 0); skb_put(skb, pkt_len);#else memcpy(skb_put(skb, pkt_len), bus_to_virt(np->cur_rx->buffer), pkt_len);#endif } else { skb_put(skb = np->cur_rx->skbuff, pkt_len); np->cur_rx->skbuff = NULL; if (np->really_rx_count == RX_RING_SIZE) np->lack_rxbuf = np->cur_rx; --np->really_rx_count; } skb->protocol = eth_type_trans(skb, dev); netif_rx(skb); dev->last_rx = jiffies; np->stats.rx_packets++;#if LINUX_VERSION_CODE > 0x20127 np->stats.rx_bytes += pkt_len;#endif } if (np->cur_rx->skbuff==NULL) { struct sk_buff *skb; skb = dev_alloc_skb(np->rx_buf_sz); if (skb !=NULL) { skb->dev = dev; /* Mark as being used by this device. */ np->cur_rx->buffer = virt_to_bus(skb->tail); np->cur_rx->skbuff = skb; ++np->really_rx_count; } } if (np->cur_rx->skbuff!=NULL) free_one_rx_descriptor(np); } /* end of while loop */ /* allocate skb for rx buffers */ allocate_rx_buffers(dev); return 0;}static struct enet_statistics *get_stats(struct device *dev){ long ioaddr = dev->base_addr; struct netdev_private *np = (struct netdev_private *)dev->priv; /* The chip only need report frame silently dropped. */ if (dev->start) { np->stats.rx_missed_errors += readl(ioaddr + TALLY) & 0x7fff; np->stats.rx_crc_errors += (readl(ioaddr + TALLY) & 0x7fff0000) >> 16; } return &np->stats;}static unsigned const ethernet_polynomial = 0x04c11db7U;static inline u32 ether_crc(int length, unsigned char *data){ int crc = -1; while(--length >= 0) { unsigned char current_octet = *data++; int bit; for (bit = 0; bit < 8; bit++, current_octet >>= 1) { crc = (crc << 1) ^((crc < 0) ^ (current_octet & 1) ? ethernet_polynomial : 0); } } return crc;}static void set_rx_mode(struct device *dev){ struct netdev_private *np = (struct netdev_private *)dev->priv; long ioaddr = dev->base_addr; u32 mc_filter[2]; /* Multicast hash filter */ u32 rx_mode; if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ /* Unconditionally log net taps. */ printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name); memset(mc_filter, 0xff, sizeof(mc_filter)); rx_mode = PROM|AB|AM; } elseif ((dev->mc_count > multicast_filter_limit) || (dev->flags & IFF_ALLMULTI)){ /* Too many to match, or accept all multicasts. */ memset(mc_filter, 0xff, sizeof(mc_filter)); rx_mode = AB|AM;}else{ struct dev_mc_list *mclist; int i; memset(mc_filter, 0, sizeof(mc_filter)); for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count; i++, mclist = mclist->next) { set_bit((ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26) ^ 0x3F,mc_filter); } rx_mode = AB|AM;} stop_nic_tx(ioaddr, np->crvalue); stop_nic_rx(ioaddr, np->crvalue&(~0x40000)); writel(mc_filter[0], ioaddr + MAR0); writel(mc_filter[1], ioaddr + MAR1); np->crvalue &= ~RxModeMask; np->crvalue |= rx_mode; writel(np->crvalue, ioaddr + TCRRCR);}static int mii_ioctl(struct device *dev, struct ifreq *rq, int cmd){ u16 *data = (u16 *)&rq->ifr_data; switch(cmd) { case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */ data[0] = ((struct netdev_private *)dev->priv)->phys[0] & 0x1f; /* Fall Through */ case SIOCDEVPRIVATE+1:/* Read the specified MII register. */ data[3] = mdio_read(dev, data[0] & 0x1f, data[1] & 0x1f); return 0; case SIOCDEVPRIVATE+2:/* Write the specified MII register */ if (!suser())return -EPERM; mdio_write(dev, data[0] & 0x1f, data[1] & 0x1f, data[2]); return 0; default: return -EOPNOTSUPP; }}static int netdev_close(struct device *dev){ long ioaddr = dev->base_addr; struct netdev_private *np = (struct netdev_private *)dev->priv; int i; dev->start = 0; dev->tbusy = 1; /* Disable interrupts by clearing the interrupt mask. */ writel(0x0000, ioaddr + IMR); /* Stop the chip's Tx and Rx processes. */ stop_nic_tx(ioaddr, 0); stop_nic_rx(ioaddr, 0); del_timer(&np->timer);#ifdef __i386__ if (debug) { printk("\n"KERN_DEBUG" Tx ring at %8.8x:\n", (int)virt_to_bus(np->tx_ring)); for (i = 0; i < TX_RING_SIZE; i++) printk(" #%d desc. %4.4x %4.4x %8.8x.\n", i, np->tx_ring.control, np->tx_ring.status, np->tx_ring.buffer); printk("\n"KERN_DEBUG " Rx ring %8.8x:\n", (int)virt_to_bus(np->rx_ring)); for (i = 0; i < RX_RING_SIZE; i++) { printk(KERN_DEBUG " #%d desc. %4.4x %4.4x %8.8x\n", i, np->rx_ring.control, np->rx_ring.status, np->rx_ring.buffer); } }#endif /* __i386__ debugging only */ free_irq(dev->irq, dev); /* Free all the skbuffs in the Rx queue. */ for (i = 0; i < RX_RING_SIZE; i++) { np->rx_ring.status = 0; if (np->rx_ring.skbuff) {#if LINUX_VERSION_CODE < 0x20100 np->rx_ring.skbuff->free = 1;#endif dev_free_skb(np->rx_ring.skbuff); } np->rx_ring.skbuff = NULL; } for (i = 0; i < TX_RING_SIZE; i++) { if (np->tx_ring.skbuff) dev_free_skb(np->tx_ring.skbuff); np->tx_ring.skbuff = NULL; } MOD_DEC_USE_COUNT; return 0;}#ifdef MODULEint init_module(void){ if (debug) /* Emit version even if no cards detected. */printk(KERN_INFO "%s" KERN_INFO "%s", version, version1);#ifdef CARDBUS register_driver(ðerdev_ops); return 0;#else return pci_etherdev_probe(NULL, pci_tbl);#endif}void cleanup_module(void){ struct device *next_dev;#ifdef CARDBUS unregister_driver(ðerdev_ops);#endif /* No need to check MOD_IN_USE, as sys_delete_module() checks. */ while (root_net_dev) { next_dev = ((struct netdev_private *)root_net_dev->priv)->next_module; unregister_netdev(root_net_dev);#ifdef USE_IO release_region(root_net_dev->base_addr, pci_tbl[0].io_size);#else iounmap((char *)(root_net_dev->base_addr));#endif kfree(root_net_dev); root_net_dev = next_dev; }}#elseint fealnx_probe(struct device *dev){ printk(KERN_INFO "%s" KERN_INFO "%s", version, version1); return pci_etherdev_probe(dev, pci_tbl);}#endif /* MODULE *//* * Local variables: * compile-command: "gcc -DMODULE -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -c fealnx.c `[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSIONS`" * SMP-compile-command: "gcc -D__SMP__ -DMODULE -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -c fealnx.c `[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSIONS`" * c-indent-level: 4 * c-basic-offset: 4 * tab-width: 4 * End: */but i got no way to compile (no compiler downloaded, and my conniction is too slow) | /* Keep the ring sizes a power of two for compile efficiency. *//* The compiler will convert <unsigned>'%'<2^N> into a bit mask. *//* Making the Tx ring too large decreases the effectiveness of channel *//* bonding and packet priority. *//* There are no ill effects from too-large receive rings.*/// 88-12-9 modify,// #define TX_RING_SIZE 16// #define RX_RING_SIZE 32#define TX_RING_SIZE 6#define RX_RING_SIZE 12Haha! That driver is 20 years old!You should spend the time getting a compiler on your system, if you want to compile your own drivers. I guess you could make an online linux account somewhere (?) and compile it. |
Should I use memory-mapped files here? | General and Gameplay Programming;Programming | At work we process some massive proprietary-structured binary files. Within the files is a tree structure, with file offsets used as 'pointers.' To read a tree node, I read the entire node from the disk, overlay a struct on top of it, and go from there. To access any child nodes or data requires that another file seek and read be done before continuing. (Obviously, arranging the tree in a certain way can help alleviate this somewhat.)When I was getting my feet wet with it, I was lazy and just mmap()'d the entire file into memory. (The only quirk was I had to fix up file offsets by adding the base of the mmap()'d region to them.) However, not everyone has as much RAM as I do, and these files can get to be quite big. I do not want my program to fail if the user's system is memory taxed and it cannot reserve the necessary memory to map the entire file.My question is: is it possible to use memory-mapped files here while being mindful of one's memory footprint in this case? The worst case is that I'm jumping around quite a bit in a file. The only possible thing I can think of is constantly moving my view of the file around to be only what I'm working on - but internally that has to be seeking around in the file anyway, right? It seems that memory-mapped files seem to be far more useful for firehose-style I/O, where you dump a large amount of data to/from a file all at once. But I do not have much experience with them, and was looking for a second opinion.Thanks! | The behavior of memory mapped files depends on the underlying operating system; and seeing as you're using mmap() that narrows it down to only about a few hundred POSIX compatible OSs. ; Alright, I was referring to the family of memory-mapped functions colloquially as mmap(). My platform is Windows. ; I don't think allocating the entire file into RAM is a good idea if the files can be huge and the clients can lack the necesary amount of it.Is high access speed a requieremnt for this program? Try caching chunks of the file from one offset to another (the size for the cache could be set based on clients RAM availability). Or just access the nodes directly from the file in the hard-disk. ; Assuming a 32-bit NT based kernel, physical or even virtual memory probably isn't going to be a problem, since a memory mapped file is already backed by a file on disk, so the kernel won't bother allocated space in the page file. Your limiting factor is going to be the address space size. With default DLL basing that gives you about the range from 0x2000 0000 to 0x6fff fffff or about 1.25 GB as the maximum size of a file you can process. This is assuming that you don't use libraries that create their own heaps or do any fancy memory management on your own. However, with worse case assumptions I wouldn't want to rely on anything greater than 512 MB mapping properly. |
sports game | Old Archive;Archive | Please check out this site then read then post if you would like to help. Contact me at rathairboy for aim. We want a sports basketball game, we need someone to create the simming of games and Play by play. Just go to this site and see if you can help.http://dynastiesworld.freeforums.org/ | There is a mandatory template for posting in this forum, please follow it. |
Tire grip in top-down car dynamics | Math and Physics;Programming | I'm stuck at simple 2D car physics for my game, i can now calculate velocity of each tire in car's local space, so i know if the car is sliding sideway and the lateral / longtitudal velocity of each wheel axis point, now i need to somehow apply tire friction force that applies tire grip and engine breaking (when it is not accelerating), which would hold the car stable when turning, what is this formula called? i was thinking it must be a rolling friction joint, can someone direct me at some websites that deals with this in some easy way? Regards, Jernej L. | look at the pacejka formula. There is a recent topic about it. ;Quote:Original post by oliiilook at the pacejka formula. There is a recent topic about it. What exactly does pacejka formula do? it appears to be something very complex. [Edited by - Delfi on September 9, 2007 2:15:17 PM]; In a nut shell, Pacejka's formula calculates a longitudinal (forward) and lateral (sideways) force.http://www.racer.nl/reference/pacejka.htmhttp://phors.locost7.info/contents.htm (parts 22, 23, 25, 25, and 29) ; Thats what you need to do, calculate forward and side forces and apply a friction model.For starters you need a 2d physics integrator. Such that you could make a physically accurate pong game. A moveable body (the ball/the car) needs an AddForce(Vector RelativePosition, Vector Force) function. This will both apply the force to the body to generate an acceleration and also apply a torque about the center of mass.Next you need to create 4 force generators for your vehicle body. These will simulate the tires on the ground. So each physics iteration you'll calculate the wheel forces on the vehicle and apply them.Pseudo code for this process:for(int i = 0; i < 4; i++){ Vector wheelforce = new Vector(); //calculate slip vel at wheel point Vector point = wheels.GetRelPos(); Vector sideDir = wheels.GetEffectiveAxel(); Vector sideVel = vehicle.GetVelInDir(point, sideDir); //20.0 is an arbitrary friction constant //a more complex model can be added here Vector sideForce = -sideVel * 20.0f;//oversteer if (superDrift && i > 2) //i>2 for front wheels sideForce *= 2.0f; //if a side forces exists, apply it if (!float.IsNaN(sideForce.length)) wheelforce += sideForce; //add friction model projected onto forwardDir vehicle.AddForceRelPoint(wheelforce, point);}The reason you query the effective axel vector from the wheel, which in my demo is really a joint, is that if the wheel turns for steering. The effective axel for the front wheels will rotate producing a force towards the center of the turning circle. ; I'm using newton physics engine in my game, but i limit vehicle rotation to stay top-down, newton uses a euler integrator (believe it or not... ), but my game is limited to 30 FPS (for easier netsync), which would mean i don't need a integrator in my game for these calculations? So, from what i understand, pacejka formula works like this, you send it the local point velocity of a tire and tire friction, and it returns you "sideways" forces to apply which makes the car magically behave realistically? So how does pacejka work with car acceleration, breaking, and handbrake powerslides and weight distribution?? ;Quote:Original post by Delfi... which would mean i don't need a integrator in my game for these calculations?If you're using newton's integrator then no, you don't need your own integrator. You simply need to calculate these forces per physical simulation step. But of course you need some kind of integrator in this situation (Newton in your case).Also, all integration techniques come down, in the end, to a Euler integration. How you obtain your derivatives is a different story.Quote:Original post by Delfi So how does pacejka work with car acceleration, breaking, and handbrake powerslides and weight distribution??Each wheel has a velocity at the contact patch. This is the velocity you compare to the world velocity to calculate the contact velocity. If it's zero, there is absolutely no slip (regardless of the vehicle speed).So when you want to brake, you simply start reducing the velocity of the contact patch (slow the wheel down). This will cause a difference in the world/contact velocity and induce a force (acceration is this in reverse). If you pull the hand brake the wheels velocity relative to the vehicle is instantly zero'd. So if the vehicle has any velocity, the world/contact velocity will jump up and a huge force will be introduced at the locked wheel. ;Quote:Original post by bzroomQuote:Original post by Delfi... which would mean i don't need a integrator in my game for these calculations?If you're using newton's integrator then no, you don't need your own integrator. You simply need to calculate these forces per physical simulation step. But of course you need some kind of integrator in this situation (Newton in your case).Also, all integration techniques come down, in the end, to a Euler integration. How you obtain your derivatives is a different story.Quote:Original post by Delfi So how does pacejka work with car acceleration, breaking, and handbrake powerslides and weight distribution??Each wheel has a velocity at the contact patch. This is the velocity you compare to the world velocity to calculate the contact velocity. If it's zero, there is absolutely no slip (regardless of the vehicle speed).So when you want to brake, you simply start reducing the velocity of the contact patch (slow the wheel down). This will cause a difference in the world/contact velocity and induce a force (acceration is this in reverse). If you pull the hand brake the wheels velocity relative to the vehicle is instantly zero'd. So if the vehicle has any velocity, the world/contact velocity will jump up and a huge force will be introduced at the locked wheel.So brake only applies longtitudal forces, and not lateral, and this makes it lose control & make it able to do powerslides? ; I like to think of it as two complete separate models. If the wheels on your car could roll in any direction. There would be only one model. But since it can only roll in the longitudinal direction, you have a sideways no roll model, and a forward/reverse roll model. The side no roll model is always the same regardless of input, the only thing that changes is the direction the side force acts when the wheels are turned for steering.The forward/reverse model is the only one that is affected by braking and acceleration. It's not even the model that changes, its the input "relative velocity between tire and ground".If you use a proper static/kinetic friction model this will enable proper power sliding. If you use a faked friction model like I demonstrated, you'll just have sliding. If the relative velocity between the ground and tire is zero (this is true any time you don't hear squealing from your tires, regardless of speed). Then you'll use the static friction model. Once static friction is exceeded, you'll switch to the kinetic friction model for both directions. So once your engine torque breaks the wheels free, there is instantly less friction in both directions. This is a power slide. |
Help implementing the most basic of shaders | Graphics and GPU Programming;Programming | ok ive started to look at making my engine shader based, as opposed to using the fixed function pipeline, after looking through the basic HLSL sample i have established that the id3dxeffect interface is the way to do thisall i am attempting to do at this point is use the shader to apply my world matrix, but using this method it doesnt seem to apply any of the transformsi initialise the effects interface here D3DXCreateEffectFromFile( gD3dDevice, "./Shaders/Basichlsl.fx", NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &g_pEffect, NULL );(ive verified the .fx file loads)so i apply the world matrix g_pEffect->SetMatrix( "g_mWorld", &entityWorld );begin the rendering loop UINT cPasses; UINT iPass;g_pEffect->Begin(&cPasses, 0); for (iPass = 0; iPass < cPasses; iPass++) { g_pEffect->BeginPass(iPass) ;g_pEffect->SetTexture( "g_MeshTexture", Textures); // Render the mesh with the applied technique mesh->DrawSubset(0) ; g_pEffect->EndPass(); } g_pEffect->End() ;but the transformation doesnt seem to be applied at all, could someone please point me in the right direction, i am reading up on how shaders work etc, but without having the most basic of functionality working within my engine i dotn really have anything to work withive also noticed that there doesnt seem to be a way to apply a material to the effects interface, only texturesfor(unsigned int i = 0; i < Mtrls.size(); i++){gD3dDevice->SetMaterial( &Mtrls );gD3dDevice->SetTexture(0, Textures); }thanks alot and please forgive me if im completely missing the point somewhere | You need to call g_pEffect->CommitChanges() after you have made all of you calls to ->Set*() and before you call DrawPrimitive() or DrawIndexedPrimitive(). |
void DrawBitmap(HDC hdcDest, HBITMAP hBitmap, int x, int y) | General and Gameplay Programming;Programming | I'm trying to take the following code from the Jonathan Harbor book and modify the DrawBitmap function so that you can load bitmap from a resource instead of from a file. I would like to do this so you can shuffle multiple images by number without being hampered by a string name. Any suggestions would be most appreciated. I've changed a few things acound and come up with this, but the bitmaps not loading.// Beginning Game Programming// Chapter 4// GameLoop project#include <windows.h>#include <winuser.h>#include <stdio.h>#include <stdlib.h>#include <time.h>#include <algorithm>#include <cmath>#define APPTITLE "Game Loop"//function prototypesLRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM);ATOM MyRegisterClass(HINSTANCE);BOOL InitInstance(HINSTANCE,int);void DrawBitmap(HDC,HBITMAP,int,int);void Game_Init();void Game_Run();void Game_End();//local variablesHWND global_hwnd;HDC global_hdc;HBITMAP hBitmap;HINSTANCE hInstance;//the window event callback functionLRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ global_hwnd = hWnd; global_hdc = GetDC(hWnd);switch (message) {case WM_DESTROY: Game_End();PostQuitMessage(0);break; }return DefWindowProc(hWnd, message, wParam, lParam);}//helper function to set up the window propertiesATOM MyRegisterClass(HINSTANCE hInstance){ //create the window class structure WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX);//fill the struct with info wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WinProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance= hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = APPTITLE; wc.hIconSm = NULL; //set up the window with the class info return RegisterClassEx(&wc);}//helper function to create the window and refresh itBOOL InitInstance(HINSTANCE hInstance, int nCmdShow){ HWND hWnd; //create a new window hWnd = CreateWindow( APPTITLE, //window class APPTITLE, //title bar WS_OVERLAPPEDWINDOW, //window style CW_USEDEFAULT, //x position of window CW_USEDEFAULT, //y position of window 500, //width of the window 400, //height of the window NULL, //parent window NULL, //menu hInstance, //application instance NULL); //window parameters //was there an error creating the window? if (!hWnd) return FALSE; //display the window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE;}//entry point for a Windows programint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTRlpCmdLine, int nCmdShow){ int done = 0;MSG msg;// register the classMyRegisterClass(hInstance); // initialize applicationif (!InitInstance (hInstance, nCmdShow)) return FALSE; //initialize the game Game_Init(); // main message loopwhile (!done){ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { //look for quit message if (msg.message == WM_QUIT) done = 1; //decode and pass messages on to WndProc TranslateMessage(&msg; DispatchMessage(&msg; } //process game loop Game_Run();}return msg.wParam;}void DrawBitmap(HDC hdcDest, HBITMAP hBitmap, int x, int y){ //HBITMAP hBitmap; BITMAP bm;HDC hdcMem; //load the bitmap image //image = (HBITMAP)LoadImage(0,"131",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);hBitmap=LoadBitmap(hInstance, MAKEINTRESOURCE(131)); //read the bitmap's properties GetObject(hBitmap, sizeof(BITMAP), &bm; //create a device context for the bitmap hdcMem = CreateCompatibleDC(global_hdc);SelectObject(hdcMem, hBitmap); //draw the bitmap to the window (bit block transfer) BitBlt( global_hdc, //destination device context x, y,//x,y location on destination bm.bmWidth, bm.bmHeight, //width,height of source bitmap hdcMem, //source bitmap device context 0, 0,//start x,y on source bitmap SRCCOPY); //blit method //delete the device context and bitmap DeleteDC(hdcMem); DeleteObject((HBITMAP)hBitmap);}void Game_Init(){ //initialize the game... //load bitmaps, meshes, textures, sounds, etc. srand(time(NULL));}void Game_Run(){ //this is called once every frame //do not include your own loop here! int x[]= {25,50,100,125,150,175}; int y[]= {25,50,100,125,150,175};int i; RECT rect;//int deck[]={50,150,250,350,450};//std::random_shuffle(deck, deck+5); GetClientRect(global_hwnd, ▭); //if (rect.right > 0) //{for(i=0; i<6; ++i){ // x = rand() % (rect.right - rect.left);// y = rand() % (rect.bottom - rect.top); DrawBitmap(global_hdc,hBitmap, x, y);} //}}void Game_End(){} | Moving. ; This should do the trick:LoadImage( 0, MAKEINTRESOURCE( 131 ), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR );If 131 is really the resource define value for the bitmap. You should rather insert the actual define though. ; That didn't seem to make any difference. Here's the way he had it originally. I'm trying to get rid of all this "char* filename" stuff in the function definition so that I can call the bitmap by a number rather than "c.bmp" the file name. void DrawBitmap(HDC hdcDest, char *filename, int x, int y){ HBITMAP image; BITMAP bm;HDC hdcMem; //load the bitmap image image = (void*)LoadImage(0,"c.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE); //read the bitmap's properties GetObject(image, sizeof(BITMAP), &bm; //create a device context for the bitmap hdcMem = CreateCompatibleDC(global_hdc);SelectObject(hdcMem, image); //draw the bitmap to the window (bit block transfer) BitBlt( global_hdc, //destination device context x, y,//x,y location on destination bm.bmWidth, bm.bmHeight, //width,height of source bitmap hdcMem, //source bitmap device context 0, 0,//start x,y on source bitmap SRCCOPY); //blit method //delete the device context and bitmap DeleteDC(hdcMem); DeleteObject((HBITMAP)image);} ; My bad, that's what i get when reading too fast:For loading anything from resources you need to provide the HINSTANCE handle which you get passed in the WinMain function:HBITMAP hbm = (HBITMAP)LoadImage( hInstance, MAKEINTRESOURCE( IDB_BITMAP ), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR ); ; That didn't seem to work either. Here is the unaltered source code for the entire program. Copy and paste into your complier. Where it says "c.bmp" just use some small bitmap. You might have to put the address of the bitmap in there too then it works fine. If you can see what you can do to change it to use an interger resource rather than a file name, it would be most appreciated.// Beginning Game Programming// Chapter 4// GameLoop project#include <windows.h>#include <winuser.h>#include <stdio.h>#include <stdlib.h>#include <time.h>#define APPTITLE "Game Loop"//function prototypesLRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM);ATOM MyRegisterClass(HINSTANCE);BOOL InitInstance(HINSTANCE,int);void DrawBitmap(HDC,char*,int,int);void Game_Init();void Game_Run();void Game_End();//local variablesHWND global_hwnd;HDC global_hdc;//the window event callback functionLRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ global_hwnd = hWnd; global_hdc = GetDC(hWnd);switch (message) {case WM_DESTROY: Game_End();PostQuitMessage(0);break; }return DefWindowProc(hWnd, message, wParam, lParam);}//helper function to set up the window propertiesATOM MyRegisterClass(HINSTANCE hInstance){ //create the window class structure WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX);//fill the struct with info wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WinProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance= hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = APPTITLE; wc.hIconSm = NULL; //set up the window with the class info return RegisterClassEx(&wc);}//helper function to create the window and refresh itBOOL InitInstance(HINSTANCE hInstance, int nCmdShow){ HWND hWnd; //create a new window hWnd = CreateWindow( APPTITLE, //window class APPTITLE, //title bar WS_OVERLAPPEDWINDOW, //window style CW_USEDEFAULT, //x position of window CW_USEDEFAULT, //y position of window 500, //width of the window 400, //height of the window NULL, //parent window NULL, //menu hInstance, //application instance NULL); //window parameters //was there an error creating the window? if (!hWnd) return FALSE; //display the window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE;}//entry point for a Windows programint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTRlpCmdLine, int nCmdShow){ int done = 0;MSG msg;// register the classMyRegisterClass(hInstance); // initialize applicationif (!InitInstance (hInstance, nCmdShow)) return FALSE; //initialize the game Game_Init(); // main message loopwhile (!done){ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { //look for quit message if (msg.message == WM_QUIT) done = 1; //decode and pass messages on to WndProc TranslateMessage(&msg; DispatchMessage(&msg; } //process game loop Game_Run();}return msg.wParam;}void DrawBitmap(HDC hdcDest, char *filename, int x, int y){ HBITMAP image; BITMAP bm;HDC hdcMem; //load the bitmap image image = (HBITMAP)LoadImage(0,"c.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE); //read the bitmap's properties GetObject(image, sizeof(BITMAP), &bm; //create a device context for the bitmap hdcMem = CreateCompatibleDC(global_hdc);SelectObject(hdcMem, image); //draw the bitmap to the window (bit block transfer) BitBlt( global_hdc, //destination device context x, y,//x,y location on destination bm.bmWidth, bm.bmHeight, //width,height of source bitmap hdcMem, //source bitmap device context 0, 0,//start x,y on source bitmap SRCCOPY); //blit method //delete the device context and bitmap DeleteDC(hdcMem); DeleteObject((HBITMAP)image);}void Game_Init(){ //initialize the game... //load bitmaps, meshes, textures, sounds, etc. srand(time(NULL));}void Game_Run(){ //this is called once every frame //do not include your own loop here!int x = 0, y = 0; RECT rect; GetClientRect(global_hwnd, ▭); if (rect.right > 0) { x = rand() % (rect.right - rect.left); y = rand() % (rect.bottom - rect.top); DrawBitmap(global_hdc, "c.bmp", x, y); }}void Game_End(){}; Ok, here's what i've done:1)Added a new resource, choose Bitmap, Import a file (.bmp)I kept the predefined name for the resource (IDB_BITMAP1)2)Added #include "resource".h3)Modified the line with LoadImage to:image = (HBITMAP)LoadImage( GetModuleHandle( NULL ),MAKEINTRESOURCE( IDB_BITMAP1 ), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR );This worked for me. Note that GetModuleHandle( NULL ) gives you the HINSTANCE handle for the starting process. Resources are always loaded from a certain instance. Note that the HMODULE you get from GetModuleHandle is castable to HINSTANCE. You could also pass the HINSTANCE parameter you get in your WinMain.I've used Visual Studio 2003, if you have a non Microsoft IDE the process to add the resource may vary. ;Quote:Original post by EndurionNote that GetModuleHandle( NULL ) gives you the HINSTANCE handle for the starting process. Resources are always loaded from a certain instance. Note that the HMODULE you get from GetModuleHandle is castable to HINSTANCE. You could also pass the HINSTANCE parameter you get in your WinMain.Minor point: It's definitely worthwhile getting into the habbit of using the HINSTANCE from WinMain. Because if you use GetModuleHandle(NULL), you'll run into issues if your resources are in a DLL (Since GetModuleHandle(NULL) gives you the EXE handle, not the DLL handle). ; Are you compiling a 32-bit or 64-bit executable?I have a program that has been running for years. Porting to 64-bits, none of the code using bitmaps works. The GetObject call really crashes the program for me. ; That worked! Thanks so much. Also, I'm using Visual C++ 2005 6.0 |
Freepascal 2.2.0 is released! | Your Announcements;Community | Hi guys :)I am relaying the message I got from the freepascal elists:Quote:"The Free Pascal Compiler team is pleased to announce the release of FPC2.2.0!An overview of most changes is available below, but some highlights are:* Architectures: PowerPC/64 and ARM support* Platforms: Windows x64, Windows CE, Mac OS X/Intel, Game BoyAdvance, and Game Boy DS support* Linker: fast and lean internal linker for Windows platforms* Debugging: Dwarf support and the ability to automatically fillvariables with several values to more easily detect uninitialised uses* Language: support for interface delegation, bit packed records andarrays and support for COM/OLE variants and dispinterfaces* Infrastructure: better variants support, multiple resource filessupport, widestrings are COM/OLE compatible on Windows, improveddatabase supportDownloads are available at http://www.freepascal.org/download.varEnjoy!The Free Pascal Compiler Team******************************************************************************What's New in 2.2.0******************************************************************************Free Pascal 2.2.0 contains a lot of bug-fixes and new features. The work onFree Pascal 2.2.0 started halfway during the year 2005. A lot has been improvedsince then.Please also see http://wiki.freepascal.org/User_Changes_2.2.0 for a listof changes which may affect the behaviour of previously working code, andhow to cope with these changes.Platforms:* New platform: Win64. FPC is the first open source compiler for 64-bitWindows operating systems.* New processor architecture: 64-bit PowerPC* PowerPC/64 support for Linux* Mac OS X on Intel (i386) is now supported* New platform: Windows CE (Windows Mobile)* New platform: Nintendo Game Boy Advance* New platform: Nintendo DS* Native support for ARM-platform* GO32V2 DOS platform got a long needed updateCompiler:* Internal linker for win32, win64 and wince, resulting in smallerexecutables, less memory used during compilation, and faster compiletimes for programs using large frameworks like for example the LazarusComponent Library.* Generics (experimental)* Bit packed arrays and records* Resourcestrings can now be smartlinked, resulting in smaller executables* Multiple resource files support* pointer[low..high] syntax to pass C-style pointer arrays to proceduresusing open arrays* Interface delegation* Proper safecall implementation* Wide strings are COM/OLE compatible on Windows* Added several speed optimisations, for example:* Compiler can omit stack frames (x86 and ARM)* Compiler can store records in registers* Tail recursion expansion* Register renaming optimizations* Improved optimizer for ARM CPU* Compiler can initialise local variables, function results, and "out"parameters with several values (command line parameters -gt till -gtttt)to help find uses of uninitialised variables* Compiler can now properly deal with paths > 255 characters in all cases* Dwarf debug format support* Reduced memory usage during compilation* Lot of small bugs and compatibility fixesRTL:* Heap uses less memory* Improved variants support* Improved currency support* Exception handling can be used without SysUtils unit* Lot of small bug and compatibility fixesFCL:* Improved database support* The obsolete sqlitedataset, interbase, fpodbc, ddg, mysqldb3 and mysqldb4units are removed* Lot of small bugs and compatibility fixesPackages:* Added a new fppkg package manager* Improved database support* Added Delphi compatible RichEdit unit* Apple universal interfaces updated to r204 of the common FPC/GPC/MWinterfaces* Lot of small bugs and compatibility fixesFree Vision:* Now uses resourcestringsIDE:* Evaluate window* Improved HTML rendering* Improved xterm support* Small bug fixesMisc:* Improved documentation* Better cross compilation supportFor a detailed list of reported bugs that are fixed in this release see thebugtracker report at http://www.freepascal.org/mantis/changelog_page.php_______________________________________________fpc-pascal maillist - [email protected]://lists.freepascal.org/mailman/listinfo/fpc-pascal" | |
Choice in Games | Game Design and Theory;Game Design | I'll be using Bioshock as an example, but I haven't played much more than 40 minutes into it A.T.M so don't worry, I can't reveal too much.I've been thinking a lot about the choices we have in games lately, as you may already know. But after playing Bioshock and reading some of the articles posted about the choice between whether you harvest the little girls or not, it got me thinking about why we do what we do in games and how it relates to who we actually are. When it all boils down, the answer on everyones lips seems to be "it doesn't really matter, it's a videogame". But just because it's a game, does that make it O.K to kill little girls for you to become stronger?The game really does look at the human response quite a bit throughout the experience. Truthfully, I havent finished the game yet, so I can't say just how much at the moment. But from what I've seen, the game also seems to be a -dig- at the human response. For instance, the fact that the entire city is crawling with insane people who have genetically altered themselves to be that way. They kill everyone and anything in their way just so they can splice themselves up some more. And whats the first thing you do when you get down there, after seeing the chaos? You splice yourself up with some electro power.Depending on whether the user chooses to splice themselves more is up to them, building your stats up to become stronger. Quite frankly I was a little disappointed to hear I wouldn't go insane from splicing myself too much, but what are you gonna do. What comes in to play next are the little sisters, the lifeblood of Rapture. The things you want. The things you need! Any experienced FPS player will gladly harvest the small girls in order to obtain more ADAM. "Hell yeah, more ADAM means more weapons!". So, of course we will. But after watching a little girl squirm for her life between your hands and begging you not to kill her, harvesting her seems like a pretty savage response. Where are the limits?Although the choice in Bioshock to harvest the girls habours different gameplay effects, the choice merely makes you pick one or the other to get a different ending. You can harvest the girls, get a lot more powerful and the game is a ton easier. Or you can let them go, get a different ending and pat yourself on the back for not killing small children. That's what people think of. They don't think about the fact that they are killing a small girl so they can become stronger and succeed in their overall mission; this is what I was referencing before, the poke at the human response to the current circumstances. Even though you are in a world where everyone is insane, you still follow suit.I think in order to implement a real kind of choice for a player, then the choices need to have equal pro's and con's; both should excel and hinder you in some way. This will force a choice from the player that isn't derived from the necessity of success; instead of the user basing their choices on statistics and how the choice will effect their game, they will base it on personal choice, what they want to do. This reveals quite a bit about the specific user that an engine could use to it's advantage to change gameplay and the way objects or characters appear to the player. Say if you choose to harvest all the little girls and you become all nicely spliced up, then after a while whenever you see one of their tunnels your player may walk slower and look towards it, hindering your view of the next room. Maybe everything but the tunnel will go a little blurry.I think that the usual "good response = good story and happy characters vs bad response = stronger character but alternate ending" is just not going to cut it. It's too simplified and you pretty much are telling the player to be bad so they can become stronger. There needs to be an implementation of emotion somehow.Discuss if you like. | Quote:Original post by skribble_styleI think that the usual "good response = good story and happy characters vs bad response = stronger character but alternate ending" is just not going to cut it. It's too simplified and you pretty much are telling the player to be bad so they can become stronger. There needs to be an implementation of emotion somehow.I don't really follow. The emotion is in the player. The choice offered seems fairly balanced, if you take emotion into account. Given the choice between "good behavior = power + good story" and "bad behavior = power + bad story," everyone would choose to be good. The "interesting" part is when you use power as a reward to tempt the player to be "bad." It makes it a viable choice. And you can still finish the game if you're "good," right?I haven't been paying much attention to this game (it certainly isn't going to run on anything I own), but based on your description it sounds pretty damn disturbing. But it also sounds very deliberately disturbing... and whether that's some sort of social commentary or just an exercise in making players queasy, it wouldn't be as effective if the choices were more equal.Edit for further tangential thoughts:As a species, we've evolved the ability to empathize with other people. As a side-effect, we sometimes end up empathizing with representations of people, even when we know they're not real. That's what makes fiction work. But it doesn't mean we can't tell the difference. Just because you'd kill a bunch of girl-representations in a videogame to get some equally imaginary weapons doesn't mean you're a danger to real little girls.So yes, that makes it okay. But you don't have to do it if you don't want to. ; 'It doesn't really matter, it's just a videogame.'I had a lot more written, but it wasn't terribly coherent. Basically, RPGs lack the content to implement much more and they can't be totally balanced or the decision is meaningless (since it doesn't effect gameplay). And I think that faced with the in-game decision as simple as they are, the visual/plot representation of the gameplay choice is/should be meaningless in your decision making process. ; But that's what I mean.The emotion is in the player, yes, but they are not using it because of the dynamics of what video games are. Tempting the player with power to become evil will just make the player become evil. The reason people like to play video games is the existential feeling of succession; we are driven to advance, that is life. Video games feed off this, knowing that we simply want to win to make our character advance, hence the reason MMO's are so popular even though most lack in substance. It is this reason that I think choice in games should be equal between good and bad, to reveal a "true" choice from the player. Lets go to Bioshock again. FYI, once again, going insane is not part of the gameplay. Say you use too many plasmids and splice yourself so much that you begin to lose control of certain aspects of gameplay, but you became more powerful than you ever could have before. You would have less control over your movement, breathing, posture, aiming and attention, but you could destroy everyone a lot more easily. However if you don't use plasmids, your accuracy increases 10 fold, your relations with characters are better, your attention to detail may increase; adding slight glows around objects you should pay attention to, making them more obvious to the eye. A mix between splicing and normality will give you the best of both worlds etc. I just think that players should be given an EQUAL choice between good and bad, having both selections help and hinder you in gameplay and story.This is where the player has to decide for themselves, not for the game. Should I kill this little girl and become more insanely powerful, or should I let her go and increase my skills the different way, which will make me as powerful, just in a different way? It's the difference between a choice for your statistics and a choice for your morals. ; Except there is no choice for morals. It's a (single player) video game. Whatever affect your decision makes is moot as soon as the program closes. ; There's a funny thing about emotions... no people will have the exact same reaction to a situation, and for the same reasons. Making choices that bring about a emotional response is great, it gives more to the game, but you can't expect everyone to feel bad because they killed the little girl... everyone is different. All you can hope to do is put the material out there... how people take is is completely up to them. ; Not totally true. Although I do agree that the response from each player is totally different, I don't think that you can pull an emotional response from one player and not from another. I think if certain method were placed within a games engine to process information that was user specific, then you could alter the games engine to facilitate this.Alas, I've also thought of the power of persuasion the game would need to implement for the player to really be swayed one way or the other. A circumstance which the player needs to really think about, an element which is not yet integrated into any game we've seen. I believe the engine needs to take the player experience into account; what they look at, how frantic they get, their weapon of choice, how often they sneak, whether or not they obtain certain items in certain areas etc. These elements need to be studied by the engine in real-time and transfered into data that is implemented into game-play on the fly.You can tell a lot about a player from a weapon that they favor. Shot-gunners love to run around blasting, occasionally hiding at a corner for a few seconds and then leaving to run and gun again. A pistol user will focus on accuracy and will more often than not go for head-shots. A machine gunner favors cover and peaks to take short bursts, occasionally switching positions for a better view.Tons of statistics can be taken from such simple studies and could be added into the engine, creating a user defined world without them even knowing it. This, I believe, would create a more immersive and personalized experience. It's sketchy at best, I know. But it's an idea! ; I just finished the game a few days ago, and I never harvested a single Little Sister. I know for a fact that my real-world sense of morals kept me from doing so. The great thing about this is that the game actually rewards you if you avoid the instant gratification of 160 ADAM (the reward for harvesting/killing a girl). If you rescue a girl, you only get 80 ADAM, but you get a huge bonus a little bit later in the level. You'll eventually find a teddy bear stuffed with 200 ADAM and a few other nice bonuses like health packs and new plasmids (i.e. spells). This happens every three sisters you rescue, IIRC. So the true "Harvest vs. Rescue Little Sisters in Bioshock" equation is...160 ADAM x 3 Little Sisters + Bad ending + Feel bad = 80 ADAM x 3 Little Sisters + 200 ADAM + Plasmid + health pack + Good ending + Feel goodIgnoring the different story and the player's emotions (or lack thereof), you're looking at 480 ADAM vs. 440 ADAM + other good items. So the real question is will you be evil and take the quick reward, or be good and wait patiently for a potentially better reward? Its not quite as simple as killing hookers in GTA, and the game is better for it.- Mike ;Quote:Original post by ortorinThere's a funny thing about emotions... no people will have the exact same reaction to a situation, and for the same reasons. Making choices that bring about a emotional response is great, it gives more to the game, but you can't expect everyone to feel bad because they killed the little girl... everyone is different. All you can hope to do is put the material out there... how people take is is completely up to them.Not actually the case, I'll share what you can do at some point in the future.This is the big problem for story-games, and what makes them inferior to movies and novels as a storytelling medium.MGS and Final Fantasy give the players very few choices, and the choices they made were insignificant, and that is why they are so immersive. Movies and novels have no choice - no choice means optimum immersion capability.Well almost...Edit: scribble style - we are thinking on the same lines... what do you think is the key to it? I've spent 6 months figuring it out and pretty certain I have the answer. ; I think games have the potential to be more immersive than other media, precisely because of the potential for player choice. I think they fail because players continually bump into reminders that it's "just a game" -- including the inability to make the choices they want to make. |
Real-Time Strategy terrain fetures and buidling questions | Graphics and GPU Programming;Programming | I am strating to make my terrain map for my RTS. natural terrain features 1)hills - mounts2)cliffs3)rivers - streams4)ponds – oceans5)Plato6)Craters7)vegetationMan Mad features1)roads2)building 3)rubbishFirst question is should I use HeightMap? If yes then what are the difernt ways of making a hieght map.Second Question is textureing the map should I use one texture or tiles with tranpaerncy?Should I use some prerender terrain were the player cant go and dynamic terrain were the player can go?What are the methods Starcraft II uses? Or any other recent RTS game?Using "Programming an RTS game with Direct3D" by Carl GranbergI am just not sure his way is the best way because the examples dont look up to date. | I'm not entirely sure if this is the correct section, but anyway.Quote:Original post by kingpinzsI am strating to make my terrain map for my RTS. First question is should I use HeightMap? If yes then what are the difernt ways of making a hieght map.That's really up to yourself. It's a lot easier if you dont use them. Units standing on a hill have an advantage over units on lower ground. They may shoot further or see more, than other units. Units going down a hill might move faster or, in case they go up, move slower. Are you ready (able?) to implement such features? I mean, creating an rts is a lot of work. Perhaps you should add the basics first and then add things like height. Quote:Original post by kingpinzsSecond Question is textureing the map should I use one texture or tiles with tranpaerncy?There are lots of ways to texture a terrain, each with their own benefits. There is no good or bad way. Well there actually are bad ways, but really, pick one you're most comfortable with. Quote:Original post by kingpinzsShould I use some prerender terrain were the player cant go and dynamic terrain were the player can go?What are the methods Starcraft II uses? Or any other recent RTS game?I am just not sure his way is the best way because the examples dont look up to date.I can't say for sure of course, as SC II has not been released yet, but I'd imagine they have some fancy 3d map editor which they use to build the entire map. It would probably include tools to 'paint' the various textures on the map, as well as tools to mark certain sections of the terrain as obstacle. With that said, it's never a bad thing to look at how the 'big guys' are doing things. But keep in mind, in this case, there's a whole team of people working on SC II (25 iirc from an interview), and there's only one of you. Tbh, it sounds as if you're doing a 25 man project.; I am thincking about using texture splating to apply my textures to the terain. I am just not sure that is the best way to make the the edge of the textures to blend with the other types of textures. ;Quote:Original post by kingpinzsI am thincking about using texture splating to apply my textures to the terain. I am just not sure that is the best way to make the the edge of the textures to blend with the other types of textures.If you're using texture splatting then the edges should be able to easily blend together just by the layout on your alpha map. As long as your alpha map doesn't have hard edges then you'll be fine. ; What are some better ways of smoothing out the terrain then what I am doing below? void HEIGHTMAP::SmoothTerrain(){//Create temporary heightmapfloat *hm = new float[m_size.x * m_size.y];memset(hm, 0, sizeof(float) * m_size.x * m_size.y);for(int y=0;y<m_size.y;y++)for(int x=0;x<m_size.x;x++){float totalHeight = 0.0f;int noNodes = 0;for(int y1=y-1;y1<=y+1;y1++)for(int x1=x-1;x1<=x+1;x1++)if(x1 >= 0 && x1 < m_size.x && y1 >= 0 && y1 < m_size.y){totalHeight += m_pHeightMap[x1 + y1 * m_size.x];noNodes++;}hm[x + y * m_size.x] = totalHeight / (float)noNodes;}//Replace old heightmap with smoothed heightmapdelete [] m_pHeightMap;m_pHeightMap = hm;CreateParticles();Sleep(500);} |
Laptor WAN Access 'On the Go'?? | GDNet Lounge;Community | I saw this commercial the other day saying that you can get a wireless card which gives you internet access anywhere. I'm trying to figure out what provider it was that offers this service (I was half asleep when I saw the commercial) I've been looking for something like this for years!! I'm the type of person that is always traveling on buses, train.. and I go to the airport at least once a month. Does anyone know the best way to get internet access on my laptop in all those places without using the hot spots (which usually cost a fee)?? I've heard that another way to accomplish this is to: use your cell phone for internet anywhere by connecting your cell phone to your computer. Has anyone accomplished this feat?? | Most major cell providers offer data plans for use with a laptop. For example:Verizon Wireless BroadbandCingular Wireless BroadbandSprint Wireless Broadband; The second thing you mentioned -- connecting via your cell phone -- is called tethering. ; I've used both tethering and ExpressCard EVDO cards.It's quite fast, sure, but the pricing is insane. If you live in Canada, however, you may be interested in something like Rogers Portable Internet, which seems to use a wonky CDMA transfer system and has okay speed.Canadian data transfer rates are completely unacceptable (the best my provider can offer is $100/mo for 250MB versus Verizon's $30/mo for 8GB). ; Yes I do live in Canada and 100 dollars / month seems insanity. ;Quote:Original post by RavuyaI've used both tethering and ExpressCard EVDO cards.It's quite fast, sure, but the pricing is insane. If you live in Canada, however, you may be interested in something like Rogers Portable Internet, which seems to use a wonky CDMA transfer system and has okay speed.Canadian data transfer rates are completely unacceptable (the best my provider can offer is $100/mo for 250MB versus Verizon's $30/mo for 8GB).I heard the rogers thing only works close to the downtowns of the listed cities. ; I asked a guy in my class about connecting his Blackberry to his laptop and streaming Internet data to it. He said it costs $12 dollars (CAN) per MB so that's like US$10 per MB. That's a terrible deal. So I think I'll just wait for the prices to come down. ; Write your MP about looking into the pricing. I did. |
Java, reading and writing XML, which api? | General and Gameplay Programming;Programming | I need to read and write xml files, I'm after a tree-like hierchical approach.I've been looking at the java site which list lots of apis to choose from, I'm not sure which one to use.egJAXP, JAXB, JDOM, DOM4J ....thx | DOM is what you are looking for.It stands for "Document Object Model".It interprets a XML file like a tree,every XML element becomes a node,the elements which lie inside a node become its children etc.. The DOM mechanism is a subset of the JAXP API.http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/TOC.htmlHere,on this page, the link "Part III: XML and the Document Object Model (DOM)" leads to useful pages which could be of your interest. ; I'd suggest to forget the ugly and bloated standard apis altogether and just use NanoXML lite which consists of only one simple class. |
Re-inventing the Wheel, or Mediocre Solutions to Already Solved Problems? | General and Gameplay Programming;Programming | Re-inventing the Wheel, or Mediocre Solutions to Already Solved Problems?While doing my strategy game Imperator Mundi and other projects I have repeatedly encountered the issue of how to select a random result froma set of possible outcomes, where the possible outcomes have different weights and are exclusive.Typically the number of outcomes and their weights are changing all the time.I have used a simple to implement solution that uses C++ multimap:class CProbableEvents{float TotalWeight;std::multimap<float, int> WeightEventMap;public: CProbableEvents() : TotalWeight(0) {} void AddEvent(float gProbability, int gIdentifier) {TotalWeight+=gProbability;WeightEventMap.insert( std::make_pair<float,int>(TotalWeight,gIdentifier) ); } int GetRandomEvent(int gValueToReturnIfNotFound=-1) { float tHit=TotalWeight*GetRandomValueFromZeroToOne(); std::multimap<float,int>::iterator tCheckI=WeightEventMap.lower_bound(tHit); if( tCheckI!=WeightEventMap.end() ) { return tCheckI->second; } else { return gValueToReturnIfNotFound; } }};The above code needs a decent GetRandomValueFromZeroToOne() function,and can be used for example like this:CProbableEvents tCombatResult;tCombatResult.AddEvent( tDestructionVote, E_UNIT_IS_DESTROYED ); tCombatResult.AddEvent( tDamageVote, E_UNIT_IS_DAMAGED ); tCombatResult.AddEvent( tUnharmedVote, E_UNIT_IS_UNHARMED ); int tResult=tCombatResult.GetRandomEvent();if( tResult==E_UNIT_IS_DESTROYED ) RemoveUnit();else ApplyPhaseResults( tResult );// ...Comments:-Custom solutions should be used in places where one cannot afford to consume time and memory as this class does....-Dealing extreme weight values...-I have done more complex systems in the problem domain code itself,but it would be better to implement some of them in a reusable form also...-I suspect that my current GetRandomValueFromZeroToOne() is not very good...What type of solutions do you have to these issues?Suggestions?-Osmo Suvisaariwww.waspgames.com | This looks like a pretty good solution to me. The only other solution I've thought of for this sort of problem is using a linear array or list instead of a map, and storing the probability of events along with the events in the array. Then given the random number between 0 and totalWeight, iterate down the array until the corresponding event is found (adding up the probabilities of each event as they are iterated over, until the cumulative probability is greater than the random number). This is slower for selecting an event, since it is O(n) while the map solution is O(log(n)), but it can be O(1) to add, remove, or change the probability of an event, while the map does those operations in O(log(n)) time. A map also has higher overhead than an array.As long as the number of events is small, it doesn't really matter that much.Extreme weights work the same as any other weights, unless you mean values that are so extreme that there isn't enough floating point accuracy. In that case the odds of an unlikely event happening where already extremely low anyway.Your selection of a random number between 0 and 1 is a separate problem. The usual solution is to use a good pseudorandom number generator to select a number in the range [0,MAX_RANDOM) and divide by MAX_RANDOM.To make things reusable, you could try to design the system to allow a hierarchy of events, and then add and remove entire groups of events in a hierarchical manner. ; You don't seem to have a way to remove outcomes or modify the weights of outcomes once they have been inserted. Depending on how dynamic your weights really are and how many outcomes there are (and of course, whether this REALLY uses up all that much CPU power and is therefore worth optimising), I think you can perform any update in log(n) time, where n=number of outcomes.It works something like this: you have a tree along the lines of:struct tree_node{ float total_weight; tree *left, *right; outcome *outcome;};Obviously this structure isn't really perfect because it includes data for both the tree nodes and leaves, but that's C++ for you. Then you can update the tree by walking from bottom to top altering the weight. Similarly you can add or remove events this way. Of course, to really make it work you'd have to use a red-black tree or something similar to guarantee log(n) behaviour, but you get the idea. The reason I'm only outlining this is it's not trivial to implement because C++ doesn't let you add additional data to the nodes of the trees it uses to implement std::set/map/multimap etc., so you have to do the whole thing by hand. In fact, it's a slightly curious situation because you know that your top-down traversal of the tree to find the outcome for a given random variable output you know the weighted probability at each node, and you can adjust your tree to improve the amortised time accordingly. That's a whole nother thing though. The thing is it's only really worth it if the number of updates to your probabilities/outcomes are on the same order as the number of queries, because if either massively outweighs the other a complete recalculation will actually be more efficient.Anyway, it's only worth it at all if you really need the CPU cycles. If you really do, good luck with that; it won't be fun to write.[/source] ; Actually, for the thing ZQJ describes, keeping the tree balanced isn't that hard. With normal binary trees balancing is difficult because the order of elements is important. For this probability tree, the order is irrelevant. The structure more closely resembles a heap, and it can be kept balanced in the same way as a binary heap (and it can also be stored in an array like a binary heap, so there is no need to maintain pointers to the children).Now I submit that with some clever implementation it should be possible to store the non-leaf nodes of the tree as an array of floats, and the leaf nodes as an array of ints. Or if you're sure about the sizes of data types they could all be stored in a single array (and this may simplify things a bit).Anyway, adding and removing elements would be just like a balanced binary heap, with elements to be removed swapped with the last element before removing, and the updates being fairly similiar (a little different, since with the probability tree a few changes need to be propagated all the way up the tree). Similiarly a newly added element is placed at the end of the array. These operations could also require moving around another element, since the leaves and non-leaves of the probability tree have very different purposes, unlike a heap's nodes. ; Thank you, good points.About modifiability:In some cases I have just re-created the data many times.Speed has not been an issue in this brute-force approach.However, a good way to modify the weights would be great.Using mostly STL containers and very few pointers, I have made a relatively small amount of bugs in this project:Now is time to summon the bugs, creating a custom tree with complex pointer logic... [cool] ;Quote:Original post by VorpyThis looks like a pretty good solution to me. The only other solution I've thought of for this sort of problem is using a linear array or list instead of a map, and storing the probability of events along with the events in the array. Then given the random number between 0 and totalWeight, iterate down the array until the corresponding event is found (adding up the probabilities of each event as they are iterated over, until the cumulative probability is greater than the random number). This is slower for selecting an event, since it is O(n) while the map solution is O(log(n)), but it can be O(1) to add, remove, or change the probability of an event, while the map does those operations in O(log(n)) time. A map also has higher overhead than an array.I would personally recommend using a linear array, in the way that Vorpy already suggested, the only thing I would have to add is that using a linear array can actually be O(log(n)) to find the event (the same as the map, and the same as the best-case for a binary tree) if you use bisection. Unfortunately you get O(n) performance for operations that modify the probabilities, but if that is rare it doesn't really matter.As in the original posted code for AddEvent you store the following pairs in the array: (cummulative weight, event ID). When it's time to pull up an event you do the following (sorry for the Pascal code):function GetRandomEvent(tHit: Float): Integer;var L, H: Integer; // the range of array indiced where our event might be M: Integer;// temporary index (mid-point between L and H)begin L := 1; // set L to the start of the array H := Length(WeightEventMap); // set H to the end of the array while (H-L)>1 do // iterate till we have found our (one) event begin M := (L+H) div 2; // find the middle point between L and H if (WeightEventMap[M].Weight=tHit) // are we extremely lucky (have we inadvertently stumbled accross the event that we are looking for)? thenbegin H := M; // guess we are lucky, set H (the return value) to M, Break; // and break out of the loopend; if (WeightEventMap[M].Weight<tHit) // compare the value at the mid-point (M) to the target value (tHit) thenL := M // raise the lower bound (our event must have its index higher than M) elseH := M; // lower the upper bound (our event must have its index lower than M) end; GetRandomEvent := WeightEventMap[H].EventID; // return the first event that has Weight>=tHit (that event has index H after the above loop was executed)end;As you can see, the above code is relatively simple (simpler than the tree balancing code you would need to guarantee O(log(n)) performance of the binary tree anyway), and has minimal overhead (no complex data structures, and no classes), while performing better than (or atleast as good as) either the map or the tree. However:Quote:Original post by VorpyAs long as the number of events is small, it doesn't really matter that much.This is also very true. If your number of events is small then it really doesn't matter if you just use simple linear search (like in the original code), since the overhead of anything else can end up being much greater than the time to execute the linear search! Find out your requirements first.In spite of the above, if it were me I would still use bisection for completeness sake, since unlike most solutions bisection has virtually no overhead. ; OP: If you reject zero probabilities in AddEvent(), you don't need a multimap, just a plain old map - because every "cumulative weight" is a distinct value. I would recommend sticking with integer weighting values, though, to avoid the usual problems with FP arithmetic. I also object rather strongly to some of your naming conventions (lowercase g prefix for a *member function parameter*? what?)Oh, not to mention, you *can't* get a .end() result from lower_bound here (barring some multithreading bug, etc.), given a correct RNG. You're simply not going to generate a value equal to or greater than the last value in the map.EDIT: Oh, of course that is a problem if the map is empty ;) To fix that, you can simply require the first option to be added in the constructor.template <typename T>struct WeightedDie { typedef std::map<int, T> mapping_t; WeightedDie(int weight, const T& result) : TotalWeight(weight) { if (weight == 0) { throw std::runtime_error("first event must be possible"); } resultMapping[totalWeight] = result; } void addSide(int weight, const T& result) { if (weight == 0) { return; } // We can just use operator[] to insert here. But you should know that // the whole reason for using std::make_pair (instead of the std::pair // constructor) is to *avoid* typing the template parameters explicitly. totalWeight += weight; resultMapping[totalWeight] = result; } const T& roll() const { int rnd = std::rand() % totalWeight; // for now... mapping_t::iterator it = resultMapping.lower_bound(rnd); assert (it != resultMapping.end()); return it->second; } private: int totalWeight; mapping_t resultMapping;};Quote:Original post by Devilogicif you use bisection. Unfortunately you get O(n) performance for operations that modify the probabilities, but if that is rare it doesn't really matter.As in the original posted code for AddEvent you store the following pairs in the array: (cummulative weight, event ID). When it's time to pull up an event you do the following (sorry for the Pascal code):*** Source Snippet Removed ***You don't have to do this yourself: the standard C++ library offers std::lower_bound(), which basically does the same thing for general sorted containers as the map lower_bound member function. ; So what methods have we come up with...Storing cumulative weights in a tree, O(logn) selection, recreate the whole tree in O(nlogn) time for most changes.Storing weights in an array, O(n) selection, O(1) changes, can be sorted in O(nlogn) time to improve average performance by putting more likely outcomes at the front of the array (improvement depends on how unbalanced the weights are)Storing cumulative weights in an array, O(logn) selection, O(n) changesCustom balanced binary heap-like thing that stores weights and cumulative weights, O(logn) selection, O(logn) changes, requires twice as much memory as the other array-based methods, more overheard for selection than cumulative weights in array methodAnd finally, one more method I've thought of: Create a table of outcomes and pick out a random entry. Outcomes are entered into the table a number of times proportional to their weight. Implemented with a vector or deque. O(1) selection. Update complexity depends on the ratios between the weights and the resolution of the table; weights must be rounded to the closest value representable by the table. For example, each entry might correspond to a probability of .25. An event with a weight of 1 would have 4 entries, and an event with a weight of .6 would probably have 2 entries. Using multiple tables with different resolutions in a hierarchical scheme may allow for better performance or more resolution while still providing O(1) performance, although with more overhead.Oh, one more possibility I just thought up: Combine the array based methods to create an adaptive data structure using one array that contains the weights and another array that contains cumulative weights, but only calculate the cumulative weights as needed (when traversing weight array) and then use them when possible. Probably has too much overhead cost to be useful in most circumstances, but asymptotically it never performs worse than the weights in array method, and if selection of events is frequent it tends towards the behavior of the cumulative weights method. ;Quote:Original post by VorpySo what methods have we come up with...Storing cumulative weights in a tree, O(logn) selection, recreate the whole tree in O(nlogn) time for most changes.Storing weights in an array, O(n) selection, O(1) changes, can be sorted in O(nlogn) time to improve average performance by putting more likely outcomes at the front of the array (improvement depends on how unbalanced the weights are)Storing cumulative weights in an array, O(logn) selection, O(n) changesCustom balanced binary heap-like thing that stores weights and cumulative weights, O(logn) selection, O(logn) changes, requires twice as much memory as the other array-based methods, more overheard for selection than cumulative weights in array methodAnd finally, one more method I've thought of: Create a table of outcomes and pick out a random entry. Outcomes are entered into the table a number of times proportional to their weight. Implemented with a vector or deque. O(1) selection. Update complexity depends on the ratios between the weights and the resolution of the table; weights must be rounded to the closest value representable by the table. For example, each entry might correspond to a probability of .25. An event with a weight of 1 would have 4 entries, and an event with a weight of .6 would probably have 2 entries. Using multiple tables with different resolutions in a hierarchical scheme may allow for better performance or more resolution while still providing O(1) performance, although with more overhead.Oh, one more possibility I just thought up: Combine the array based methods to create an adaptive data structure using one array that contains the weights and another array that contains cumulative weights, but only calculate the cumulative weights as needed (when traversing weight array) and then use them when possible. Probably has too much overhead cost to be useful in most circumstances, but asymptotically it never performs worse than the weights in array method, and if selection of events is frequent it tends towards the behavior of the cumulative weights method.I suspect you're overthinking this. :) Probably, the cumulative-weights-in-array (ahem, vector) approach is most likely to be optimal. (When binary-searched, the "tree" is always perfectly "balanced", whereas schemes like red-black, AVL etc. allow the tree depth to be up to a constant multiple of the optimal value. Not to mention per-node space overhead, cache coherency etc. Also, the fact that subsequent nodes have to be modified *anyway* ruins the map's normal advantage of O(lg N) updates.) |
Nokia S60 emulator too slow! | General and Gameplay Programming;Programming | Hi all,so far I've been trying to run from the command line my midlet using the Nokia S60 emulator and I've always come across the same problem: the emulator is freaking slow. I've tried to change parameters and options in order to gain more heapsize etc. etc. but nothing has changed.I've read a lot of articles on different forums. It seems thatthis problems occurs to a lot of users but there's NO SOLUTION at all.I've also read that the problem may be dealing with hyperthreading and dual core processors. My computer has two Intel Pentium D CPU 2.80GHz processors.I tried to install a hotfix patch from Microsoft's website to fix slow performances on dual core processors and to change "energy saving options" from the control panel. After that I obtained a speed up that I've lost after a reboot of the system.Do you please know any solution?Thanks in advance. | Quote:Original post by ClawerI've also read that the problem may be dealing with hyperthreading and dual core processors. My computer has two Intel Pentium D CPU 2.80GHz processors.IMX, it is.Quote:Do you please know any solution?The only thing I know that works is to set the CPU affinity for each process to use only one (virtual) CPU, ideally the same for all the related processes. The relevant ones are:java.exe (two copies; set both)emulator.exemidp.exeOtherwise, I would recommend using Sun's default emulators to test as much as you can, first. Especially if you're using MIDP 2 and have a recent version of the WTK. :) |
COM + .NET | General and Gameplay Programming;Programming | Hi guys!I'm using .NET to code a Windows Service. Problem is, I must insert some COM (yeah, Component Object Model) code into it so I can connect to a cluster using Windows Compute Cluster API.Is mixing COM and .NET possible? Are there advantages/disadvantages to this approach? I think it may not be possible since .NET uses the JIT compiler and COM doesn't, so...tough doubt. | Mixing COM and .NET are most certainly possible; in fact you can think of .NET as "COM 2.0".Do you need to consume COM objects, provide COM objects or handle COM events? The specifics of the interop vary. I've consumed and provided COM objects and its fairly easy; I've not done something that handles COM events (i.e. the callback mechanism in COM).Take a look at the ComVisible attribute in the framework.Oh, and the fact that .NET is JIT compiled has no bearing on the issue. You can expose and consume COM objects from vbscript and its interpreted. ; Here are two articles which help illustrate how you can use COM from within .NET.".NET Interop: Get Ready for Microsoft .NET by Using Wrappers to Interact with COM-based Applications"http://msdn.microsoft.com/msdnmag/issues/01/08/interop/"Understanding Classic COM Interoperability With .NET Applications"http://www.codeproject.com/dotnet/cominterop.aspCheers! |
libnoise: can it tile noise? | General and Gameplay Programming;Programming | Hello,not sure if I'm posting in the right forum, but here goes....Does anyone know if libnoise can be made to produce tileable noise textures?Simple as that!ThanksSimon | Out of the box, no it can't (unless there is something in the noiseutils package I haven't seen; it's possible, since I haven't played much with those). You can do some trickery by sampling different areas adjacent to each other, and blending from one to the other based on x/y/z coordinate progression across the area. IE, to make an area tile left-to-right, you would sample two regions of equal size, one to the right of the other. As the X coordinate progresses, you increase the blend between the two sample areas, so that when X=0 (or, the left edge of the area) then you blend fully from the right-hand sample area, whereas when X=WIDTH (or, the right edge of the area) you blend fully from the left sample area. Maybe this picture will illustrate a little better:In the picture we are sampling the noise function from 2 points: (-WIDTH+x, y) and (x,y). (WIDTH is the size of the area you want to output into a texture, buffer, or whatever) We can calculate a blending factor between 0 and 1 with x/WIDTH, and use this blending factor to linearly interpolate from B to A, like so:valA = NoiseModule:GetValue(-WIDTH + x, y, 0);valB = NoiseModule:GetValue(x,y,0);blend = x/WIDTH;valFinal = valB + blend*(valA - valB);In this fashion, when the sample point lies on the left edge of the areas, the blend factor is 0, and the final value is the exact value on the left edge of the right-hand area. When blend is 1, the final value is the exact value on the right edge of the left-hand area, and thus this edge will tile exactly with the edge for blend=0. The interior values are linear blends, causing a gradual fade from one side to the other.For tiling in 2 dimensions, you need to sample a block of 4 areas in a similar fashion, interpolate based on x between the top 2 and the bottom 2 values, then interpolate these intermediate values based on y for the final value. Similarly, for tiling in 3D, you need to sample a block of 8 areas, and perform intermediate interpolations on x and y, and the final on z, for a total of 9 interpolations. (I've never had to create tiling 3D noise, however, so I've avoided this expensive operation.)Note that this can alter the fundamental character of the noise. For the standard Perlin it isn't too noticable, but for modules such as the ridged multifractal, it is more obvious. ; What a comprehensive answer... Thank you. Its a very good approach.Really I am looking for a fast real-time noise generation technique. I wanted it to tile so I could test a theory I had:Since my engine only requires noise sampling at various points, which vary around the tile, I thought I could have a 2d array of values representing the noise values. The array starts empty. Every time a real-time noise calculation is required, I check the table to see if it contains a value yet, if not I calculate the noise function and use the value, but also store it in the array.So gradually the array is filled, and less and less noise functions are called to do the same job.The array could then perhaps also be stored to disk when the player quits, improving performance next game.----Its kind of like building up premade noise textures with one important difference. I am not restricted to the supplied frequencies and octaves of the premade textures. They can be changed in real time, I jut have to start a new array (or load one created earlier)Perhaps this is stupid, since I could do something similar by having lots of premade textures and blending them to mix new noise patterns in realtime... then its a GPU operation.... hmmm; What you're doing is called memoization. That's a technique where you save the result of a function so that you can reuse it instead of computing the result when it is needed again.I think it's strange that a noise generation library doesn't have a method to create tileable noise. Tiling Perlin noise, and similiar types of noise, is fairly simple. Perlin noise works by interpolating between gradients defined at the intersection points on a grid. Inside each cell, the values are computed by using the gradients from the four corners and interpolating between the resulting values. Making it wrap around just requires wrapping around the grid. ; I took a look at the noiseutils.zip package available from the same page as libnoise, and it looks like there are several useful classes in there for generating seamless mappings, as well as other mappings (cylindrical, spherical, etc...) Might want to take a look at them to see if they suit your needs. ;Quote:Original post by JTippetts[...]valA = NoiseModule:GetValue(-WIDTH + x, y, 0);valB = NoiseModule:GetValue(x,y,0);blend = x/WIDTH;valFinal = valB + blend*(valA - valB);In this fashion, when the sample point lies on the left edge of the areas, the blend factor is 0, and the final value is the exact value on the left edge of the right-hand area. When blend is 1, the final value is the exact value on the right edge of the left-hand area, and thus this edge will tile exactly with the edge for blend=0. The interior values are linear blends, causing a gradual fade from one side to the other.[...]Note that this can alter the fundamental character of the noise. For the standard Perlin it isn't too noticable, but for modules such as the ridged multifractal, it is more obvious.Realize that while that technique might work, it also changes the noise distribution depending on the position of the sample point. On each edge, the noise will have uniform distribution, but in the middle, it will have a guassian ditribution, and the points in between will vary between the two distributions. Perhaps this is what you meant by 'fundamental character' of the noise, but mentioning the distribution changes makes the point more obvious (to me, anyways =-) ;Quote:Original post by Extrarius... but mentioning the distribution changes makes the point more obvious (to me, anyways =-)Your logic offends me, and I challenge you to a duel with wet spaghetti. Have at you, fiend!Yeah, that's basically what I meant, though I see it on a more visual level. It sometimes looks weird doing it this way; you can almost see the blend going on with some basis functions. [grin]EDIT: Some of the artifacting that I've noticed from doing seamless in this fashion comes from the underlying gradient noise basis function, as well. I implemented some generators based on Perlin's simplex function, and they seem to look better when made seamless. In this image, the one on the left is based on gradient noise interpolated to be seamless as above, the one on the right is simplex noise similarly interpolated. You can clearly see grid artifacts in the left image.[Edited by - JTippetts on September 9, 2007 1:09:37 PM]; What does your normal perlin noise look like when it isn't blended to be tileable? It looks like the grid is visible even near the edges, where the texture should be almost entirely from one source. ; Yeah, the grid artifacts are still there in the normal gradient ridged noise. The blending accentuates them quite a lot, however. Grid artifacts are quite noticeable in ridged multifractal noise based on gradient, which is why I chose ridged for the example, since it's often used for landscapes and such. In this image I have the non-seamless and seamless versions of gradient noise (top) and simplex (bottom). You can see that while both forms are made 'muddier' by the blending, the grid alignment that is present in gradient noise is accentuated. The high spots in a gradient ridged tend to follow integral boundaries, so the blending has a higher chance of blending from high-spot to high-spot on the integral boundaries, compounding the artifacts. Simplex noise isn't grid based, so while the seamless version of it is more muddled, there are fewer obvious underlying artifacts to accentuate.I'm still trying to figure out a 'good' method from producing quality tiling noise using a general library such as libnoise. By mapping noise from a cylinder in the 3D noise space, you can get good quality noise that tiles from left to right or top to bottom on a texture, but extending that to a torus for tiling in both directions presents some pretty knotty distortion problems. You can do pretty good tiling by messing with the basis functions, but that presents interface problems when using a third-party library such as libnoise. ; It's almost enough to make me want to write a noise generation library that actually works properly. There's no reason for there not to be a gradient interpolator module that interpolates between gradients defined on grid points by the user. Actually, writing a function to do this is extremely simple; there's really not even much of a need for a library. The function itself is completely deterministic, yet it does most of the work involved in computing perlin noise. Making it generate noise that tiles is trivial (set the gradients at the corresponding edges to be the same). |
Odd bit of refactoring - need some expert help | General and Gameplay Programming;Programming | I'm in the process of refactoring some of my code, and have been doing it as per the book I bought, Refactoring to Patterns, as well as a couple of websites. So far I've only done simple stuff, splitting longer methods into several smaller ones with the same granularity and so on, which is lovely, but I'm now at a spot where I don't know what to do next - it seems that there are conflicting refactorings I can perform. Using a very simplified, psuedocode-ised form of my actual code:class Building { void update(float dt) { if(state 1) { do some stuff to the physical part of the building also do some stuff to the graphical part of the building } else if(state 2) { just do stuff to the logical part of the building } else if(state 3) { do stuff to all the bits of the building } }};There are plenty of other methods like update, some of which have conditionals based on state, some of which deal with different parts of the building.As far as I can see, there are two big smells I'd like to remove: Firstly, Building is responsible for too much; physics and graphics and logic should be in separate classes. Secondly, the conditional logic has to go.The refactorings to remove these smells are most likely to turn Building into a composite of components, and to turn the conditional logic into the strategy pattern.What I can't get my head around is what order to do these in, and what the result will look like - the strategies will each need to deal with all the components, and all the components will be modified by all the strategies. Won't this look really ugly? Should each component have its own strategies? If that's the case, won't the number of classes skyrocket? Also bear in mind that Building will be a superclass once I've refactored it; there will be other types of Building that have slightly different appearance and behaviour. Should this be approached using decorators or more finely grained classes?What do you chaps think I should do? | Refactoring is a code issue, not really a design problem.Without code, there's nothing to be said.With TDD, you write tests, then code implementation to the tests. If there's a design problem, you fix the tests first, then fix the implementation.With Agile, there's not much emphasis on design. Find the simplest solution to your problem, then code from there.Waterfall model has rigid interfaces and classes. As long as you don't muck up global namespace, you're free to do whatever you want.There is no "right" way. The whole point of refactoring is to work exactly with the code you have. Not a bit more, not a bit less. To be strict - when you refactor, you first make a unit test, refactor, make sure original test still runs. Anything you change in between is not the scope of the discussion.If you think you have design issue, solve it at design level through unit tests, then come back to code to fix it. If there's code issue, don't touch the design, and just improve the code.All this smell and various hype-babble distracts from real issue, and tends to attract people with too much time - you're solving a problem. Unless there's a reason (adding a new feature, performance, etc.), you're wasting time by polishing part of code that doesn't matter.That's a lesson often missed. Purpose of refactoring and Agile approach isn't in producing sleek code, but writing code in such a manner that it's easy to change, along with demonstrating several tools and techniques with which to perform these changes with minimum effort. ; Traditional OO wisdom usually says that switch statements like that should be converted into individual classes and polymorphism. However I think this only makes sense when the individual cases are relatively isolated and don't communicate between them much. Otherwise a few switch statements can be much more readable and maintainable.Put bluntly, I don't think it's possible to judge what to do with that code without going into a lot more detail describing the system and what it needs to do. ;Quote:Original post by AntheusAll this smell and various hype-babble distracts from real issue, and tends to attract people with too much time - you're solving a problem. Unless there's a reason (adding a new feature, performance, etc.), you're wasting time by polishing part of code that doesn't matter.Ah, well that's the thing; The purpose of me doing this is to produce some beautiful code as a sample for an interview. I could go in there and say "It's crap but does the job", but I don't think they'd be impressed with that ;)I understand it's a bit difficult to give advice on code without seeing it, so here's a particularly horrible uncensored sample:void Building::update(float dt) {Ogre::Root* root = Ogre::Root::getSingletonPtr();double timeNow = root->getTimer()->getMilliseconds() / 1000.0;if(mState == Free) {if(timeNow > mTimeSetFree + mMaxFreeTime)mWorld->removeBuilding(this);} else if (mState == Controlled) {if(mHeight <= 0.0f) {if(canBuild())attach();elsesetFree();}} else if(mState == Attached) {float jointDamage = mJoint->getAccumulatedDamage();if (jointDamage > mJointDamageLastFrame)mJointDamageLastFrame = jointDamage;} else if(mState == Controlled) {// translate to appropriate coordinate and height// remember that it should be relative to the Island scene nodeOgre::Vector3 t = mIsland->getSceneNode()->getPosition();Ogre::Quaternion r = mIsland->getSceneNode()->getOrientation();opal::Matrix44r transform;transform.translate(t.x,t.y,t.z);transform.setQuaternion(r.w,r.x,r.y,r.z);transform.translate(mIsland->getPosition(mXpos), mHeight + mIsland->getHeight(mXpos,mYpos),mIsland->getPosition(mYpos));mSolid->setQuaternion(r.w, r.x, r.y, r.z);mSolid->setPosition(transform.getPosition());}if(mState != Controlled) {// We no longer want to build/set free the building on collisions, so delete the handlerif(opal::CollisionEventHandler* h = mSolid->getCollisionEventHandler()) {mSolid->setCollisionEventHandler(0);delete h;h = 0;}}}Off the top of your head(s), what changes would you make to that to make it nicer? I'm not asking you to write code for me, just some pointers would be nice ;) ; Have I misread a brace somewhere or are you doing:} else if (mState == Controlled) {twice? ; Do you envision adding more states in the future? Is this a multi-threaded application? Do you need to store your state for future use?--random ; In this case, the switch isn't to identify different kinds of objects (which would be polymorphism), but to identify different states of the same object.Maybe you should look at the State pattern instead of thinking "ah, switch means I need to do Replace Conditional with Polymorphism". ;Quote:Original post by hymermanI understand it's a bit difficult to give advice on code without seeing it, so here's a particularly horrible uncensored sample:*** Source Snippet Removed ***Off the top of your head(s), what changes would you make to that to make it nicer? I'm not asking you to write code for me, just some pointers would be nice ;)Hmm... I don't think thats too bad really. High-level gameplay objects often tend to end up looking something like that since they've got to keep their representation in the various subsystems (like physics and graphics in this code) in sync with each other.You might be able to extract another class to manage the lower level graphics calls ("BuildingVisual" or something) and hold one of those as a member, but since the graphics calls are all pretty simple I don't think you'd gain much from it. About the only thing I'd do is wrap the translation/rotation code up in it's own function. ;Quote:Original post by AntheusRefactoring is a code issue, not really a design problem.Spoken as though you don't refactor.Quote:Original post by OrangyTangTraditional OO wisdom usually says that switch statements like that should be converted into individual classes and polymorphism. However I think this only makes sense when the individual cases are relatively isolated and don't communicate between them much. Otherwise a few switch statements can be much more readable and maintainable.Put bluntly, I don't think it's possible to judge what to do with that code without going into a lot more detail describing the system and what it needs to do.I don't know about that traditional wisdom (never seen it put that way), but as I recall from MY traditional OO wisdom: OO does recommend avoiding switch statements by breaking things down into components that can interact with minimal dependencies between them. Note the subtle difference between my traditional wisdom wording and yours. However you are right on at the end: details are very important.Quote:Original post by legalizeIn this case, the switch isn't to identify different kinds of objects (which would be polymorphism), but to identify different states of the same object.Maybe you should look at the State pattern instead of thinking "ah, switch means I need to do Replace Conditional with Polymorphism".Yeah, refactoring to patterns is a great boon here. As with most things dealing with code and code cleanup, refactoring also deals with code design. Some people seem to overlook the design aspect and focus more on the "cleaning up code" part, but in reality the two are one and the same. I've found over the years that code tends to naturally evolve torwards certain patterns as you refactor. While explicitly implementing those patterns when first noticed is a really big temptation, I tend to avoid such behavior as often the refactoring will improve the resulting pattern by addressing the problem's needs in a clearer manner. Very rarely do I explicitly apply patterns anymore, tending to use more TDD/Refactoring principles to let my code naturally express the patterns that best fit the problems it faces. ;Quote:Original post by WashuVery rarely do I explicitly apply patterns anymore, tending to use more TDD/Refactoring principles to let my code naturally express the patterns that best fit the problems it faces.Agreed. I like the "emergent design" aspect of doing TDD and incrementally refactoring as I go.There is one situation where it helps to explicitly apply a pattern though: refactoring old code. I've been refactoring a huge spaghetti mess of C code into a collection of loosely coupled C++ components. Its a tough slog. In this case, sometimes it is easier to say "yeah, this is really a Strategy pattern implemented with a shitload of if statements shotgun blasted throughout the source base" and purposefully refactor things to Strategy.Refactoring to Patterns is a great reference for this. |
GLM:read material??? | Graphics and GPU Programming;Programming | Hi,I am trying to include the glm-reader by Nate Robins into my application. However, I only see the model, but the materials are not applied. I have placed the mtl-file in the same directory as my obj-file. My code loks like this:#include "glm.h"#include "gltb.h"#include <GL/glut.h>#include <assert.h>#include <stdarg.h>#include <string.h>cow=glmReadOBJ("data/models/cowok.obj");glmDimensions(cow, main_dim);glmFacetNormals(cow); glmVertexNormals(cow, smoothing_angle);glmDraw(cow, GLM_SMOOTH | GLM_MATERIAL);Any idea why the material is not applied? Are some calls missing?Thanks! mery | If there will be one person that have the some my problem... can see if there is the comand glEnable(GL_LIGHTING) in your file.c I forgot this comand!!! Now it's ok!! |
Solutions to Project 2 | Old Archive;Archive | Feel free to post your source code or links to source code for project 2 in this thread.Cheers! | I've been in China for the past 3 weeks moving my family from the states so I honestly haven't had as much time as I would like to complete this project, but I was able to get all the non-optional parts completed. I'm working on the optional stuff now, but it won''t be finished before the project is due. Here is what I got:Main Program:namespace CharacterGenerator{ class Program { static void Main(string[] args) { Console.Title = "Random Character Generator"; System.IO.StreamReader sr = new System.IO.StreamReader(@"C:\Documents and Settings\onufert\My Documents\Visual Studio 2005\Projects\CharacterGenerator\CharacterGenerator\IntroArt.txt"); string introArt = sr.ReadToEnd(); Console.Write(introArt + "\r\n"); RandomCharacter randomCharacter = new RandomCharacter(); bool repeat = true; while (repeat) { Character character = new Character(); character.Name = GetName(); character.Gender = GetGender(); character.Race = GetRace(); character.Class = GetClass(); character.Level = GetLevel(); randomCharacter.GenerateCharacter(ref character); CharacterDisplay.DisplayCharacter(character); repeat = GetRepeatFlag(); Console.Clear(); } } static bool GetRepeatFlag() { bool repeatGame; bool run = false; string response; Console.Write("Would you like to generate another character? "); do { Console.Write("Enter [y]es or [n]o: "); response = Console.ReadLine(); response = response.ToLower(); if (response == "n" || response == "no" || response == "y" || response == "yes") {if (response.StartsWith("n")){ run = false;}else if (response.StartsWith("y")){ run = true;}repeatGame = false; } else {Console.Write("Incorrect response! ");repeatGame = true; } } while (repeatGame); return (run); } static string GetName() { Boolean repeat = false; string name; do { Console.Write("Character's Name: "); name = Console.ReadLine(); if (name.ToLower() == "help") {Console.WriteLine("Naming rules:");Console.WriteLine("1) Limit of 25 characters.");Console.WriteLine(@"2) A name can consist of only letters, apostrophes (\') and hyphens (-).");Console.WriteLine("3) Only single hyphens, apostrophes and spaces are allowed.");repeat = true; } else if (CheckName(name)) {name = FormatName(name);return (name); } else {Console.WriteLine("Invalid name! Type \'help\' for naming rule. ");repeat = true; } } while (repeat); return (name); } static bool CheckName(string name) { bool nameValid = true; if (name.Length > 26) { nameValid = false; return (nameValid); } foreach (char c in name) { if (System.Char.IsLetter(c) || System.Char.IsWhiteSpace(c) || c == Convert.ToChar("'") || c == Convert.ToChar("-")) {nameValid = true; } else {nameValid = false;return (nameValid); } } return (nameValid); } static string FormatName(string name) { string myName = name; string formatedName = ""; char testChar1 = Convert.ToChar("-"); char testChar2 = Convert.ToChar("'"); char[] validChars = {testChar1, testChar2}; string[] myNameSub; myNameSub = myName.Split(); string word = ""; for (int i = 0; i < myNameSub.Length; i++) { if (!(myNameSub == "")) {if (myNameSub.Contains("-") || myNameSub.Contains("'")){ word = myNameSub; for(int j = word.IndexOfAny(validChars); j < word.Length - 1; j++) { if(word[j] == testChar1 || word[j] == testChar2) { if (word[j + 1] == testChar1 || word[j + 1] == testChar2) { word = word.Remove(j+1,1); j--; } } }}word = word + " ";formatedName = formatedName + word;word = ""; } } return (formatedName); } static CharGender GetGender() { Type genders = typeof(CharGender); Boolean repeat = false; string input; do { Console.Write("Character's Gender: "); input = Console.ReadLine(); if (input.ToLower() == "help") {Console.WriteLine("Available Genders:");foreach (string s in Enum.GetNames(genders)){ Console.WriteLine(s);}repeat = true; } else {try{ return (CharGender)(Enum.Parse(genders, input, true));}catch{ Console.Write("Invalid Gender! Type \'help\' for available genders. "); Console.WriteLine(); repeat = true;} } } while (repeat); return (0); } static CharRace GetRace() { Type races = typeof(CharRace); Boolean repeat = false; string input; do { Console.Write("Character's Race: "); input = Console.ReadLine(); if (input.ToLower() == "help") {Console.WriteLine("Available Races:");foreach (string s in Enum.GetNames(races)){ Console.WriteLine(s);}repeat = true; } else {try{ return (CharRace)(Enum.Parse(races, input, true));}catch{ Console.Write("Invalid Race! Type \'help\' for available races. "); Console.WriteLine(); repeat = true;} } } while (repeat); return (0); } static CharClass GetClass() { Type classes = typeof(CharClass); Boolean repeat = false; string input; do { Console.Write("Character's Class: "); input = Console.ReadLine(); if (input.ToLower() == "help") {Console.WriteLine("Available Classes:");foreach (string s in Enum.GetNames(classes)){ Console.WriteLine(s);}repeat = true; } else {try{ return (CharClass)(Enum.Parse(classes, input, true));}catch{ Console.Write("Invalid Class! Type \'help\' for available classes. "); Console.WriteLine(); repeat = true;} } } while (repeat); return (0); } static byte GetLevel() { byte level = 1; Boolean repeat = false; string input; do { Console.Write("Character's Level: "); input = Console.ReadLine(); try {level = Convert.ToByte(input);if (level > 0 && level < 21){ repeat = false;}else{ Console.Write("Invalid Level! Please enter a number between 1 and 20: "); repeat = true;} } catch {Console.Write("Invalid Level! Please enter a number between 1 and 20: ");repeat = true; } Console.WriteLine(); } while (repeat); return (level); } }}RandomCharacter.cs:namespace CharacterGenerator{ class RandomCharacter { //static Dice Dice = new Dice(); Character myCharacter = new Character(); public void GenerateCharacter(ref Character character) { float weight; this.myCharacter = character; myCharacter.Size = GetSize(myCharacter.Race); myCharacter.Age = GetAge(myCharacter.Race, myCharacter.Class); myCharacter.Height = GetHeightWeight(myCharacter.Race, myCharacter.Gender, out weight); myCharacter.Weight = weight; myCharacter.Hair = GetHair(); myCharacter.Eyes = GetEyes(); myCharacter.Money = GetMoney(myCharacter.Level, myCharacter.Class); myCharacter.Strength = GetAbility(CharAbilities.Strength, 4, 3, 6, myCharacter.Race); myCharacter.Dexterity = GetAbility(CharAbilities.Dexterity, 4, 3, 6, myCharacter.Race); myCharacter.Constitution = GetAbility(CharAbilities.Constitution, 4, 3, 6, myCharacter.Race); myCharacter.Intelligence = GetAbility(CharAbilities.Intelligence, 4, 3, 6, myCharacter.Race); myCharacter.Wisdom = GetAbility(CharAbilities.Wisdom, 4, 3, 6, myCharacter.Race); myCharacter.Charisma = GetAbility(CharAbilities.Charisma, 4, 3, 6, myCharacter.Race); myCharacter.HitDie = GetHitDie(myCharacter.Class); myCharacter.MaxHitPoints = GetHitPoints(myCharacter.Level, myCharacter.ConstitutionModifier, myCharacter.HitDie); myCharacter.CurrentHitPoints = myCharacter.MaxHitPoints; } private CharSize GetSize(CharRace race) { switch (race) { case CharRace.Dwarf:return (CharSize.Medium); case CharRace.Elf:return (CharSize.Medium); case CharRace.Gnome:return (CharSize.Small); case CharRace.HalfElf:return (CharSize.Medium); case CharRace.Halfling:return (CharSize.Medium); case CharRace.HalfOrc:return (CharSize.Medium); case CharRace.Human:return (CharSize.Medium); default:return (CharSize.Medium); } } private int GetAge(CharRace race, CharClass charClass) { int age = 0; switch (race) { case CharRace.Dwarf:age = 40;#region Class based age casesswitch (charClass){ case (CharClass.Barbarian): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Rogue): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Sorcerer): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Bard): age += Dice.ThrowDice(5, 6); return (age); case (CharClass.Fighter): age += Dice.ThrowDice(5, 6); return (age); case (CharClass.Paladin): age += Dice.ThrowDice(5, 6); return (age); case (CharClass.Ranger): age += Dice.ThrowDice(5, 6); return (age); case (CharClass.Cleric): age += Dice.ThrowDice(7, 6); return (age); case (CharClass.Druid): age += Dice.ThrowDice(7, 6); return (age); case (CharClass.Monk): age += Dice.ThrowDice(7, 6); return (age); case (CharClass.Wizard): age += Dice.ThrowDice(7, 6); return (age); default: return (age);}#endregion case CharRace.Elf:age = 110;#region Class based age casesswitch (charClass){ case (CharClass.Barbarian): age += Dice.ThrowDice(4, 6); return (age); case (CharClass.Rogue): age += Dice.ThrowDice(4, 6); return (age); case (CharClass.Sorcerer): age += Dice.ThrowDice(4, 6); return (age); case (CharClass.Bard): age += Dice.ThrowDice(6, 6); return (age); case (CharClass.Fighter): age += Dice.ThrowDice(6, 6); return (age); case (CharClass.Paladin): age += Dice.ThrowDice(6, 6); return (age); case (CharClass.Ranger): age += Dice.ThrowDice(6, 6); return (age); case (CharClass.Cleric): age += Dice.ThrowDice(10, 6); return (age); case (CharClass.Druid): age += Dice.ThrowDice(10, 6); return (age); case (CharClass.Monk): age += Dice.ThrowDice(10, 6); return (age); case (CharClass.Wizard): age += Dice.ThrowDice(10, 6); return (age); default: return (age);}#endregion case CharRace.Gnome:age = 40;#region Class based age casesswitch (charClass){ case (CharClass.Barbarian): age += Dice.ThrowDice(4, 6); return (age); case (CharClass.Rogue): age += Dice.ThrowDice(4, 6); return (age); case (CharClass.Sorcerer): age += Dice.ThrowDice(4, 6); return (age); case (CharClass.Bard): age += Dice.ThrowDice(6, 6); return (age); case (CharClass.Fighter): age += Dice.ThrowDice(6, 6); return (age); case (CharClass.Paladin): age += Dice.ThrowDice(6, 6); return (age); case (CharClass.Ranger): age += Dice.ThrowDice(6, 6); return (age); case (CharClass.Cleric): age += Dice.ThrowDice(9, 6); return (age); case (CharClass.Druid): age += Dice.ThrowDice(9, 6); return (age); case (CharClass.Monk): age += Dice.ThrowDice(9, 6); return (age); case (CharClass.Wizard): age += Dice.ThrowDice(9, 6); return (age); default: return (age);}#endregioncase CharRace.HalfElf:age = 20;#region Class based age casesswitch (charClass){ case (CharClass.Barbarian): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Rogue): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Sorcerer): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Bard): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Fighter): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Paladin): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Ranger): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Cleric): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Druid): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Monk): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Wizard): age += Dice.ThrowDice(3, 6); return (age); default: return (age);}#endregion case CharRace.Halfling:age = 20;#region Class based age casesswitch (charClass){ case (CharClass.Barbarian): age += Dice.ThrowDice(2, 4); return (age); case (CharClass.Rogue): age += Dice.ThrowDice(2, 4); return (age); case (CharClass.Sorcerer): age += Dice.ThrowDice(2, 4); return (age); case (CharClass.Bard): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Fighter): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Paladin): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Ranger): age += Dice.ThrowDice(3, 6); return (age); case (CharClass.Cleric): age += Dice.ThrowDice(4, 6); return (age); case (CharClass.Druid): age += Dice.ThrowDice(4, 6); return (age); case (CharClass.Monk): age += Dice.ThrowDice(4, 6); return (age); case (CharClass.Wizard): age += Dice.ThrowDice(4, 6); return (age); default: return (age);}#endregion case CharRace.HalfOrc:age = 14;#region Class based age casesswitch (charClass){ case (CharClass.Barbarian): age += Dice.ThrowDice(1, 4); return (age); case (CharClass.Rogue): age += Dice.ThrowDice(1, 4); return (age); case (CharClass.Sorcerer): age += Dice.ThrowDice(1, 4); return (age); case (CharClass.Bard): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Fighter): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Paladin): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Ranger): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Cleric): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Druid): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Monk): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Wizard): age += Dice.ThrowDice(2, 6); return (age); default: return (age);}#endregion case CharRace.Human:age = 15;#region Class based age casesswitch (charClass){ case (CharClass.Barbarian): age += Dice.ThrowDice(1, 4); return (age); case (CharClass.Rogue): age += Dice.ThrowDice(1, 4); return (age); case (CharClass.Sorcerer): age += Dice.ThrowDice(1, 4); return (age); case (CharClass.Bard): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Fighter): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Paladin): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Ranger): age += Dice.ThrowDice(1, 6); return (age); case (CharClass.Cleric): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Druid): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Monk): age += Dice.ThrowDice(2, 6); return (age); case (CharClass.Wizard): age += Dice.ThrowDice(2, 6); return (age); default: return (age);}#endregion default:return (age); } } private CharHeight GetHeightWeight(CharRace race, CharGender gender, out float weight) { int inches = 0; int pounds = 0; int hDice = 1; int hSides = 1; int wDice = 1; int wSides = 1; int roll = 0; CharHeight myHeight = new CharHeight(); switch (race) { case CharRace.Dwarf:#region Base Height/Weightif (gender == CharGender.Female){ inches = 12 * 3 + 7; pounds = 100;}else if (gender == CharGender.Male){ inches = 12 * 3 + 9; pounds = 130;}hDice = 2;hSides = 4;wDice = 2;wSides = 6;break;#endregion case CharRace.Elf:#region Base Height/Weightif (gender == CharGender.Female){ inches = 12 * 4 + 5; pounds = 80;}else if (gender == CharGender.Male){ inches = 12 * 4 + 5; pounds = 85;}hDice = 2;hSides = 6;wDice = 1;wSides = 6;break;#endregion case CharRace.Gnome:#region Base Height/Weightif (gender == CharGender.Female){ inches = 12 * 2 + 10; pounds = 35;}else if (gender == CharGender.Male){ inches = 12 * 3 + 0; pounds = 40;}hDice = 2;hSides = 4;wDice = 1;wSides = 1;break;#endregion case CharRace.HalfElf:#region Base Height/Weightif (gender == CharGender.Female){ inches = 12 * 4 + 5; pounds = 80;}else if (gender == CharGender.Male){ inches = 12 * 4 + 7; pounds = 100;}hDice = 2;hSides = 8;wDice = 2;wSides = 4;break;#endregion case CharRace.Halfling:#region Base Height/Weightif (gender == CharGender.Female){ inches = 12 * 2 + 6; pounds = 25;}else if (gender == CharGender.Male){ inches = 12 * 2 + 8; pounds = 30;}hDice = 2;hSides = 4;wDice = 1;wSides = 1;break;#endregion case CharRace.HalfOrc:#region Base Height/Weightif (gender == CharGender.Female){ inches = 12 * 4 + 5; pounds = 110;}else if (gender == CharGender.Male){ inches = 12 * 4 + 10; pounds = 150;}hDice = 2;hSides = 12;wDice = 2;wSides = 6;break;#endregion case CharRace.Human:#region Base Height/Weightif (gender == CharGender.Female){ inches = 12 * 4 + 5; pounds = 85;}else if (gender == CharGender.Male){ inches = 12 * 4 + 10; pounds = 120;}hDice = 2;hSides = 10;wDice = 2;wSides = 4;break;#endregion } roll = Dice.ThrowDice(hDice, hSides); inches += roll; myHeight.Feet = (byte)(inches / 12); myHeight.Inches =(byte)(inches % 12); pounds += roll * (Dice.ThrowDice(wDice, wSides)); weight = pounds; return (myHeight); } private CharHair GetHair() { CharHair hair = new CharHair(); hair = (CharHair)Dice.ThrowDice(1, Enum.GetNames(typeof(CharHair)).Length - 1); return (hair); } private CharEyes GetEyes() { CharEyes eyes = new CharEyes(); eyes = (CharEyes)Dice.ThrowDice(1, Enum.GetNames(typeof(CharEyes)).Length - 1); return (eyes); } private CharMoney GetMoney(byte level, CharClass myClass) { int mdice = 1; int sides = 1; CharMoney money = new CharMoney(); switch (myClass) { case (CharClass.Barbarian):mdice = 4;sides = 4;break; case (CharClass.Rogue):mdice = 5;sides = 4;break; case (CharClass.Sorcerer):mdice = 3;sides = 4;break; case (CharClass.Bard):mdice = 4;sides = 4;break; case (CharClass.Fighter):mdice = 6;sides = 4;break; case (CharClass.Paladin):mdice = 6;sides = 4;break; case (CharClass.Ranger):mdice = 6;sides = 4;break; case (CharClass.Cleric):mdice = 5;sides = 4;break; case (CharClass.Druid):mdice = 2;sides = 4;break; case (CharClass.Monk):mdice = 5;sides = 4;break; case (CharClass.Wizard):mdice = 3;sides = 4;break;} int numLevels = 0; for (int i = 1; i <= level; i++) { numLevels += (i * mdice); } money.Copper = Dice.ThrowDice(numLevels, sides) * 10; if (myClass == CharClass.Monk) { money.Copper = money.Copper / 10; } money.SortCopper(); return (money); } private byte GetAbility(CharAbilities ability, int numRolls, int numToKeep, int diceSides, CharRace race) { byte value = 0; byte[] abilityRolls = new byte[4]; for (int i = 0; i < numRolls; i++) { abilityRolls = (byte)Dice.ThrowDice(1, diceSides); } Array.Sort(abilityRolls); for (int i = abilityRolls.Length - (abilityRolls.Length - numToKeep); i > 0; i--) { value += (byte)abilityRolls; } value = (byte)((sbyte)value + GetRaceAbility(race, ability)); return (value); } private sbyte GetRaceAbility(CharRace race, CharAbilities ability) { sbyte value = 0; switch (race) { case CharRace.Dwarf:#region Race Specific Ability Modifiersswitch (ability){case CharAbilities.Strength: value = 0; break; case CharAbilities.Dexterity: value = 0; break; case CharAbilities.Constitution: value = +2; break; case CharAbilities.Intelligence: value = 0; break; case CharAbilities.Wisdom: value = 0; break; case CharAbilities.Charisma: value = -2; break; default: value = 0; break;}#endregionbreak; case CharRace.Elf:#region Race Specific Ability Modifiersswitch (ability){ case CharAbilities.Strength: value = 0; break; case CharAbilities.Dexterity: value = 2; break; case CharAbilities.Constitution: value = -2; break; case CharAbilities.Intelligence: value = 0; break; case CharAbilities.Wisdom: value = 0; break; case CharAbilities.Charisma: value = 0; break; default: value = 0; break;}#endregionbreak; case CharRace.Gnome:#region Race Specific Ability Modifiersswitch (ability){ case CharAbilities.Strength: value = -2; break; case CharAbilities.Dexterity: value = 0; break; case CharAbilities.Constitution: value = 2; break; case CharAbilities.Intelligence: value = 0; break; case CharAbilities.Wisdom: value = 0; break; case CharAbilities.Charisma: value = 0; break; default: value = 0; break;}#endregionbreak; case CharRace.HalfElf:#region Race Specific Ability Modifiersswitch (ability){ case CharAbilities.Strength: value = 0; break; case CharAbilities.Dexterity: value = 0; break; case CharAbilities.Constitution: value = 0; break; case CharAbilities.Intelligence: value = 0; break; case CharAbilities.Wisdom: value = 0; break; case CharAbilities.Charisma: value = 0; break; default: value = 0; break;}#endregionbreak; case CharRace.Halfling:#region Race Specific Ability Modifiersswitch (ability){ case CharAbilities.Strength: value = -2; break; case CharAbilities.Dexterity: value = 2; break; case CharAbilities.Constitution: value = 0; break; case CharAbilities.Intelligence: value = 0; break; case CharAbilities.Wisdom: value = 0; break; case CharAbilities.Charisma: value = 0; break; default: value = 0; break;}#endregionbreak; case CharRace.HalfOrc:#region Race Specific Ability Modifiersswitch (ability){ case CharAbilities.Strength: value = 2; break; case CharAbilities.Dexterity: value = 0; break; case CharAbilities.Constitution: value = 0; break; case CharAbilities.Intelligence: value = -2; break; case CharAbilities.Wisdom: value = 0; break; case CharAbilities.Charisma: value = -2; break; default: value = 0; break;}#endregionbreak; case CharRace.Human:#region Race Specific Ability Modifiersswitch (ability){ case CharAbilities.Strength: value = 0; break; case CharAbilities.Dexterity: value = 0; break; case CharAbilities.Constitution: value = 0; break; case CharAbilities.Intelligence: value = 0; break; case CharAbilities.Wisdom: value = 0; break; case CharAbilities.Charisma: value = 0; break; default: value = 0; break;}#endregionbreak; default:value = 0;break; } return (value); } private int GetHitDie(CharClass myClass) { int sides = 1; switch (myClass) { case (CharClass.Barbarian):sides = 12;break; case (CharClass.Rogue):sides = 6;break; case (CharClass.Sorcerer):sides = 4;break; case (CharClass.Bard):sides = 6;break; case (CharClass.Fighter):sides = 10;break; case (CharClass.Paladin):sides = 10;break; case (CharClass.Ranger):sides = 8;break; case (CharClass.Cleric):sides = 8;break; case (CharClass.Druid):sides = 8;break; case (CharClass.Monk):sides = 8;break; case (CharClass.Wizard):sides = 4;break; } return (sides); } private int GetHitPoints(int level, sbyte constModifier, int hitDie) { int hitPoints = hitDie + constModifier; for (int i = 1; i < level; i++) { hitPoints += Dice.ThrowDice(1, hitDie) + constModifier; } return (hitPoints); } }}Character.cs:namespace CharacterGenerator{ class Character { string name; CharGender gender; CharRace race; CharClass charClass; byte level; CharSize size; int age; CharHeight height; float weight; CharEyes eyes; CharHair hair; byte strength; byte dexterity; byte constitution; byte intelligence; byte wisdom; byte charisma; byte fortitude; byte reflex; byte will; int maxHitPoints; int currentHitPoints; CharMoney money; int hitDie; #region Properties public string Name { get { return (this.name); } set { this.name = value; } } public CharGender Gender { get { return (this.gender); } set { this.gender = value; } } public CharRace Race { get { return (this.race); } set { this.race = value; } } public CharClass Class { get { return (this.charClass); } set { this.charClass = value; } } public byte Level { get { return (this.level); } set { this.level = value; } } public CharSize Size { get { return (this.size); } set { this.size = value; } } public int Age { get { return (this.age); } set { this.age = value; } } public CharHeight Height { get { return (this.height); } set { this.height = value; } } public float Weight { get { return (this.weight); } set { this.weight = value; } } public CharEyes Eyes { get { return (this.eyes); } set { this.eyes = value; } } public CharHair Hair { get { return (this.hair); } set { this.hair = value; } } public CharMoney Money { get { return (this.money); } set { this.money = value; } } public byte Strength { get { return (this.strength); } set { this.strength = value; } } public byte Dexterity { get { return (this.dexterity); } set { this.dexterity = value; } } public byte Constitution { get { return (this.constitution); } set { this.constitution = value; } } public byte Intelligence { get { return (this.intelligence); } set { this.intelligence = value; } } public byte Wisdom { get { return (this.wisdom); } set { this.wisdom = value; } } public byte Charisma { get { return (this.charisma); } set { this.charisma = value; } } public sbyte StrengthModifier { get { return (GetModifier(this.strength)); } } public sbyte DexterityModifier { get { return (GetModifier(this.dexterity)); } } public sbyte ConstitutionModifier { get { return (GetModifier(this.constitution)); } } public sbyte IntelligenceModifier { get { return (GetModifier(this.intelligence)); } } public sbyte WisdomModifier { get { return (GetModifier(this.wisdom)); } } public sbyte CharismaModifier { get { return (GetModifier(this.charisma)); } } public int MaxHitPoints { get { return (this.maxHitPoints); } set { this.maxHitPoints = value; } } public int CurrentHitPoints { get { return (this.currentHitPoints); } set { this.currentHitPoints = value; } } public int HitDie { get { return (this.hitDie); } set { this.hitDie = value; } } public int Fortitude { get { return (SavingThrows.BaseFortitude(this.level,this.charClass) + ConstitutionModifier); } } public int Reflex { get { return (SavingThrows.BaseReflex(this.level, this.charClass) + DexterityModifier); } } public int Will { get { return (SavingThrows.BaseWill(this.level, this.charClass) + WisdomModifier); } } #endregion private sbyte GetModifier(byte attribute) { if (attribute >= 10) { byte atr = (byte)(attribute - 10); sbyte atrMod = (sbyte)(atr / 2); return (atrMod); } else if (attribute < 10) { byte atr = attribute; sbyte atrMod = (sbyte)(0 - ((9 - atr) / 2 + 1)); return (atrMod); } return (0); } }CharacterStructs.cs:namespace CharacterGenerator{ struct CharHeight { public byte Feet; public byte Inches; } struct CharMoney { public int Platinum; public int Gold; public int Copper; public int Silver; public void SortCopper() { int copper = this.Copper; if (copper >= 1000) {this.Platinum = copper / 1000;copper -= this.Platinum * 1000; } if (copper >= 100) {this.Gold = copper / 100;copper -= this.Gold * 100; } if (copper >= 10) {this.Silver = copper / 10;copper -= this.Silver * 10; } this.Copper = copper; } }}CharacterEnumerations.cs:namespace CharacterGenerator{ public enum CharGender { Male, Female, } public enum CharRace { Human, Dwarf, Elf, Gnome, HalfElf, HalfOrc, Halfling, } public enum CharClass { Barbarian, Bard, Cleric, Druid, Fighter, Monk, Paladin, Ranger, Rogue, Sorcerer, Wizard, } public enum CharSize { Small, Medium, } public enum CharEyes { Brown, Hazel, Amber, Green, Blue, Gray } public enum CharHair { Brown, Mahogany, Chocolate, Cinnamon, Chestnut, Black, Raven, Ebony, Charcoal, Blonde, Honey, Golden, Strawberry, Platinum, Red, Auburn, Russet, Scarlet, White, Gray, Silver } public enum CharAbilities { Strength, Dexterity, Constitution, Intelligence, Wisdom, Charisma }}SavingThrows.cs:namespace CharacterGenerator{ class SavingThrows { static private byte[] sequence2 = new byte[] { 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12 }; static private byte[] sequence1 = new byte[] { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, }; static public byte BaseFortitude(int level, CharClass myClass) { byte value = 0; switch (myClass) { case (CharClass.Barbarian):value = sequence2[level - 1];break; case (CharClass.Rogue):value = sequence1[level - 1];break; case (CharClass.Sorcerer):value = sequence1[level - 1];break; case (CharClass.Bard):value = sequence1[level - 1];break; case (CharClass.Fighter):value = sequence2[level - 1];break; case (CharClass.Paladin):value = sequence2[level - 1];break; case (CharClass.Ranger):value = sequence2[level - 1];break; case (CharClass.Cleric):value = sequence2[level - 1];break; case (CharClass.Druid):value = sequence2[level - 1];break; case (CharClass.Monk):value = sequence2[level - 1];break; case (CharClass.Wizard):value = sequence1[level - 1];break; } return (value); } static public byte BaseReflex(int level, CharClass myClass) { byte value = 0; switch (myClass) { case (CharClass.Barbarian):value = sequence1[level - 1];break; case (CharClass.Rogue):value = sequence2[level - 1];break; case (CharClass.Sorcerer):value = sequence1[level - 1];break; case (CharClass.Bard):value = sequence2[level - 1];break; case (CharClass.Fighter):value = sequence1[level - 1];break; case (CharClass.Paladin):value = sequence1[level - 1];break; case (CharClass.Ranger):value = sequence2[level - 1];break; case (CharClass.Cleric):value = sequence1[level - 1];break; case (CharClass.Druid):value = sequence1[level - 1];break; case (CharClass.Monk):value = sequence2[level - 1];break; case (CharClass.Wizard):value = sequence1[level - 1];break; } return (value); } static public byte BaseWill(int level, CharClass myClass) { byte value = 0; switch (myClass) { case (CharClass.Barbarian):value = sequence1[level - 1];break; case (CharClass.Rogue):value = sequence1[level - 1];break; case (CharClass.Sorcerer):value = sequence2[level - 1];break; case (CharClass.Bard):value = sequence2[level - 1];break; case (CharClass.Fighter):value = sequence1[level - 1];break; case (CharClass.Paladin):value = sequence1[level - 1];break; case (CharClass.Ranger):value = sequence1[level - 1];break; case (CharClass.Cleric):value = sequence2[level - 1];break; case (CharClass.Druid):value = sequence2[level - 1];break; case (CharClass.Monk):value = sequence2[level - 1];break; case (CharClass.Wizard):value = sequence2[level - 1];break; } return (value); } }}Dice.csnamespace CharacterGenerator{ class Dice { static Random randomNum = new Random(); public static int ThrowDice(int numberDice, int diceSides) { int roll = 0; for (int i = 0; i < numberDice; i++) { roll += randomNum.Next(1 , diceSides + 1); } return (roll); } }}CharacterDisplay.cs:namespace CharacterGenerator{ static class CharacterDisplay { static Character myCharacter = new Character(); public static void DisplayCharacter(Character character) { myCharacter = character; Console.WriteLine(); Console.WriteLine("Name: {0}", myCharacter.Name); Console.WriteLine("Gender: {0}", myCharacter.Gender); Console.WriteLine("Race: {0}", myCharacter.Race); Console.WriteLine("Class: {0}", myCharacter.Class); Console.WriteLine("Level: {0}", myCharacter.Level); Console.WriteLine("Size: {0}", myCharacter.Size); Console.WriteLine("Age:{0}", myCharacter.Age); Console.WriteLine("Height: {0}' {1}''", myCharacter.Height.Feet, myCharacter.Height.Inches); Console.WriteLine("Weight: {0}lbs", myCharacter.Weight); Console.WriteLine("Eyes: {0}", myCharacter.Eyes); Console.WriteLine("Hair: {0}", myCharacter.Hair); Console.WriteLine("Money: {0} Platinum, {1} Gold, {2} Silver, {3} Copper", myCharacter.Money.Platinum, myCharacter.Money.Gold, myCharacter.Money.Silver, myCharacter.Money.Copper); Console.WriteLine("Strength:{0}", myCharacter.Strength); Console.WriteLine("StrengthMod: {0}", myCharacter.StrengthModifier); Console.WriteLine("Dexterity: {0}", myCharacter.Dexterity); Console.WriteLine("DexterityMod: {0}", myCharacter.DexterityModifier); Console.WriteLine("Constitution: {0}", myCharacter.Constitution); Console.WriteLine("ConstMod:{0}", myCharacter.ConstitutionModifier); Console.WriteLine("Intelligence: {0}", myCharacter.Intelligence); Console.WriteLine("IntelMod:{0}", myCharacter.IntelligenceModifier); Console.WriteLine("Wisdom: {0}", myCharacter.Wisdom); Console.WriteLine("WisdomMod: {0}", myCharacter.WisdomModifier); Console.WriteLine("Charisma:{0}", myCharacter.Charisma); Console.WriteLine("CharismaMod: {0}", myCharacter.CharismaModifier); Console.WriteLine("MaxHitPoints: {0}", myCharacter.MaxHitPoints); Console.WriteLine("CurrentHitPts:{0}", myCharacter.CurrentHitPoints); Console.WriteLine("Fortitude: {0}", myCharacter.Fortitude); Console.WriteLine("Reflex: {0}", myCharacter.Reflex); Console.WriteLine("Will: {0}", myCharacter.Will); } }}I saved the intro art into a text file that I parse and display, this way I can put any art I want into the program by replacing the text file. I never quite figured out how to specify the file as part of the project, the only way I could find it was to put the actual path of the file on my computer.IntroArt.txt:;Quote:Original post by Rule3o3I've been in China for the past 3 weeks moving my family from the states so I honestly haven't had as much time as I would like to complete this project, but I was able to get all the non-optional parts completed. I'm working on the optional stuff now, but it won''t be finished before the project is due. Here is what I got:Main Program:*** Source Snippet Removed ***RandomCharacter.cs:*** Source Snippet Removed ***Character.cs:*** Source Snippet Removed ***CharacterStructs.cs:*** Source Snippet Removed ***CharacterEnumerations.cs:*** Source Snippet Removed ***SavingThrows.cs:*** Source Snippet Removed ***Dice.cs*** Source Snippet Removed ***CharacterDisplay.cs:*** Source Snippet Removed ***I saved the intro art into a text file that I parse and display, this way I can put any art I want into the program by replacing the text file. I never quite figured out how to specify the file as part of the project, the only way I could find it was to put the actual path of the file on my computer.IntroArt.txt:I am still working then mine (school started!!!), but I think you should be fine if you just put the text file in with the .exe; CharGen.zipIncluded is a largely step by step, test first approach description of how I approached the problem, though the description is pretty rough. HTML format; uses NUnit. ; Overachiever. [lol];Quote:Original post by SiCrane CharGen.zipIncluded is a largely step by step, test first approach description of how I approached the problem, though the description is pretty rough. HTML format; uses NUnit.SiCrane,This is great! Thank you for taking the time to write your steps out. Quite a few "light-bulb" moments and "Wows!" I also love the use of your unittest approach. Good stuff. Thanks again!-Rule ;Quote:Original post by JWalshOverachiever. [lol]Damn straight. So what's happening with Project 3? Seeing as its deadline has already passed.... ; I've got a milestone this weekend. =( I'll post project 3 this Sunday. That gives people a little bit more time to finish project 2, and gives me a reprieve at the same time.Cheers! ;Quote:Original post by JWalshI've got a milestone this weekend. =( I'll post project 3 this Sunday. That gives people a little bit more time to finish project 2, and gives me a reprieve at the same time.Cheers!My implementation has growing a lot - and I have no idea when I'll will finish. I will try to NOT add Lua scripting (that how I first intended to implement the various spell effects and special abilities). Hopefully, project 3 will use either the character generation OR the maze generation OR some basic gameplay using the generated character, so I'll be able to use what i'm doing right now [smile]. ; Okay I have finally completed all the basic functionality that the generator needs to provide for this project. Heres the source:The structs I used: struct Height { public int feet; public int inches; public Height(int f, int i) { feet = f; inches = i; } //possible problem if user constructs height like Height height = new Height(6, 15); //maybe restrict to 12 or convert within constructor public static int ToInches(Height height) { int feetAsInches = height.feet * 12; int inches = feetAsInches + height.inches; return inches; } public static Height ToFeet(int inches) { Height height; int feet = inches / 12; int inch = inches % 12; height.feet = feet; height.inches = inch; return height; } public override string ToString() { string str = ""; str = str + feet + "ft'" + inches; return str; } } struct Money { public int platinum; public int gold; public int silver; public int copper; public Money(int pla, int gol, int sil, int cop) { platinum = pla; gold = gol; silver = sil; copper = cop; } public static Money Sort(Money amount) { Money money = amount; int tempSilver; int tempGold; int tempPlatinum; tempSilver = money.copper / 10; money.copper -= tempSilver * 10; money.silver += tempSilver; tempGold = money.silver / 10; money.silver -= tempGold * 10; money.gold += tempGold; tempPlatinum = money.gold / 10; money.gold -= tempPlatinum * 10; money.platinum += tempPlatinum; return money; } public override string ToString() { string str = platinum + "pp " + gold + "gp " + silver + "sp " + copper + "cp"; return str; } } struct Abilities { public int strength; public int dexterity; public int constitution; public int intelligence; public int wisdom; public int charisma; } struct SThrows { public int fortitude; public int reflex; public int will; }The race class(RaceDef)abstract class RaceDef { public abstract int RandomAge(Class type); public abstract Height RandomHeight(Gender gen); public abstract float RandomWeight(Height playerHeight, Gender gen); public abstract Size Size(); public abstract Abilities RandomAbilities(); public EyeColour RandomEyeColour() { int numEnum = Enum.GetValues(typeof(EyeColour)).Length; Random rand = new Random(); EyeColour colour = (EyeColour)rand.Next(numEnum); return colour; } public HairColour RandomHairColour() { int numEnum = Enum.GetValues(typeof(HairColour)).Length; Random rand = new Random(); HairColour colour = (HairColour)rand.Next(numEnum); return colour; } private int BestRolls() { int[] iArray = new int[4]; for (int i = 0; i < 4; i++) { iArray = Dice.Roll(1, 6); } Array.Sort(iArray); int total = 0; for (int i = iArray.Length - 1; i > 0; i--) total += iArray; return total; } public void InitAbilities(ref Abilities abilities) { abilities.strength = BestRolls(); abilities.dexterity = BestRolls(); abilities.constitution = BestRolls(); abilities.intelligence = BestRolls(); abilities.wisdom = BestRolls(); abilities.charisma = BestRolls(); //Console.WriteLine("str: {0}, dex: {1}, con: {2}, int: {3}, wis: {4}, cha: {5}", abilities.strength, // abilities.dexterity, abilities.constitution, abilities.intelligence, abilities.wisdom, abilities.charisma); } public static RaceDef human = new Human(); public static RaceDef dwarf = new Dwarf(); public static RaceDef elf = new Elf(); public static RaceDef gnome = new Gnome(); public static RaceDef halfelf = new HalfElf(); public static RaceDef halforc = new HalfOrc(); public static RaceDef halfling = new Halfling(); } class Human : RaceDef { public override int RandomAge(Class type) { string[] ageTable = { "1d4", "1d6", "2d6", "2d6", "1d6", "2d6", "1d6", "1d6", "1d4", "1d4", "2d6" }; string dice = ageTable[(int)type]; string[] split = dice.Split('d'); int numDie; int dieSize; int.TryParse(split[0], out numDie); int.TryParse(split[1], out dieSize); int age = 15 + Dice.Roll(numDie, dieSize); return age; } public override Height RandomHeight(Gender gen) { Height mHeight = new Height(4, 10); Height fHeight = new Height(4, 5); int inches = Dice.Roll(2, 10); Height height; if (gen == Gender.Male) { int mH = Height.ToInches(mHeight); mH += inches; height = Height.ToFeet(mH); } else { int fH = Height.ToInches(fHeight); fH += inches; height = Height.ToFeet(fH); } return height; } public override float RandomWeight(Height playerHeight, Gender gen) { int inches = Height.ToInches(playerHeight); int weight; int diceRoll = Dice.Roll(2, 4); if (gen == Gender.Male) { int sInches = Height.ToInches(new Height(4, 10)); int eWeight = (inches - sInches) * diceRoll; weight = 120 + eWeight; } else { int sInches = Height.ToInches(new Height(4, 5)); int eWeight = (inches - sInches) * diceRoll; weight = 85 + eWeight; } return weight; } public override Size Size() { return CharacterGenerator.Size.Medium; } public override Abilities RandomAbilities() { Abilities abilities = new Abilities(); InitAbilities(ref abilities); //no changes needed return abilities; } } class Dwarf : RaceDef { public override int RandomAge(Class type) { string[] ageTable = { "3d6", "5d6", "7d6", "7d6", "5d6", "7d6", "5d6", "5d6", "3d6", "3d6", "7d6" }; string dice = ageTable[(int)type]; string[] split = dice.Split('d'); int numDie; int dieSize; int.TryParse(split[0], out numDie); int.TryParse(split[1], out dieSize); int age = 40 + Dice.Roll(numDie, dieSize); return age; } public override Height RandomHeight(Gender gen) { Height mHeight = new Height(3, 9); Height fHeight = new Height(3, 7); int inches = Dice.Roll(2, 4); Height height; if (gen == Gender.Male) { int mH = Height.ToInches(mHeight); mH += inches; height = Height.ToFeet(mH); } else { int fH = Height.ToInches(fHeight); fH += inches; height = Height.ToFeet(fH); } return height; } public override float RandomWeight(Height playerHeight, Gender gen) { int inches = Height.ToInches(playerHeight); int weight; int diceRoll = Dice.Roll(2, 6); if (gen == Gender.Male) { int sInches = Height.ToInches(new Height(3, 9)); int eWeight = (inches - sInches) * diceRoll; weight = 130 + eWeight; } else { int sInches = Height.ToInches(new Height(3, 7)); int eWeight = (inches - sInches) * diceRoll; weight = 100 + eWeight; } return weight; } public override Size Size() { return CharacterGenerator.Size.Medium; } public override Abilities RandomAbilities() { Abilities abilities = new Abilities(); InitAbilities(ref abilities); abilities.constitution += 2; abilities.charisma -= 2; return abilities; } } class Elf : RaceDef { public override int RandomAge(Class type) { string[] ageTable = { "4d6", "6d6", "10d6", "10d6", "6d6", "10d6", "6d6", "6d6", "4d6", "4d6", "10d6" }; string dice = ageTable[(int)type]; string[] split = dice.Split('d'); int numDie; int dieSize; int.TryParse(split[0], out numDie); int.TryParse(split[1], out dieSize); int age = 110 + Dice.Roll(numDie, dieSize); return age; } public override Height RandomHeight(Gender gen) { Height mHeight = new Height(4, 5); Height fHeight = new Height(4, 5); int inches = Dice.Roll(2, 6); Height height; if (gen == Gender.Male) { int mH = Height.ToInches(mHeight); mH += inches; height = Height.ToFeet(mH); } else { int fH = Height.ToInches(fHeight); fH +=inches; height = Height.ToFeet(fH); } return height; } public override float RandomWeight(Height playerHeight, Gender gen) { int inches = Height.ToInches(playerHeight); int weight; int diceRoll = Dice.Roll(1, 6); if (gen == Gender.Male) { int sInches = Height.ToInches(new Height(4, 5)); int eWeight = (inches - sInches) * diceRoll; weight = 85 + eWeight; } else { int sInches = Height.ToInches(new Height(4, 5)); int eWeight = (inches - sInches) * diceRoll; weight = 80 + eWeight; } return weight; } public override Size Size() { return CharacterGenerator.Size.Medium; } public override Abilities RandomAbilities() { Abilities abilities = new Abilities(); InitAbilities(ref abilities); abilities.dexterity += 2; abilities.constitution -= 2; return abilities; } } class Gnome : RaceDef { public override int RandomAge(Class type) { string[] ageTable = { "4d6", "6d6", "9d6", "9d6", "6d6", "9d6", "6d6", "6d6", "4d6", "4d6", "9d6" }; string dice = ageTable[(int)type]; string[] split = dice.Split('d'); int numDie; int dieSize; int.TryParse(split[0], out numDie); int.TryParse(split[1], out dieSize); int age = 40 + Dice.Roll(numDie, dieSize); return age; } public override Height RandomHeight(Gender gen) { Height mHeight = new Height(3, 0); Height fHeight = new Height(2, 10); int inches = Dice.Roll(2, 4); Height height; if (gen == Gender.Male) { int mH = Height.ToInches(mHeight); mH += inches; height = Height.ToFeet(mH); } else { int fH = Height.ToInches(fHeight); fH += inches; height = Height.ToFeet(fH); } return height; } public override float RandomWeight(Height playerHeight, Gender gen) { int inches = Height.ToInches(playerHeight); int weight; int diceRoll = Dice.Roll(1, 1); if (gen == Gender.Male) { int sInches = Height.ToInches(new Height(3, 0)); int eWeight = (inches - sInches) * diceRoll; weight = 40 + eWeight; } else { int sInches = Height.ToInches(new Height(2, 10)); int eWeight = (inches - sInches) * diceRoll; weight = 35 + eWeight; } return weight; } public override Size Size() { return CharacterGenerator.Size.Small; } public override Abilities RandomAbilities() { Abilities abilities = new Abilities(); InitAbilities(ref abilities); abilities.constitution += 2; abilities.strength -= 2; return abilities; } } class HalfElf : RaceDef { public override int RandomAge(Class type) { string[] ageTable = { "1d6", "2d6", "3d6", "3d6", "2d6", "3d6", "2d6", "2d6", "1d6", "1d6", "3d6" }; string dice = ageTable[(int)type]; string[] split = dice.Split('d'); int numDie; int dieSize; int.TryParse(split[0], out numDie); int.TryParse(split[1], out dieSize); int age = 20 + Dice.Roll(numDie, dieSize); return 20; } public override Height RandomHeight(Gender gen) { Height mHeight = new Height(4, 7); Height fHeight = new Height(4, 5); int inches = Dice.Roll(2, 8); Height height; if (gen == Gender.Male) { int mH = Height.ToInches(mHeight); mH += inches; height = Height.ToFeet(mH); } else { int fH = Height.ToInches(fHeight); fH += inches; height = Height.ToFeet(fH); } return height; } public override float RandomWeight(Height playerHeight, Gender gen) { int inches = Height.ToInches(playerHeight); int weight; int diceRoll = Dice.Roll(2, 4); if (gen == Gender.Male) { int sInches = Height.ToInches(new Height(4, 7)); int eWeight = (inches - sInches) * diceRoll; weight = 100 + eWeight; } else { int sInches = Height.ToInches(new Height(4, 5)); int eWeight = (inches - sInches) * diceRoll; weight = 80 + eWeight; } return weight; } public override Size Size() { return CharacterGenerator.Size.Medium; } public override Abilities RandomAbilities() { Abilities abilities = new Abilities(); InitAbilities(ref abilities); //no changes needed return abilities; } } class HalfOrc : RaceDef { public override int RandomAge(Class type) { string[] ageTable = { "1d4", "1d6", "4d6", "4d6", "1d6", "4d6", "1d6", "1d6", "1d4", "1d4", "4d6" }; string dice = ageTable[(int)type]; string[] split = dice.Split('d'); int numDie; int dieSize; int.TryParse(split[0], out numDie); int.TryParse(split[1], out dieSize); int age = 14 + Dice.Roll(numDie, dieSize); return age; } public override Height RandomHeight(Gender gen) { Height mHeight = new Height(4, 10); Height fHeight = new Height(4, 5); int inches = Dice.Roll(2, 12); Height height; if (gen == Gender.Male) { int mH = Height.ToInches(mHeight); mH += inches; height = Height.ToFeet(mH); } else { int fH = Height.ToInches(fHeight); fH += inches; height = Height.ToFeet(fH); } return height; } public override float RandomWeight(Height playerHeight, Gender gen) { int inches = Height.ToInches(playerHeight); int weight; int diceRoll = Dice.Roll(2, 6); if (gen == Gender.Male) { int sInches = Height.ToInches(new Height(4, 10)); int eWeight = (inches - sInches) * diceRoll; weight = 150 + eWeight; } else { int sInches = Height.ToInches(new Height(4, 5)); int eWeight = (inches - sInches) * diceRoll; weight = 110 + eWeight; } return weight; } public override Size Size() { return CharacterGenerator.Size.Medium; } public override Abilities RandomAbilities() { Abilities abilities = new Abilities(); InitAbilities(ref abilities); abilities.strength += 2; abilities.intelligence -= 2; abilities.charisma -= 2; return abilities; } } class Halfling : RaceDef { public override int RandomAge(Class type) { string[] ageTable = { "2d4", "3d6", "4d6", "4d6", "3d6", "4d6", "3d6", "3d6", "2d4", "2d4", "4d6" }; string dice = ageTable[(int)type]; string[] split = dice.Split('d'); int numDie; int dieSize; int.TryParse(split[0], out numDie); int.TryParse(split[1], out dieSize); int age = 20 + Dice.Roll(numDie, dieSize); return age; } public override Height RandomHeight(Gender gen) { Height mHeight = new Height(2, 8); Height fHeight = new Height(2, 6); int inches = Dice.Roll(2, 4); Height height; if (gen == Gender.Male) { int mH = Height.ToInches(mHeight); mH += inches; height = Height.ToFeet(mH); } else { int fH = Height.ToInches(fHeight); fH += inches; height = Height.ToFeet(fH); } return height; } public override float RandomWeight(Height playerHeight, Gender gen) { int inches = Height.ToInches(playerHeight); int weight; int diceRoll = Dice.Roll(1, 1); if (gen == Gender.Male) { int sInches = Height.ToInches(new Height(2, 8)); int eWeight = (inches - sInches) * diceRoll; weight = 30 + eWeight; } else { int sInches = Height.ToInches(new Height(2, 6)); int eWeight = (inches - sInches) * diceRoll; weight = 25 + eWeight; } return weight; } public override Size Size() { return CharacterGenerator.Size.Small; } public override Abilities RandomAbilities() { Abilities abilities = new Abilities(); InitAbilities(ref abilities); abilities.dexterity += 2; abilities.strength -= 2; return abilities; } }The Character class:class Character { //fields string name; Gender gender; RaceDef race; Class type; byte level; int age; Height height; float weight; EyeColour eyeColour; HairColour hairColour; Size size; Abilities abilities; SThrows savingThrows; Money money; int maxHitPoints; int currentHitPoints; //properties -- perhaps make them private to the class public string Name { set { name = value; } get { return name; } } public Gender Gender { set { gender = value; } get { return gender; } } public RaceDef Race { set { race = value; Age = race.RandomAge(type); EyeColour = race.RandomEyeColour(); HairColour = race.RandomHairColour(); Height = race.RandomHeight(Gender); Weight = race.RandomWeight(Height, Gender); Size = race.Size(); Abilities = race.RandomAbilities(); } get { return race; } } public Class Type { set { type = value; } get { return type; } } public byte Level { set { level = value; } get { return level; } } public int Age { set { age = value; } get { return age; } } public Height Height { set { height = value; } get { return height; } } public float Weight { set { weight = value; } get { return weight; } } public EyeColour EyeColour { set { eyeColour = value; } get { return eyeColour; } } public HairColour HairColour { set { hairColour = value; } get { return hairColour; } } public Size Size { set { size = value; } get { return size; } } public Abilities Abilities { set { abilities = value; } get { return abilities; } } public SThrows SavingThrows { set { savingThrows = value; } get { return savingThrows; } } public Money Money { set { money = value; } get { return money; } } public int MaxHitPoints { set { maxHitPoints = value; } get { return maxHitPoints; } } public int CurrentHitPoints { set { currentHitPoints = value; } get { return currentHitPoints; } } //end of properties private int GoodSave(int level) { return 2 + level / 2; } private int WeakSave(int level) { return level / 3; } private int FortSave(Class type, int level) { switch (type) { case Class.Barbarian: case Class.Cleric: case Class.Druid: case Class.Fighter: case Class.Monk: case Class.Paladin: case Class.Ranger:return GoodSave(level); case Class.Bard: case Class.Rogue: case Class.Sorcerer: case Class.Wizard:return WeakSave(level); default:throw new ArgumentException("Invalid class"); } } private int RefSave(Class type, int level) { switch (type) { case Class.Bard: case Class.Monk: case Class.Ranger: case Class.Rogue:return GoodSave(level); case Class.Barbarian: case Class.Cleric: case Class.Druid: case Class.Fighter: case Class.Paladin: case Class.Sorcerer: case Class.Wizard:return WeakSave(level); default:throw new ArgumentException("Invalid class"); } } private int WillSave(Class type, int level) { switch (type) { case Class.Bard: case Class.Cleric: case Class.Druid: case Class.Monk: case Class.Sorcerer: case Class.Wizard:return GoodSave(level); case Class.Barbarian: case Class.Fighter: case Class.Paladin: case Class.Ranger: case Class.Rogue:return WeakSave(level); default:throw new ArgumentException("Invalid class"); } } private SThrows GetSavingThrows(Class type, int level) { SThrows save = new SThrows(); save.fortitude = FortSave(type, level); save.reflex = RefSave(type, level); save.will = WillSave(type, level); return save; } private Money RandomMoney(Class type, byte level) { string[] moneyTable = { "4d4", "4d4", "5d4", "2d4", "6d4", "5d4", "6d4", "6d4", "5d4", "3d4", "3d4" }; string dice = moneyTable[(int)type]; string[] split = dice.Split('d'); int numDie; int dieSize; int.TryParse(split[0], out numDie); int.TryParse(split[1], out dieSize); int totalLevel = 0; for (int i = 1; i < (level + 1); i++) { totalLevel += i; } int gold; if (type != Class.Monk) { gold = Dice.Roll((totalLevel * numDie), dieSize); gold *= 10; } else gold = Dice.Roll((totalLevel * numDie), dieSize); Money money = new Money(0, gold, 0, 0); return money; } private int GetMaxHitPoints(Class type, int level, int constitution) { int mHP = 0; int conMod = (constitution - 10) / 2; string[] hitDie = { "1d12", "1d6", "1d8", "1d8", "1d10", "1d8", "1d10", "1d8", "1d6", "1d4", "1d4"}; string dice = hitDie[(int)type]; string[] split = dice.Split('d'); int numDie; int dieSize; int.TryParse(split[0], out numDie); int.TryParse(split[1], out dieSize); if (level == 1) { mHP = dieSize + conMod; } else { int rolls = (level - 1); mHP = dieSize + conMod; for (int i = 0; i < rolls; i++) {mHP = mHP + Dice.Roll(numDie, dieSize) + conMod; } if (mHP < 1)mHP = 1; } return mHP; } public void GenerateRandom(string name, Gender gender, Race race, Class type, byte level) { Name = name; Gender = gender; switch (race) { case CharacterGenerator.Race.Human:Race = RaceDef.human;break; case CharacterGenerator.Race.Dwarf:Race = RaceDef.dwarf;break; case CharacterGenerator.Race.Elf:Race = RaceDef.elf;break; case CharacterGenerator.Race.Gnome:Race = RaceDef.gnome;break; case CharacterGenerator.Race.HalfElf:Race = RaceDef.halfelf;break; case CharacterGenerator.Race.HalfOrc:Race = RaceDef.halforc;break; case CharacterGenerator.Race.Halfling:Race = RaceDef.halfling;break; } Type = type; Level = level; savingThrows = GetSavingThrows(Type, Level); Money = RandomMoney(Type, Level); MaxHitPoints = GetMaxHitPoints(Type, Level, abilities.constitution); CurrentHitPoints = MaxHitPoints; } public void DisplayStats() { string str = Race.ToString(); string[] strArray = str.Split('.'); string[] stats = { "Name ", "Gender ", "Race ", "Class ", "Level ", "Age ", "Eye colour ", "Hair colour ", "Height ", "Weight ", "Size ", "Strength ", "Dexterity ", "Constitution ", "Intelligence ", "Wisdom ", "Charisma ", "Fortitude ", "Reflex ", "Will ", "Max HP ", "Current HP ", "Money " }; string[] resul = { Name, Gender + "", strArray[strArray.Length - 1], Type + "", Level + "", Age + "", EyeColour + "", HairColour + "", Height + "", Weight + "lbs", Size + "\n", abilities.strength + "", abilities.dexterity + "", abilities.constitution + "", abilities.intelligence + "", abilities.wisdom + "", abilities.charisma + "\n", savingThrows.fortitude + "", savingThrows.reflex + "", savingThrows.will + "\n", MaxHitPoints + "", CurrentHitPoints + "", Money + "" }; int longest = 0; for (int i = 0; i < stats.Length; i++) { if (longest < stats.Length)longest = stats.Length; } Console.WriteLine("\nStatistics\n"); for (int i = 0; i < stats.Length; i++) { string pad = new string(' ', longest - stats.Length); Console.WriteLine(stats + pad + ":" + '\t' + resul); } } }and finally main which includes functions(static methods) for getting basic info:class Program { static string GetName() { string name; Console.Write("Enter your character name: "); name = Console.ReadLine(); while (true) { if (name.Length > 25) {Console.Write("Name is too long. Try again: ");name = Console.ReadLine(); } else {bool valid = true;for(int i = 0; i < name.Length; i++){ if (char.IsDigit(name) || char.IsSymbol(name) || (char.IsPunctuation(name) && name != '-') && (char.IsPunctuation(name) && name != '\'')) { valid = false; break; }}if (!valid){ Console.Write("Only letters,' ', - and ' allowed. Try again: "); name = Console.ReadLine();}else break; } } //remove multiples Remove(ref name, ' '); Remove(ref name, '-'); Remove(ref name, '\'');//maybe make remove a param argument so it can take a array of chars to remove //Console.WriteLine(name); //tidy up - remove characters that are allowed but should not next to each other //remove any unnecessary characters from the start and end of the string name = name.TrimStart(new char[] { ' ', '-', '\'' }); name = name.TrimEnd(new char[] { ' ', '-', '\'' }); //Console.WriteLine(name); for (int i = 0; i < name.Length; i++) { if (char.IsPunctuation(name) || char.IsWhiteSpace(name)) {while (!char.IsLetter(name))<br>{<br> name = name.Remove(i + <span class="cpp-number">1</span>, <span class="cpp-number">1</span>);<br>}<br> }<br> }<br><br> <span class="cpp-keyword">return</span> name;<br> }<br><br> <span class="cpp-keyword">static</span> <span class="cpp-keyword">void</span> Remove(ref string str, <span class="cpp-keyword">char</span> ch)<br> {<br> <span class="cpp-keyword">for</span> (<span class="cpp-keyword">int</span> i = <span class="cpp-number">0</span>; i < str.Length; i++)<br> {<br> <span class="cpp-keyword">int</span> pos = <span class="cpp-number">0</span>;<br> <span class="cpp-keyword">int</span> length = <span class="cpp-number">0</span>;<br><br> <span class="cpp-keyword">if</span> (i == <span class="cpp-number">0</span> && str<span style="font-weight:bold;"> == ch)<br> {<br>pos = i;<br><span class="cpp-keyword">int</span> j = i;<br><span class="cpp-keyword">while</span> (j < str.Length && str[j] == ch)<br>{<br> length++;<br> j++;<br>}<br><span class="cpp-keyword">if</span> (length > <span class="cpp-number">1</span>)<br>{<br> str = str.Remove(pos, length - <span class="cpp-number">1</span>);<br> i = <span class="cpp-number">0</span>;<br>}<br> }<br> <span class="cpp-keyword">else</span> <span class="cpp-keyword">if</span> (str<span style="font-weight:bold;"> == ch)<br> {<br>pos = i;<br><span class="cpp-keyword">int</span> j = i;<br><span class="cpp-keyword">while</span> (j < str.Length && str[j] == ch)<br>{<br> length++;<br> j++;<br>}<br><br><span class="cpp-keyword">if</span> (length > <span class="cpp-number">1</span>)<br>{<br> <span class="cpp-comment">//string temp = str.Substring(pos, length);</span><br> <span class="cpp-comment">//Console.WriteLine("temp:" + temp);</span><br> str = str.Remove(pos, length - <span class="cpp-number">1</span>);<br> i = i - (length - <span class="cpp-number">1</span>);<br>}<br> }<br> }<br> }<br><br> <span class="cpp-keyword">static</span> Gender GetGender()<br> {<br> string gender;<br><br> Console.Write(<span class="cpp-literal">"Enter the characters gender(Male or Female): "</span>);<br> gender = Console.ReadLine();<br><br> gender = gender.ToLower();<br><br> <span class="cpp-keyword">while</span> (gender != <span class="cpp-literal">"male"</span> && gender != <span class="cpp-literal">"female"</span>)<br> {<br> Console.Write(<span class="cpp-literal">"Please enter a valid gender(Male or Female: "</span>);<br> gender = Console.ReadLine();<br> gender = gender.ToLower();<br> }<br><br> Gender gen;<br><br> <span class="cpp-keyword">if</span> (gender == <span class="cpp-literal">"male"</span>)<br> gen = Gender.Male;<br> <span class="cpp-keyword">else</span><br> gen = Gender.Female;<br><br> <span class="cpp-keyword">return</span> gen;<br> }<br><br> <span class="cpp-keyword">static</span> Race GetRace()<br> {<br> <span class="cpp-keyword">int</span> numEnum = <span class="cpp-keyword">Enum</span>.GetValues(typeof(Race)).Length;<br> Race race = <span class="cpp-number">0</span>;<br><br> <span class="cpp-keyword">int</span> longest = race.ToString().Length;<br><br> <span class="cpp-keyword">for</span> (<span class="cpp-keyword">int</span> i = <span class="cpp-number">0</span>; i < numEnum; i++)<br> {<br> <span class="cpp-keyword">if</span> (longest < race.ToString().Length)<br>longest = race.ToString().Length;<br><br> race++; <br> }<br><br> race = <span class="cpp-number">0</span>;<br><br> Console.WriteLine(<span class="cpp-literal">"Race options:"</span>);<br> <span class="cpp-keyword">for</span> (<span class="cpp-keyword">int</span> i = <span class="cpp-number">0</span>; i < numEnum; i++)<br> {<br> string pad = <span class="cpp-keyword">new</span> string(' ', longest - race.ToString().Length);<br> Console.Write(race + pad + '\t');<br> race++;<br><br> <span class="cpp-keyword">if</span> (i % <span class="cpp-number">3</span> == <span class="cpp-number">2</span>)<br>Console.WriteLine();<br> }<br><br> string[] strArray = <span class="cpp-keyword">new</span> string[numEnum];<br><br> strArray = <span class="cpp-keyword">Enum</span>.GetNames(typeof(Race));<br><br> string tempRace;<br> Console.Write(<span class="cpp-literal">"\nEnter your race: "</span>);<br> tempRace = Console.ReadLine();<br><br> <span class="cpp-keyword">while</span> (<span class="cpp-keyword">true</span>)<br> {<br> <span class="cpp-keyword">bool</span> found = <span class="cpp-keyword">false</span>;<br><br> <span class="cpp-keyword">for</span> (<span class="cpp-keyword">int</span> i = <span class="cpp-number">0</span>; i < strArray.Length; i++)<br> {<br><span class="cpp-keyword">if</span> (strArray<span style="font-weight:bold;">.ToLower() == tempRace.ToLower())<br>{<br> found = <span class="cpp-keyword">true</span>;<br> <span class="cpp-keyword">break</span>;<br>}<br> }<br><br> <span class="cpp-keyword">if</span> (!found)<br> {<br>Console.Write(<span class="cpp-literal">"Invalid input. Please try again: "</span>);<br>tempRace = Console.ReadLine();<br> }<br> <span class="cpp-keyword">else</span><br> {<br>race = (Race)<span class="cpp-keyword">Enum</span>.Parse(typeof(Race), tempRace, <span class="cpp-keyword">true</span>);<br><span class="cpp-keyword">break</span>;<br> }<br><br> }<br><br> <span class="cpp-keyword">return</span> race;<br> }<br><br> <span class="cpp-keyword">static</span> <span class="cpp-keyword">Class</span> GetClass()<br> {<br> <span class="cpp-keyword">int</span> numEnum = <span class="cpp-keyword">Enum</span>.GetValues(typeof(<span class="cpp-keyword">Class</span>)).Length;<br> <span class="cpp-keyword">Class</span> type = <span class="cpp-number">0</span>;<br><br> <span class="cpp-keyword">int</span> longest = type.ToString().Length;<br><br> <span class="cpp-keyword">for</span> (<span class="cpp-keyword">int</span> i = <span class="cpp-number">0</span>; i < numEnum; i++)<br> {<br> <span class="cpp-keyword">if</span> (longest < type.ToString().Length)<br>longest = type.ToString().Length;<br><br> type++;<br> }<br><br> type = <span class="cpp-number">0</span>;<br><br> Console.WriteLine(<span class="cpp-literal">"Class options:"</span>);<br> <span class="cpp-keyword">for</span> (<span class="cpp-keyword">int</span> i = <span class="cpp-number">0</span>; i < numEnum; i++)<br> {<br> string pad = <span class="cpp-keyword">new</span> string(' ', longest - type.ToString().Length);<br> Console.Write(type + pad + <span class="cpp-literal">"\t"</span>);<br> type++;<br><br> <span class="cpp-keyword">if</span> (i % <span class="cpp-number">3</span> == <span class="cpp-number">2</span>)<br>Console.WriteLine();<br> }<br><br> string[] strArray = <span class="cpp-keyword">new</span> string[numEnum];<br><br> strArray = <span class="cpp-keyword">Enum</span>.GetNames(typeof(<span class="cpp-keyword">Class</span>));<br><br> string tempType;<br> Console.Write(<span class="cpp-literal">"\nEnter your Class: "</span>);<br> tempType = Console.ReadLine();<br><br> <span class="cpp-keyword">while</span> (<span class="cpp-keyword">true</span>)<br> {<br> <span class="cpp-keyword">bool</span> found = <span class="cpp-keyword">false</span>;<br><br> <span class="cpp-keyword">for</span> (<span class="cpp-keyword">int</span> i = <span class="cpp-number">0</span>; i < strArray.Length; i++)<br> {<br><span class="cpp-keyword">if</span> (strArray<span style="font-weight:bold;">.ToLower() == tempType.ToLower())<br>{<br> found = <span class="cpp-keyword">true</span>;<br> <span class="cpp-keyword">break</span>;<br>}<br> }<br><br> <span class="cpp-keyword">if</span> (!found)<br> {<br>Console.Write(<span class="cpp-literal">"Invalid input. Please try again: "</span>);<br>tempType = Console.ReadLine();<br> }<br> <span class="cpp-keyword">else</span><br> {<br>type = (<span class="cpp-keyword">Class</span>)<span class="cpp-keyword">Enum</span>.Parse(typeof(<span class="cpp-keyword">Class</span>), tempType, <span class="cpp-keyword">true</span>);<br><span class="cpp-keyword">break</span>;<br> }<br><br> }<br><br> <span class="cpp-keyword">return</span> type;<br> }<br><br> <span class="cpp-keyword">static</span> byte GetLevel()<br> {<br> byte level = <span class="cpp-number">0</span>;<br><br> Console.Write(<span class="cpp-literal">"Enter a level(1 - 20): "</span>);<br> byte.TryParse(Console.ReadLine(), out level);<br><br> <span class="cpp-keyword">while</span> (level < <span class="cpp-number">1</span> || level > <span class="cpp-number">20</span>)<br> {<br> Console.Write(<span class="cpp-literal">"Please enter a value between 1 and 20: "</span>);<br> byte.TryParse(Console.ReadLine(), out level);<br> }<br><br> <span class="cpp-keyword">return</span> level;<br> } <br><br> <span class="cpp-keyword">static</span> <span class="cpp-keyword">void</span> Main(string[] args)<br> {<br> TextReader tr = <span class="cpp-keyword">new</span> StreamReader(<span class="cpp-literal">"picture.txt"</span>);<br> Console.Title = <span class="cpp-literal">"Character Generator"</span>;<br> Console.ForegroundColor = ConsoleColor.Red;<br> Console.WriteLine(tr.ReadToEnd());<br> Console.ResetColor();<br> <br> string repeat = <span class="cpp-literal">"y"</span>;<br><br> <span class="cpp-keyword">while</span> (repeat == <span class="cpp-literal">"y"</span>)<br> {<br> Character player = <span class="cpp-keyword">new</span> Character();<br> string name = GetName();<br> Gender gen = GetGender();<br> Race race = GetRace();<br> <span class="cpp-keyword">Class</span> type = GetClass();<br> byte level = GetLevel();<br><br> player.GenerateRandom(name, gen, race, type, level);<br> player.DisplayStats();<br><br> Console.Write(<span class="cpp-literal">"Create again(y/n): "</span>);<br> repeat = Console.ReadLine();<br> }<br> }<br> }<br>}<br><br></pre></div><!–ENDSCRIPT–><br><br>Finally a few thoughts about the project from myself:<br><br>Initially when I created the character class it consisted of only properties - this is because I thought that when ever somebody used the class they would use these properties and fill in the fields themselves, however as the project went on I realised that this wouldn't be a good idea because sometimes certain fields needed to be filled in before other fields. As a result I decided to give the character class a GenerateRandom method - this brings all control of the creation of a random character under the control of the class creator. After this I added a DisplayStats method which also seemed to me that it should be part of the character class.<br> <br>This makes me think I should either make all the properties private within the character class or have no properties at all, would this be a good idea?<br><br>Also the RaceDef class, I'm not sure if creating this class was a good idea, there is a lot of duplicate code in the various subclasses which I am unhappy with. <br>With the various threads I created regarding this issue(Telestyn if your reading) - is this what I should have been doing?<br>I can't help but feel there is something I'm missing when it comes to creating classes and using them?<br><br>Lastly some of the code in my character class - anything to do with saving throws was taken from SiCranes source code, I think SiCrane implements this in a clever way, my own solution to this would probably to create tables using class and level as indexes to get the correct results - this would be hard coded into the method like most of the other tables in my source code.<br><br>Any feedback would be welcome. |
SDL - problem: surfaces have no color | Engines and Middleware;Programming | I hope someone here can assist me with this problem:I am using SDL in a C++ program. I call SDL_CreateRGBSurface() to create a surface of certain dimensions and a certain color. However, the surface shows up on the screen black, no matter what the R, G, and B values are. It used to show up in color, so I probably made a goof somewhere. When I assign a surface by loading an image from a file, it works fine, but not on the "primitive" way of constructing surfaces. What are all the possible causes of this bug? Here's the call:picture = SDL_CreateRGBSurface( SDL_SWSURFACE, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, SCREEN_BPP, 0x90, 0, 0xFF, 0 );A twist is that it shows up completely invisible if both the alpha and any of the RGB values are greater than 1. I'm not sure if this helps, because I've never bothered with the alpha value.EDIT: SCREEN_BPP is 32. | SDL_CreateRGBSurface doesn't create surfaces of a given colour. It creates blank surfaces of a given format. The last 3 parameters are bitmasks, specifying where the colour is stored within the pixel - in your case, noting which of your 32 bits are allocated to red, green, and blue respectively. ; Thanks for pointing that out to me! I should use SDL_FillRect() to color the surface. Thanks a lot. |
BOJ Productions presents: Araboth | Your Announcements;Community | This is the most current build of my latest project, Araboth.A simple side scrolling shooter in the same vein as such games as Raiden and Ikaruga, the gameplay aspects have been completed. Though it is custom to actually have graphics at this stage, the placeholder "art" (white squares) are just that: placeholders. Updated graphics will come a bit later. Sound falls in the same category.Default controls: WASD for movement, Space = Fire, Q = Swap Shield Polarity, E = Special, F = Slow time, R = Solar Wind (Clear particles), C = Almost halt time.Note: This game is very hard. I have yet to see anyone beat the last level on normal mode. Download Link (8 mb) Just unzip it, and the game should run. It also comes with the most current version of the VC redistibutable and OpenAL redistributable, in case you need to isntall those.Feel free to visit my website too.Any and all criticism welcome (except maybe criticism on the graphics.) | |
What books did developer read for game development in the 1990s? | For Beginners | I want to make a game But I wonder how game developers worked in the 1990s, how they made games, how they learning before the Internet became as widespread as it is today. etc.how do they know how to build game mechanics as character ability power up system?how they know to reverse engineering game competitor company.what book I should read? | As far as I know (not being a programmer myself), books on the subject started appearing in the early 2000s. Up to that point, it was “learn by doing” and tips from one another. ;The first book that came to mind was Tricks of the Game-Programming Gurus: Lamothe, Andre, Ratcliff, John, Tyler, Denise: 9780672305078: Amazon.com: Books, which was geared toward beginners/students/amateurs. There were others, but that's the best selling pre-2000. After that point in time, game development became a hot topic in the book publishing world. Even GameDev.net has a series - Beginning Game Programming: A GameDev.net Collection (Course Technology Cengage Learning): 9781598638059: Computer Science Books @ Amazon.com.Otherwise, in the professional realm a lot was “learn by doing” as Tom said, or through word of mouth on early Usenet/IRC/websites (pre-GameDev.net in 1999 - see About GameDev.net). ;Computers in that era didn't have an OS like we have today. The machine booted, and you were dropped in a command shell or in an interactive BASIC interpreter. You basically programmed directly at the metal. Video memory was directly accessible, by writing in a known address range you could make pixels appear at the screen in various colors. The “OS” had a corner in the memory too for its data, but nothing prevented you from poking around there. Lua, Python, C#, C++ didn't exist, ANSI-C was just invented (K&R book about that was in 1989 iirc). Assembly language of course did exist (with books) and was used.Monthly computer magazines were published for all types of home computers. Tips and tricks were exchanged in that way, also program listings were printed in those magazines that you could then enter at your own computer. Studying those listings, and trying things for yourself is how you learned. There was also technical documentation about the computer.If you want to enjoy that stuff, today there is a retro-computing movement, that lives in that era, except with slight more modern hardware but still no OS, etc.;Alberth said:Computers in that era didn't have an OS like we have today.In the 1990s there was MSDOS, Several versions of Windows, and of MacOS. And that's not all the operating systems of the nineties, most likely.Like Linux, for instance.;Tom Sloper said:Alberth said:Computers in that era didn't have an OS like we have today.In the 1990s there was MSDOS, Several versions of Windows, and of MacOS. And that's not all the operating systems of the nineties, most likely.Like Linux, for instance.Yep. There were things like Windows 95, Win 98, and at the time I was still using a Commodore Amiga (AmigaOS) .To deal with the original question “what game dev books was I reading in the 90s?” Back in that era, one of my favorites was : The Black Art of 3D Game Programming by André LaMothe. ;Abrash was the guy who did the Windows NT graphics subsystem and worked on Quake.https://www.drdobbs.com/parallel/graphics-programming-black-book/184404919 ;There are a couple of" history of video games" books, that track the rise of the medium and genre.Just google for them. ;GeneralJist said:There are a couple of" history of video games" booksThat's not what the OP is looking for.;Thanks all |
Choosing a career in AI programmer? | Games Career Development;Business | Hello everyone, my name is Ramon Diaz; I am currently studying Game development and programming at SNHU. I have taken the initiative to learn about a professional career in AI programming. I have a lot of gaps in my development in the short term. I have blueprint experience with AI but not enough to choose a career in this profession. I would like to know how I can be competitive leaving the university in 5 months after finishing my studies. I am looking for knowledge from all of you who have been in the industry for years. | Entry level? Know your algorithms, it will help you at interviews. If you have made demos it can help you get jobs, but the market is wide open right now and should be relatively easy to find work for the foreseeable future. Overall, it reads like you are on the right path. When you graduate and start looking for work, be open to any positions rather than just an AI specialty. Once you have a job it is easier to transition into whatever specialty you prefer.;Thank you. ;I would like to know how I can be competitive leaving the university in 5 months after finishing my studies.Talk about last minute. Create AI projects? Or A game with character behaviors? Pathfinding examples. Crowd movements. Anything really. Learn how navigation meshes work.;@dpadam450 Character Behavior is what I doing in the project at this moment. Everything related to AI programming.;@dpadam450 Is it the same when learning C++ in AI as visual scripting Blueprint? If I were to make a demo, what kind of programming should I focus on my attention? ;@frob It is important to have a portfolio? ;Not for programming. You will need to show you know how to do the work, but it is usually some interview questions and writing some code of their choice. If you have something you want to share with them, you can do it if you want. Having done fancy demos can sometimes help get interviews, and can help show your interest and abilities, but it is generally not needed. It does not hurt, unless you do it badly and therefore becomes a cautionary warning. Build it if you want. I have interviewed and hired bunches of programmers without portfolios. ;I'm studying AI at the moment, in terms of statistical learning. I've learned so much about AI over the past few weeks. Check out: https://hastie.su.domains/ISLR2/ISLRv2_website.pdfandMachine Learning with R: Expert techniques for predictive modeling, 3rd Edition |
Newbie desperate for advice! | Games Business and Law;Business | Hi allI'm new to the game development community and need some advice.I've created 2 educational games with a simple idea but are sufficiently challenging for all ages. These could be played on pcs or phones.Is it worth patenting any parts of the games?What would be the best way to monetize?How should I market the games? | hendrix7 said:I'm new to the game development communityReally? Your profile shows that you've been a member here since 2004, and your last activity was in 2007, asking about raycasting.hendrix7 said:Is it worth patenting any parts of the games?Probably not. Expensive and there will be hurdles, and possible lawsuits after the patent is granted (if it is).hendrix7 said:What would be the best way to monetize? How should I market the games?There are several threads here in the Business and Law forum about that. While you wait for more replies from the community, you can read up on those previous answers to those questions. Mainly, “you should have thought about that before you finished your games.” (You wouldn't be “desperate” now.) Good luck with your sales!;@hendrix7 Filing for a patent can be expensive, and you need to document the solution and how it separates from anything else. I have developed software that solved problems in a way that no other software does, but there is only a very small portion of that that can actually be patented. Even though you can file an application yourself, I would recommend hiring an experienced IP attorney. This too is very expensive, though, so you are best off doing this if this idea can provide millions in income. If it can't, then it's actually not that harmful if anybody copies it.You could look at registering trademarks, design and other parts of the games. This is cheaper, but it will protect you brand more than your idea or solution.Again, if this is something that could turn a real profit, it might be worth looking into. If not, it's a very costly waste of time.As for marketing - my day job is actually creating videos and commercials etc., so naturally that's the first thing that comes to mind.Make videos for social media or other platforms where your target audience is likely to see it. Oh, and you need to define a target audience. Know where they are, what they respond to, what their struggles are and how your product will solve their problems, enhance their life experience or in other ways contribute positively to their life.There are several other ways to do this, but the list exceeds my level of expertise in the area.;patenting is costly, and time intensive. As said above, it depends on a lot if it's worth it. ;@hendrix7 Nothing is worth patenting unless you're willing and able to defend your patent. There is no patent police; you're responsible for finding and prosecuting infrigement.What you're patenting has to be novel and non-obvious to a person skilled in the art. You called your idea ‘simple’ which makes me wonder if it's obvious or already in use.;@Tom Sloper Thanks TomI have been programming for a while but not games until now.Thanks for getting back and your advice, particularly patents.;@scott8 Thanks for your reply.I see. The play of the game utilises basic maths skills so I'm guessing it'll be difficult to identify anything that's unique. I suppose, in a similar way, it would be difficult to patent something like ‘Wordle’. Am I right? |
Hi I'm new. Unreal best option ? | For Beginners | Hallo everyone. My name is BBCblkn and I'm new on this forum. Nice to virtually meet you 🙂. One of my biggest dreams is to make my own videogame. I love writing design as in text on how my dream game would be. Now I got no skills to create it. But who knows what life will bring. Is Unreal the best program to have fun with an experience ? Obviously I prefer a simple but capable program. Not pre designed auto drop. Why not install Unreal and roam into it and see if anything happens.My favorite games are in the genre of Fantasy, usually stone age with magic. Dota, Homm, Diablo and the odd one out is the genius Starcraft 1. But I played plenty of different games, especially when I way younger. I don't game currently at all but designing gets my creative juices flowing and is so inspiring and fun. Thanks for having me guys | BBCblkn said:My name is BBCblknI am truly sorry for you. Even Elons daughter has a better name than that.BBCblkn said:Is Unreal the best program to have fun with an experience ?Give it a try, but it's not meant for total beginners.Starting small always is a good idea. 2D is easier than 3D. You could try GameMaker, learn some programming language, learn some math, move on to more advanced engines like UE or Unity… ;There's honestly no perfect program for beginners. If I had to compare Unreal though at my skill level, I would probably pick Unity. However, It really comes down to your needs, and how much programming you want to learn. Furthermore, I would also keep in mind other engines.;@BBCblkn I'd recommend Gamemaker studio 2 as a first engine. It's easy to learn and I haven't had a problem making my game ideas in it yet.There are some good tutorials on YouTube to follow to learn it. Do note you'll be limited to 2D games with GMS2.Bit late to the post, but I hope it helps;gamechfo said:Bit late to the postTwo months late. Always consider whether you honestly believe that a question asked long in the past is still awaiting an answer. Thread locked. |
How to publish a book? | GDNet Lounge;Community | Hello, So, over the holidays I finished my 1st book. Do any of yall writer types know where I can find:an editorpublisherIt's like 99% done, just need to know what to do next. Also, it's cross genre, so it doesn't necessarily fit the standard model. | You've given nowhere near enough information to get a final answer, but I can suggest next steps for you. (For background, I've worked as an author, co-author, editor, and ghostwriter on 9 books so far.)Publishing is a business deal. You need to figure out what business services you need.Do you even need a publisher? Do you need a distributor? You already mention needing an editor. Do you need marketing? Do you need retail agreements? Digital or physical? If physical, POD or offset, how many each of hard or soft, what size of print run can you afford? What business services do you need? Publishers have an awful lot of potential features of what they can provide and what those services cost.Once you know the list of services you actually need, your favorite bookstore will have books that have listings of all the major publishers and hundreds of minor publishers, along with the services they provide and the specialties they work with. Work through the listings methodically, and talk to them all until you've got a deal. You'll also want to start shopping around for a lawyer at that point, both because they have connections and because they'll be working with the contracts you'll be signing.Once you know what you need and have talked with your lawyer the first few times, you will be ready to start shopping around. It's far better if you have more money and are using the publisher as a paid service. That is, you pay them for the services they provide up front. It will cost you many thousand dollars but you'll require far fewer sales to reach profitability. It can be better to do an online plus POD service starting out if you're self funded. If they need to front any of the money there will be two phases to the deal, one phase before it's profitable and another after a threshold is reached and it's profitable. The exact terms will depend on your needs and the services they'll be providing. Before you sign with anyone, you'll need to work back and forth more than once with your lawyer to help you negotiate what's fair in the agreement. Good lawyers understand the costs of the various services and can help you get fair rates.Just like publishing games, the more you need from them the harder your pitch becomes. If you need a lot of services the more it will cost you. If you're looking for them to invest in you, front you money, and pay for the books, don't expect a lot of money from the deal, and in addition your pitch needs to be amazing and you'll be rejected many times. If you've got the money to self-publish and are only looking for retail agreements that's rather easy. ;hmmmWell Self publish might work too. I'm looking for:an editor publishing distribution for ebookNo hard cover or physical book planned at this timemaking cover art. Future Audio book production. I think that's it. I'd be willing to do physical print if needed, but I don't really want to pay for that at this time. frob said:You've given nowhere near enough information to get a final answer The issue is I don't know what questions or criteria I should be asking or looking for. ;Have you considered publishing with Packt?https://www.packtpub.com/;GeneralJist said:2. publishing distribution for ebook 3. No hard cover or physical book planned at this timeFor distribution of an ebook there are plenty of options. Amazon is the biggest with kindle direct publishing requiring little more than an html file and an image for the title. If you are comfortable with software tools you can use that same document to build/compile every other format out there. You're on the hook for everything else with the business if you go that route, but it can work well if you are marketing through your own channels.There are many ebook publishers out there targeting specific platforms and specific readers or specific genres. I mentioned publisher lists, they also include electronic-only publishers. Understand the tools they use against piracy are also helpful since otherwise anybody with access to the file can make unlimited copies.Be careful of contracts, you almost certainly want something that has a non-exclusive agreement since you've done all the work yourself already. If a publisher wants an exclusive deal they need to be putting quite a lot on the negotiating table.GeneralJist said:4. making cover art.Find an artist with the style you like and contact them. Often it's in the range of a couple hundred bucks, especially for ‘unknown’ artists when they're starting with something that wouldn't have seen the light of day otherwise. Artist friends are best, and asking around at local art schools is inexpensive.GeneralJist said:5. Future Audio book production.If you don't need it now, it's something easily done later.GeneralJist said:1. an editorThis one is the most difficult. Skilled editors are amazing. If you go with a publishing house they'll provide professional editors, at professional rates. ;taby said:Have you considered publishing with Packt?https://www.packtpub.com/hmmm 1st time hearing of them.Looks like they are more of an educational option?My book is a mix of mental health journey auto bio, and Sci Fi elements. It's not really a standard “how to” for game dev. ;so I just heard back from my 1st publisher submission.https://triggerhub.org/And they essentially say they be willing to look at it deeper, and have extensive edits to focus on the mental health angle. but they would want me to cut a lot. From what they are hinting at, It sounds like they want to cut a lot of the Game dev and gaming journey, as they are a publisher focused on mental health.So, now I need to decide what to do.I sent them back an email saying I'm open to continued dialogue.Without knowing exactly what they want to cut, and edit, I don't know how to proceed.Also, would it be better to hold out, and find a publisher that is willing to accept most of the game dev journey, as I'm looking for a continued publisher to work with, aka accept most of the book as is. Any advice would be helpful.Thanks yall. ;GeneralJist said:Any advice would be helpful.Look into your own mind and heart.;hmmmok,So I've submitted to a few other places.We shall see.I submitted to this place called author House, and they got back to me really quick, but it looks like they want me to pay a couple thousand for a package:https://www.authorhouse.com/en/catalog/black-and-white-packagesI personally find that a bit frustrating.I mean, really, I wrote the book, I thought traditional publishers get paid from a % of sales?@frobWhat do you think?Is the above package a good deal?I was also a little put off, as it seems the person who called me didn't even read anything about my book, and asked me “so what's your book about?"beyond the above, how does this usually work? Edit: so, after a bit of basic research, it seems the above organization is a bit scamy. The hunt continues. ;You're unlikely to get a publisher deal, where the publisher pays you an advance and distributes your book to retail outlets.You'll have to self-publish, meaning you have to bear all the costs for printing, and nobody will distribute it for you. https://en.wikipedia.org/wiki/Vanity_press |
First-person terrain navigation frustum clipping problem | General and Gameplay Programming;Programming | I am trying to develop first-person terrain navigation. I am able to read a terrain and render it as well as to move around the terrain by interpolating the location of the camera every time I move around. The main problem I have is that depending on the terrain, i.e. moving on a sloping terrain, the near plane clips my view (see below). What is the best way to avoid this? Presumably, I can interpolate the heights for the bottom corners of the near plane … any help would be appreciated. | I believe this can aways be an issue. I mean if you are clipping to a near plane and that plane passes through geometry, it has to do something. That being said you technically don't have to clip to a near plane at all, however many graphics APIs require it. Another other thing to consider is once you have collision working, you can put your camera, including your near clipping plane inside a collidable object, for instance a sphere, such that this problem will never occur. If you are eventually going to make this a real first-person game, that should take care of the problem since your camera will be inside the players head. Even in a 3rd person game you can put them inside a floating sphere. ;Gnollrunner said:That being said you technically don't have to clip to a near plane at all, however many graphics APIs require it.The near clip plane is always needed, even if you use a software rasterizer. If you don't do the clipping, vertices would flip behind the camera, causing glitches way worse than what we get from clipping.mllobera said:What is the best way to avoid this? Presumably, I can interpolate the heights for the bottom corners of the near plane … any help would be appreciated.Yes, basically you want to ensure that the camera is in empty space (above the hightmap), not in solid space (below the heightmap).But in general you can not treat the camera as a simple point, because the front clip plane requires a distance larger than zero. So ideally you build a sphere around the camera which bounds the front clip rectangle of the frustum, and then you make sure the sphere is entirely in empty space, for example. In the specific case of your terrain not having too steep slopes however, it should work well enough to sample height below camera, add some ‘character height’, and place the camera there. That's pretty simple and usually good enough for terrain.It's quite a difficult problem mainly for 3rd person games in levels made from architecture. It's difficult to project the camera out of solid space in ways so the motion still feels smooth and predictable.Some games additionally fade out geometry which is too close, attempting to minimize the issue.Imo, the ‘true’ solution to the problem would be to let the clipping happen, but rendering the interior volume of the geometry as sliced by the clipping plane.That's pretty hard with modern rendering, which usually lacks a definition of solid or empty space. But it was easy to do in the days of Doom / Quake software rendering. When i did such engine, it was possible to render clipped solid walls in simple black color. This felt really robust and not glitchy, so while it does not solve all related problems, i wonder why no game ever did this. ;@undefinedJoeJ said:The near clip plane is always needed, even if you use a software rasterizer. If you don't do the clipping, vertices would flip behind the camera, causing glitches way worse than what we get from clipping.You can clip to a pyramid instead of a frustum. I used to do this many years ago on old hardware. So there is no near clipping plane. In fact you don't need a far clipping plane either.Edit: Just wanted to add as far as I know the near and far clipping planes mostly have to do with optimizing your Z resolution. If you are dealing with that in other ways, I think they aren't strictly necessary. I currently don't even deal with the far plane and let LOD solve Z-fighting issues.;Gnollrunner said:You can clip to a pyramid instead of a frustum.I see. You still have front clip. It is a point, formed indirectly as the intersection of the other other frustum planes.I've misunderstood your claim to be ‘you don't need a front clip’. But you didn't say say that. Sorry. But now i'm curious about the experience with z precision you have had. I guess it just worked? Which then would probably mean: All those painful compromises of ‘make front plane distant so you get acceptable depth precision for large scenes’, are a result of a bad convention being used by APIs?Or did you use no z-Buffer? ;@undefined My whole engine is based on aggressive LOD and culling. I don't do projection in the matrix. It's a post step. My Z coordinates are world distances. My current project does have a near clipping plane mainly because DirectX wants one, but it's not that relevant for my application.;Ah, so you use the pyramid for culling only. But for rasterization, the usual front clip plane at some distance i guess.Still an interesting question if ‘some distance’ is really needed, but i guess yes.I did some experiment about point splatting. It uses spherical projection, which is simple than planar projection:auto WorldToScreen = [&](Vec4 w){Vec4 local = camera.inverseWorld * w;if (local[2] < .1f) return (Vec3(-1)); // <- front clip at some distance of 0.1Vec3 screen = (Vec3&)local;screen[2] = length(screen); // if it was zero, i'd get NaN herescreen[0] = (1 + screen[0] / (screen[2] * camera.fov)) / 2;screen[1] = (1 + screen[1] / (screen[2] * camera.fov)) / 2;return screen;}; Planar projection would cause division by zero too, i guess.;Thanks for all your comments! I will need to investigate how to do what Gnollrunner proposed (about putting the camera inside of a sphere). ;This may be obvious, but in case it helps:Let me note that, as a first-person camera may be more likely than a third-person camera to draw very close to geometry, it likely makes some sense to have a smaller near-plane distance for the former than the latter.Now, this only ameliorates the problem, it doesn't remove it entirely: it means that the problem will still appear, but only if the player gets very close indeed to a surface. It's intended to be used in conjunction with one or another means of preventing the camera from approaching quite so near to a surface (such as the sphere-approach mentioned by others above).;Thaumaturge said:This may be obvious, but in case it helps:Let me note that, as a first-person camera may be more likely than a third-person camera to draw very close to geometry, I'm not sure that's so true. I mean in both cases you have to take care of the problem somehow. The case of a first-person camera is a bit easier because it should always be in the collision boundary of the player (sphere(s), ellipsoid, capsule etc.). As along as the near plane is also within that boundary, the problem should never occur. So if you have a 10cm radius sphere and put the camera in the back of it, that gives you maybe a 10 to 15 cm camera to near clipping plane distance to play with depending on the field of view you are going for. With a 3rd person camera, you can also get very close to terrain, in fact your camera can end up within terrain or some object if you don't do anything to solve that problem, and this will happen very often without separate camera collision. One typical way to handle this is just implement your following camera, ignoring terrain considerations. Then to figure out your camera's actual position, project a line back from the head of the avatar to the camera's ostensible position, and see if it intersects anything to get the camera's true position. In reality you should project a cylinder and not a line since your camera will need its own bounding sphere to contain the near clipping plane. In any case this means that as you move around your camera can jump forward to clear terrain and objects. I've seen this in a few MMOs. However, when you leave blocking terrain you have the option of implementing smooth movement back to the cameras desired location. If you want to get really fancy, I guess you could try to predict when your camera will need to jump forward ahead of time and try to do smooth moment forward too. Maybe you can have a second camera bounding sphere which is somewhat larger, that would trigger smooth movement, but I think you would still need a fallback camera jump routine to be safe. |
What annual salaries for a Game Designer, junior pos. at Vancouver, Canada? | Games Business and Law;Business | Maybe some of you may know. What annual salaries can I take into account when I'm working as a Junior Game Designer at Vancouver, Canada? It will be a next-gen mmorpg game.I did some research and from Games Dev Magazine Salaries Survey it's 61.000$ average? I want to propose 51.000. Is it ok? Too much? What do you think? To Canadians: suppose I'll get 41.000$/year. It's ok to live in Vancouver as a single, 1-room apartment?I'd really appreciate your help! | Well, I'm working in Vancouver as an engineer (games). I started two years ago at $48,000. Currently new hires seem to be getting around $50,000 (as of last year at least). Although depending on the company you'll get raises quickly once you prove your competence (I'm making much more than $48,000 now). ; Oh and as for living. Vancouver is pretty expensive, but there are affordable 1-bedrooms if you take the time to look (there are cheap ones but they tend to be pretty gross). ; Totally depends on the company, not sure for designers. For engineers in vancouver a startup will usually be between 25-35k. A reputable game company usually starts there engineers around 50k. As far as living in vancouver goes, depends on how much you want to commute. You can live out in the burbs in a decent sized basement suite for as low as 600-700 but you're going to be commuting an hour a day on skytrain. Apartments closer to downtown are going to be more in the 1000-1200 range. ; Thanks guys for such a quick answer. It really helps me a lot. So You think that I can for sure start and try to propose 51.000$? And then eventually I'll bid down. ; Here is a quick trick to know the cost of life differential between two cities, or at least a pretty darn approximation of it. It's called the Big Mac Index ( clicky ). You take a Big Mac trio at both cities and the bills' ratio gives you a ponderation factor. That's because - according to the theory - MacDonalds is using local products, has local outlets, and need to pay local electricity and gas, etc, and that McDonalds has a fixed % markup on its prices based on costs. So for two equal purchases at two cities, the ratio will take into account housing costs, gazoline, groceries, etc, all the things that make up a person's normal living expenses.-cb ; Great thread ! I`d like to ask what is the salary range, in Vancouver, for a gfx/engine/gameplay programmer with 6 years experience in DirectX/C++ and about 3 finished titles ?Thanks ; Realize that the Game Developer's Annual Survery reports numbers that are a bit higher than a starting out salary and doesn't take things such as health insurance and whatnot into account. An entry level game designer makes fairly significantly less than someone with three years experience and possibly multiple shipped titles under their belt. Location drastically affects things as well.For instance, I just started as an entry level designer for a 3rd party Nintendo developer in Springfield, MO, which has an extremely low cost of living. I started at 30k, but I'll have really, really nice insurance when my probationary period ends. Asking 51k in Vancouver to work on a big title is certainly reasonable, but don't be surprised if they don't offer that. Look at other benefits they offer as well. Benefits are extremely expensive.Quote:joe1024I`d like to ask what is the salary range, in Vancouver, for a gfx/engine/gameplay programmer with 6 years experience in DirectX/C++ and about 3 finished titlesWhat do you mean by "about finished"? What kinds of project are these? ; Is this 6 years of experience programming for a company? When you say 3 finished titles, do you mean shipped titles? What kind of games were they? ;Quote:Original post by zer0wolfRealize that the Game Developer's Annual Survery reports numbers that are a bit higher than a starting out salary and doesn't take things such as health insurance and whatnot into account. I`m not aware of GD`s Annual Salary Survey to cover other areas than U.S. specifically. Sure, there were summary numbers for "Europe" and such, but considering that Europe consists of dozen states (with gamedev at reasonable level), costs of living are drastically different, thus the number is irrelevant and incomparable to anything else.Quote:Original post by zer0wolfAn entry level game designer makes fairly significantly less than someone with three years experience and possibly multiple shipped titles under their belt. That`s obvious, I just don`t understand the part with "multiple titles within 3 yrs experience". Sounds like someone hopping from company to company and never finishing any title. 3 yrs is enough to enter one company at about half of the cycle, finish the title and possibly start another title.Quote:Original post by zer0wolfLocation drastically affects things as well.You forgot the timing, which is probably even more important (though it may not seem so obvious at first, I admit). Especially considering we`re talking about Vancouver. I`ve been watching the costs of living in Vancouver during last few years and recently prices of houses have risen quite a lot. Seems some areas doubled in the price during last few years.And i`m pretty sure that wages have risen just few percents (please confirm, I`m wrong here), so a salary of $50k doesn`t seem like a salary on which I could feed my family and pay all the bills.Quote:Original post by zer0wolfBenefits are extremely expensive.Especially if the company pays for the medical insurance for whole family. Though, I`ve seen that only few times. What is the "norm" in Vancouver area in this regard ?Quote:Original post by zer0wolfWhat do you mean by "about finished"? What kinds of project are these?Two titles went into distribution (PC budget), third one still doesn`t have the publisher/distributor.Quote:Original post by iKidIs this 6 years of experience programming for a company? When you say 3 finished titles, do you mean shipped titles? What kind of games were they?Is your company looking for programmers :-) ? I could send you my portfolio link ;-) |
Removing scrollbars in a console application | General and Gameplay Programming;Programming | Hello;I am working on a small console based game using Win32 console functions.As you may know the default size of the console apps is 80x25 well.. characters? In my case I need the width to be something near to 40.But doing that using the API function "SetConsoleScreenBufferSize" doesn't seem to work.In fact,this function fails when a screen buffer size is given smaller than 80.Therefore,I make a screen buffer which has the size 80x50 and use the "SetConsoleWindowInfo" function to give the application the desired size,by modifying its window,instead of the screen buffer.This works,but when the window is smaller than the screen buffer,scroll bars appear on the edges by default.I totaly hate this behavior because the actual thing should happen in the 40x50 sized part which the window shows initially.If the user scrolls to right for example,she/he will see an useless,annoying,black area..I even gave to the "FindWindow" function the title name of my program and acquired the HWND of my window,which is an unusual thing to do in a console app.(Win32 doesn't have any direct method for obtaining the console window handles.)I call "GetScrollInfo" using the HWND I obtain,but interestingly the function doesn't return anything altough a horizontal scrollbar just sits under the window and annoys me..My google searches weren't helpful,too.So I need some advice for what to do..Thanks in advance.. | SetConsoleScreenBufferSize() won't reduce the buffer size to be smaller than the window size. So in order to shrink the buffer you need to first shrink the window with SetConsoleWindowInfo() and then call SetConsoleScreenBufferSize() to shrink the screen buffer. ; And this has just solved my problem,it seems..Thank you very much. |
generating a random tree, my algorithm isn't correct? | General and Gameplay Programming;Programming | I came up with a very simple algorithm for generating a tree for testing a particular problem I'm working on. However one of my friends claims my algorithm is incorrect and will create loopbacks. I however do not see this and would like a third opinion.Its pretty simple, I start with a single root node(1) and do the following:for(int j = 2, 3, ..., N) i = random(1 to j - 1) create edge(i, j)That's it. So when j = 2, i can only go from 1 to j - 1, and hence i only equals 1. So in my adjacency matrix, I set edge(1,2), which means root node has the new node(2) as a child. And this continues for N nodes.Does anybody see a problem with this? | No, that looks fine WRT cycles. I'm not sure about the statistical properties of the generated tree, and it looks as though average branching factors will differ between levels. Is this a problem? ; No, it doesn't matter if node levels are even or not. I was just told something was wrong with it and I don't see ANYTHING programatically or functionally wrong with it. ; Simple proof: each node except the root (the first) will have exactly one incoming edge, and cycles are impossible because each edge always goes from a node of a lower number to a node with a greater number. Therefore this algorithm creates a tree. |
A multiplatform clipboard library | General and Gameplay Programming;Programming | Hello,I wonder if there are any libraries for multiplatform clipboard access.I would like to be able to read from and write to Window's clipboard and to read from & write to linux clipboard.If there are no such libraries, I would like to know how can I access linux's clipboard since I found some useful winapi functions from MSDN.Thank You,Indrek Sünter | wxWidgets; So, there are no stand-alone libraries for handling clipboards?It could be possible to use a part of wxWidget's source code.The whole library is too big to use only the clipboard functions..Thank You,Indrek Sünter ;Quote:Original post by IndrekSntSo, there are no stand-alone libraries for handling clipboards?Clipboard, whatever that means, is purely OS specific functionality. Clipboard, by itself, is the same as using shared memory, or a file to store raw binary data. It's the OS-provided functions that makes it useful and context aware.Let's say you put a block of formatted text on it from FireFox, and paste that into Word. Clipboard is the whole context-aware conversion system that transforms text/ascii/7-bit HTML chunk into MS Word 7.0 representation. That's a lot of conversions and type information to handle. It's not as simple as put/get.Anything below that, and you might as well write to files - but you'd be unable to use that in any meaningful fashion. How do you represent *anything*, even a fraction of something in a meaningful manner?; I just need to copy text into it or paste out.Its just that I need it to be compatible with both: windows and linux..Thank You,Indrek Sünter |
Start of Game Development Blog & FREE GAMES | Your Announcements;Community | Hello,This is just a quick e-mail to let people know hat I’ve started a blog to cover the game development of our first game “Lucky 7”. I stuck a help wanted post on the forums, (http://www.gamedev.net/community/forums/topic.asp?topic_id=454629&whichpage=1�) so I guess it seems only far to keep people who are interested up to date. I’ll try to update it at least twice a month and definitely more, if there’s been a lot of action.I’ve also stuck some old phone games (Java based) that we worked on under the old name of “Angry Beaver” on the site (still like that name for a company). Feel free to download them and have a play.Thanks,Mike Moore.www.badbumble.com | |
s3tc boosted fps by 100% | Graphics and GPU Programming;Programming | 1024 x 1024 palletized no tiling / 6 polygons - 127fpshttp://i37.photobucket.com/albums/e78/3dshots/Shot0008.jpg1024 x 1024 DXT1 no tiling / 6 polygons - 192fpshttp://i37.photobucket.com/albums/e78/3dshots/Shot0007.jpg1024 x 1024 DXT1 tiling / 6 polygons - 100fps http://i37.photobucket.com/albums/e78/3dshots/Shot0009.jpg1024 x 1024 palletized tiling / 6 polygons - 54fpshttp://i37.photobucket.com/albums/e78/3dshots/Shot0002.jpg1024 x 1024 DXT1 / 4 textures / 24 polygons - 106fpshttp://i37.photobucket.com/albums/e78/3dshots/Shot0005.jpg1024 x 1024 palletized / 4 textures / 24 polygons - 53fpshttp://i37.photobucket.com/albums/e78/3dshots/Shot0003.jpg2048 x 2048 DXT1 / 6 polygons - 79fpshttp://i37.photobucket.com/albums/e78/3dshots/Shot0004.jpg2048 x 2048 palletized / 6 polygons - 56fpshttp://i37.photobucket.com/albums/e78/3dshots/Shot0001.jpg2048 x 2048 x 24bits uncompressed= 12MB2048 x 2048 x 24bits compressed= 2MB2048 x 2048 x 8bits = 2,5MB[Edited by - sopa_de_letras on September 6, 2007 5:26:47 PM] | Because the framerates are over 100, the first batch of results don't seem terribly useful; strange things happen up there. And remember that the primary speed benefits of texture compression are realized when you have to page textures in and out of vidcard memory. ;Quote:Original post by sopa_de_letrasI made these tests in Unreal Tournament 1 using lastest OpenGL drivers and MX440.You registered only to tell us this ? Anyway, you are using a graphics card from the stoneage for these tests. They are essentially meaningless. Modern graphics cards don't even support palleted textures anymore.;Quote:Original post by Yann LQuote:Original post by sopa_de_letrasI made these tests in Unreal Tournament 1 using lastest OpenGL drivers and MX440.You registered only to tell us this ? Anyway, you are using a graphics card from the stoneage for these tests. They are essentially meaningless. Modern graphics cards don't even support palleted textures anymore.Thanks! ; Boo to abusing the edit-post feature!These forums aren't just for *you* to get answers, they also exist so that other people can come along and read them and be educated. ; I was and still am stratching my head because those framerate variations are weird, it's weird that a simple thing as repeating the texture over a large surface causes so much fps hit.Unless the STAT FPS statistics are all wrong. ;Quote:Original post by sopa_de_letrasI was and still am stratching my head because those framerate variations are weird, it's weird that a simple thing as repeating the texture over a large surface causes so much fps hit.Repeating a texture multiple times over a large surface tends to make the texture caches unhappy, especially on an old card such as the MX440. A non-repeated texture is more coherent and will make much better use of the cache.; I did another quick test just for checking. 256 x 256 x 256 cube, one texture, no lightmaps and nothing, 295fps.Now the same as above, but with a 1024 cube, got about 50% fps hit. WTF is that? bad engine rendering code? ; Yes Unreal has bad engine coding...good thing you have made this discovery. ;Quote:Original post by Matt AufderheideYes Unreal has bad engine coding...good thing you have made this discovery.[Edit by jpetrie: That was not appropriate.][Edited by - jpetrie on September 10, 2007 2:29:35 PM] |
Tech and Fantasy | Game Design and Theory;Game Design | What are some ways to imitate tech in a fantasy world? I am thinking of computer terminals specifically.Also, how might a mid/high tech world be melded with mid/high fantasy? | Some enchanted stones which can be set up to communicate with each other by writing? (scribble on one and it appears on the other)There are mysterious channels that run through the world, and if you place a suitably prepared obelisk over one of them it becomes a gateway through which communication with the channels is possible.I don't know how to answer your second question... can you give more background on what exactly you're hoping for? ; Hey I always found that making magic run machines was quite a good way of doing this. Say instead of engine you have like a magic core. The key is making sure you have the two working in harmony (or not actually both works) if you're thinking about computer terminals, have them made out of stone/wood and have the computer screen made out of magic glass, have a pipe coming out of its back with magic green smoke coming out of it, make it emit a strange sound, some kind of whirling or sparking. Just some ideas, can't really think too much in detail at the moment.But I always like to hear people putting both Magic and Tech in their games.EDIT: Think Final Fantasy, the earlier ones.Cheers. ; So... you want steampunk? ; I very much like the idea of magic-based technology. ^_^One idea that occurs to me as being fairly obvious is that of constructs taking the place of robots.On the subject of computers, consider some of the things that magic might be able to do (depending heavily, of course, on your magic system):Create illusions in mid-air - much like a hologram, not so? Thus magic might allow for something akin to a holographic screen, in which the illusion spell is controlled by the main computing apparatus.Completing a spell has an effect, which could be seen as analogous to the completion of a circuit having an effect on the charge within it. Given this, perhaps a magi-pc might consist in part of partial simple spells in separated crystals (or metal rods, or whatever container for spells is appropriate). Bringing these parts together, either magically or mechanically, might complete the spell and allow for knock-on effects - perhaps adding up to computing, given appropraite arrangement of sufficient and well-enough chosen parts?A spell has an effect of some sort (at least if successful), which might be complex. Might a single, highly complex spell not act similarly to a computer?Note that communications devices seem to be fairly common in fantasy (scrying crystals, for instance, a good example of which might be the palantiri of Tolkein's world). These might be useful in your magical technology - for example, as sensory devices.On a stylistic note, I would suggest metals as the main casing materials of my magi-pc, depending heavily on both your desired aesthetic style and any relevant magical concerns that might come into play (iron, for instance, may disrupt some magics, or silver prove an excellent conductor or amplifier for it, at your choice).Such things as flight are fairly simply treated in most fantasy work, I believe (although I seem to recall that Robert Jordan's Wheel of Time series considers it to be rather difficult, and reasonably so, I would say).What sort of technology might you want to emulate?And, for that matter, how might a magic-based society differ from a technological one? Such a society may well develop in ways very different from one reliant on technology, I suspect... ; hmm. thank you for the suggestions so far.First of all, what is steampunk?Also, I I am thinking of making a fantasy RPG (yes i asked about horror in my other thread, but I think im going to come up with a good fantasy plot and go with that because I dont really want to make a horror game). I dont know if I want to imitate tech in a pure magic world, or just have them coexist. Would it be strangely out of place to have computer terminals built into walls? I considered the suggestions y'all made and honestly im really attracted to the idea of just using terminals to giv ethe player messages rather than trying to make something else with similar effects.What sort of visual and gameplay elements smack of tech? I dont want a grunge metal and conduits setting, but i dont want it to seem odd to run into a piece of tech like a computer screen in the wall or anything else techlike. ; Steampunk is a sub-genre of fantasy/sci-fi where many of the crazy inventions of the Victorian era actually work. Think giant steam powered robot spiders, dirigible yachts, clockwork golems....A game called arcanum implemented this, sort of. The steampunk stuff was at odds with magic stuff, and one failed to work around the other. Good idea/story, middling game.The final fantasy series also have done the 'terminals don't seem out of place' thing really well; usually via a "technology of the elders" sort of plot device.I'm ponding similar things for my game, and the key (imo) is creating the 'physics' for your magic first. What can it do, what's the range, who can use it, how often, at what price? You'll then have a much better idea about what sort of real world stuff it would replace or adjunct. ; I think anything like computer terminals would seem very odd in a standard medieval-fantasy setting. You might be able to do something interesting with a retro-futuristic art deco-ish look, though. I would merge the tech and magic rather than having them coexist, though. It seems to make more sense.What exactly do you want to do with these computer terminals, anyway? ;Quote:I think anything like computer terminals would seem very odd in a standard medieval-fantasy setting.Not really. Its been done since the 80s. Wizardry, Might&Magic, Final Fantasy...there is also such a thing as "technomage".Quote:What are some ways to imitate tech in a fantasy world? I am thinking of computer terminals specifically.Trees.A forest is a natural network, and trees are the terminals.Quote:I'm ponding similar things for my game, and the key (imo) is creating the 'physics' for your magic first. What can it do, what's the range, who can use it, how often, at what price? You'll then have a much better idea about what sort of real world stuff it would replace or adjunct.Hehe, i'll point you to this article :http://www.designersnotebook.com/Columns/017_Magic/017_magic.htm ; i intend on the PCs being brought to a place unexpectedly, with no other NPCs around to talk to, save the monsters. The terminals are there for the non-personal communication of the PCs with others (obviously unknown to the PCs).I was just thinking, what if the medieval magic and modern tech are explained by the melding of two cultures from two different worlds. one without tech, the other without magic. they recognized that they each had something the other didnt and the other something they wanted, they began relations and traded magic for tech.after a few hundred years, this would yield, a society with tech, magic, magic powered tech, tech controlled magic, medieval relicts still in use, possible improved by both tech and magic.I'm sure that idea has been done somewhere at some point, so would anyone like to tell me if it worked very well? I think it could meld it all together well and allow the freedom for everything from computers to swords and armor to magic shields and fireballs.PS: A few things I don't want in my game though;cars and guns |
Advanced Degrees? | GDNet Lounge;Community | Hi all. I am currently finishing up a B.S. in CS. However, I'm not sure as to whether I want to go straight into working. I was considering advanced degrees, such as M.S. in SE or CS, however, it seems(from pages/course descriptions) like the M.S. in CS would just be a rehash of what my B.S. was(is this accurate?) . With PhDs, you need to do research for 2 1/2 years(8 hour days?) or more usually? That seems kind of long to be researching the same thing.. Is it boring to be doing that? Also, what if the thing you are working on can't be solved(or can't be solved by you). Wouldn't that mean you just wasted 2-3 years? Anyway, i was hoping someone here might have completed an advanced degree in comp sci/Software Engineering or would provide feedback. I'm very interested in Software Engineering, but I am unsure of the benefits of obtaining a M.S. if I already have a B.S. in Computer Science. I am also unsure of whether to keep going, and get a M.S. in SE or CS, or a PhD. Another option is to keep working as a Software Engineer. What option would make the most sense? Thanks | Do a Masters or Phd if you are actually interested in the subject. Otherwise, get a job. ;Quote:What option would make the most sense? What makes the most sense for you is something that only you can decide.Quote:However, I'm not sure as to whether I want to go straight into working. It is easiest to get a graduate degree before entering the work force because you aren't really dependent on the salary to support a family, a mortgage, and other expenses.If you are interested in additional education, you should get it. If you are sick of school and can't stand the thought, then obviously you should get a job. If you are just afraid of change, you should do some serious soul searching and perhaps get some career and education counseling, maybe even some psychology counseling if your school offers a few sessions for free.Quote:I'm very interested in Software Engineering, but I am unsure of the benefits of obtaining a M.S. if I already have a B.S. in Computer Science.First, you must know that your educational experience is whatever you make of it. You can go to class and learn nothing, or you can go to classes and learn everything presented. Or you can take full advantage of the University and go far beyond anything that is presented by taking initiative.Next, know that every graduate school is different. One school may have an extremely theoretical approach, another might have a very practical "you will use this" approach, yet another will have a goal of getting papers published, another of getting research grants and funding or of doing new original research, or of extending existing research or.... you get the point.Finally, know that ever student works with an adviser to build a program of study that is personalized for them. As for your question about if it is just an extension to a BS degree, the answer is "no". There are very few required courses -- my school had four of them, and two were courses I would have taken anyway. If you want to learn everything there is to know about machine learning techniques, then you can specialize there and never take another class on topics you hate. If you intend to learn about parallel and networked processing, you can take classes on that instead. A masters degree may require a thesis at some schools, while others have coursework-only options.Quote:With PhDs, you need to do research for 2 1/2 years(8 hour days?) or more usually? That seems kind of long to be researching the same thing.. Is it boring to be doing that? Also, what if the thing you are working on can't be solved(or can't be solved by you). Wouldn't that mean you just wasted 2-3 years?A PhD will continue on that vein focusing on a single specific topic. It will almost always require a dissertation requiring several hundred hours of original research and generally resulting in one or more published papers. Some schools will accept a collection of published papers in lieu of a dissertation. I don't know of any CS schools that have non-research PhD programs.The amount of research involved varies by school. It will probably be a minimum of 18 credit hours, more or less. Because of the intensity required at the graduate level, it will be around 500 hours minimum. For comparison, that's about 3 months of full time employment, which is 2000 hours/year.If the problem is something that cannot be solved, then you have done your dissertation by proving that it cannot be solved. Congratulations!If the problem cannot be solved within a reasonable time frame of three to four years of part time effort, your doctorate adviser should be severely punished, and you should also take a lot of blame for not knowing what you were getting in to.Quote:I am unsure of the benefitsThe educational and academic benefits should be obvious. The employment benefit of a masters degree is that you earn much more money through your career. You will generally be initially employed a few rungs up the career ladder. You will generally be more able to move across careers, and more quickly move into leadership roles.With a PhD you earn more but typically cannot get the same types of jobs. You will focus on less directed research on a specific area. Typically PhDs earn more money, but due to the specialization they have severely limited opportunities for lateral and vertical career migration. Unless you are interested in teaching, or interested in specialized research, or interested in specialized implementations such as advanced computer physics, a PhD is generally overkill.Once you are nearly finished with a masters degree, you should be qualified to know if you should apply for a doctoral program. ; Agreed; only get an advanced degree if you are very interested in the topic you are studying. If you aren't interested in your research, you won't do as well and it will be a bad experience for you. Don't go just to avoid getting a job in the "real world". ;Quote:Original post by nagromoAgreed; only get an advanced degree if you are very interested in the topic you are studying. If you aren't interested in your research, you won't do as well and it will be a bad experience for you. Don't go just to avoid getting a job in the "real world".Or just getting a job and then going back for your Phd later is always another option. That's what alot of my professors at community college did go back and get their phd after teaching for several years.One thing I noticed thought is that the ones that went on to get their Phd's don't teach anymore and are in higher paying administrative jobs buy this is community college and not all professors have phd's in the first place like at a 4 year school.; So basically the PhD isn't a good idea if I want to work as a Software Engineer?Also, is it better to get a M.S. in CS or SE? Seems like SE would be more practical, but not many schools seem to offer that kind of degree. ;Quote:Original post by ginkeqSo basically the PhD isn't a good idea if I want to work as a Software Engineer?Also, is it better to get a M.S. in CS or SE? Seems like SE would be more practical, but not many schools seem to offer that kind of degree.I am also searching for schools these days. CMU seems to offer one ;Quote:Original post by ginkeqSo basically the PhD isn't a good idea if I want to work as a Software Engineer?Also, is it better to get a M.S. in CS or SE? Seems like SE would be more practical, but not many schools seem to offer that kind of degree.There are many different definitions of "Software Engineer".If you want to work as a code monkey or 'normal' worker, a PhD is a very bad idea. Prefer a BS.If you want to work in a software development leadership role, a PhD is a bad idea. Prefer a MS.If you want to work as a technical director or moderate research, a PhD is not a good idea. Prefer a MS.If you want to work in pure research or academia, a PhD is a very good idea. The highest of research jobs require a PhD outright.;Quote:Original post by ginkeqHi all. I am currently finishing up a B.S. in CS. However, I'm not sure as to whether I want to go straight into working. I was considering advanced degrees, such as M.S. in SE or CS, however, it seems(from pages/course descriptions) like the M.S. in CS would just be a rehash of what my B.S. was(is this accurate?) .You'll probably cover many of the same topics, but at a higher level. To say it's just a rehash would be like me saying that college physics was just a rehash of the physics course I took in high school.Quote:With PhDs, you need to do research for 2 1/2 years(8 hour days?) or more usually? That seems kind of long to be researching the same thing.. Is it boring to be doing that? Also, what if the thing you are working on can't be solved(or can't be solved by you). Wouldn't that mean you just wasted 2-3 years?If you're thinking about getting a PhD, here's the advice I'd give you: If you think researching the same thing 8 hours a day for 2 1/2 years would be boring, a PhD isn't for you. If you think finding that a topic cannot be solved means your research work was wasted, then a PhD isn't for you.I'm sure there are exceptions, but most PhD students don't mind taking their time getting their PhD because the general idea is to get a PhD, get a post-doc, then get a permament research position somewhere (national lab, professorship at a university, etc.). Basically, they don't mind taking their time getting their PhD because that's the sort of work they want to do for the rest of their lives. If the idea of researching a topic for 2 1/2 years bores you, then think about doing that for the rest of your life. On the other hand, it's basically the dream job for the people who do it.Quote:I am also unsure of whether to keep going, and get a M.S. in SE or CS, or a PhD. Another option is to keep working as a Software Engineer. What option would make the most sense?I think frob broke it down really well.For what it's worth, I was a PhD student. My advisor is moving so I took that as a chance to reevaluate where I was headed. I decided to get an MS instead for reasons similar to what I was saying above.;Quote:Original post by frob[...]The educational and academic benefits should be obvious.[...]Quite the contrary - I don't understand what I can get studying something at school that I can't get studying it at home. I can still talk to the same people, buy the same books, read the same papers, etc. The only real benefit might be if the school will provide hardware or software too expensive to buy for yourself, but then again, you might actually be able to afford them if you put the money toward equipment instead of school.The paper itself will obviously help with employment (though I'm not sure it's better than an equal period of work experience), but the academic and educational benefits are not obvious to me. |
3D Math beginner & oliii's collision tutorials | For Beginners | I'm really a beginner in terms of 3D mathematics but today I started reading oliii's collision tutorials. I'm stuck right at the begining at the axis separation algorithm. I understand the basic idea but I don't seem to understand how do you project a polygon onto the a normal and how the intervals are calculated. As far as I know projecting vectors onto other vectors returns quantities and has nothing to do with intervals. How are the intervals calculated? | What you refer to as a 'quantity' from projecting a vector onto another is actually a length. Perhaps your textbook refers to it as a 'scalar quantity'? That would be accurate, but not complete; it's also a length along the vector you're projecting onto. (That is, 'go length x along vector y'). So, without having read oliii's tutorial, it seems to me likely that your quantities and intervals are the same thing. |
Game Development Questions | General and Gameplay Programming;Programming | I have lurked these forums for a while, rarely posting and simply focused on researching and learning from other peoples questions and answers. However, after spending so much time, their are specific questions I have concerning my purpose and intentions that are not answered here specifically.Background wise I spent a few years in my late teens developing a 2D MMORPG. It started with me experimenting in visual basics 5 and DX7 Direct Draw and over time as we worked on it more and more it become a functional game. These days however are long since past.1) From experience I am aware that Visual Basics with the right tools can handle a 2D game of any proportions. However, I would like to one day in the near future atleast to start progressing towards making a small time 3D online RPG. Using Visual Basics .NET and Dx9 would a 3D online RPG be possible? I am well aware that C++ would be the obvious route from a professional stand point, but say a game with maybe 2-4000 users online at a time, would VB .NET and DX be able to handle it without signifigant performance loss?2) I have started learning C++ for the purpose of game design. Is C# just as capable and easier to learn with somewhat less of a learning curve? Should I just stick with C++ or maybe learn C# first then take on the monster that is C++?3) I have always been against premade game engines because I felt that was someone elses work and would be the easy route to go. I am starting to realize this is simply the functions that every game needs in the form of a package and the actual game is still up to you to develop. Would it be better to find a good 3D game engine and work off of that learning what is needed along the way as opposed to starting from scratch like I did once?4) 3D worlds are something that I have never quite understood. In games such as World of Warcraft, Archlord, and hundreds of other MMORPGs, the worlds are seamless. Dungeons of course are accessed through portals, but how are worlds designed? Do game creators use pre existing world creators and load their own graphics and such and design the levels that way, then link them with code to appear seamless?I guess the main thing I am trying to figure out is can I use my pre existing knowledge of VB and DX and go to the next level and start working on a 3D game. Or for performance purposes should I find a good engine with the basics included, written in C++, and start that way? | Quote:1) From experience I am aware that Visual Basics with the right tools can handle a 2D game of any proportions. However, I would like to one day in the near future atleast to start progressing towards making a small time 3D online RPG. Using Visual Basics .NET and Dx9 would a 3D online RPG be possible? I am well aware that C++ would be the obvious route from a professional stand point, but say a game with maybe 2-4000 users online at a time, would VB .NET and DX be able to handle it without signifigant performance loss?Sure. You're the bottleneck, not the language.Quote:I have started learning C++ for the purpose of game design. Is C# just as capable and easier to learn with somewhat less of a learning curve? Should I just stick with C++ or maybe learn C# first then take on the monster that is C++?There is no particular reason to use C++ unless you want to get a job as a professional programmer in the industry in the near future. Quote:3) I have always been against premade game engines because I felt that was someone elses work and would be the easy route to go. I am starting to realize this is simply the functions that every game needs in the form of a package and the actual game is still up to you to develop. Would it be better to find a good 3D game engine and work off of that learning what is needed along the way as opposed to starting from scratch like I did once?You want to write games, not engines, so leveraging existing technology is a great way to actually be productive instead of engaging in ego-stroking by writing your own Amazing Personal Engine Of Awesomeness +3 (which is likely actually less featured, less powerful, and overall "less good" than existing platforms).Quote:4) 3D worlds are something that I have never quite understood. In games such as World of Warcraft, Archlord, and hundreds of other MMORPGs, the worlds are seamless. Dungeons of course are accessed through portals, but how are worlds designed? Do game creators use pre existing world creators and load their own graphics and such and design the levels that way, then link them with code to appear seamless?The worlds are built with tools, which may or may not be domain specific, and connected via code, yes.Quote:I guess the main thing I am trying to figure out is can I use my pre existing knowledge of VB and DX and go to the next level and start working on a 3D game.Yes.Quote:Or for performance purposes should I find a good engine with the basics included, written in C++, and start that way?Performance is not an issue. Forget you ever heard of the term until you actually have a game, and it actually runs slow. ; In response to #3:When considering whether or not you should make you own engine also consider the following (even though I bet you have). It "can" be a major waste of time to re-invent the wheel. If you are simply avoiding other engines based solely on the grounds that it's someone else’s work I think this is a weak grounds to expel its use entirely. Other good reason for making your own engine might be the learning experience, or specific features that no other engine will provide to you properly. (Note: in the second case this is somewhat not the strongest statement given that many engines provide the source to their engines, so tinkering is very possible). Or you can’t find a good one for free!It is also good experience to go through the process of using someone else’s engine. It is not a cake walk. Should you work in the industry I bet there will come many a time where you will be using someone else’s engine.In Answering #2: If you have a strong programming background(or even moderate) and want to learn C++ I say go for it. Yes C# is easier only given that there are no pointers and it's garbage collected. I honestly don't see what else is so much more difficult about C++ as many seem to rant about. I am always the type who will learn something out of necessity so.... maybe I’m just giving you bad advice from an academic point of view. If you need it, go and learn it. If not, leave it be.So overall, find out what you need. Ask yourself again why you are avoiding a pre made engine. Make sure you don't squander your precious time be that learning C#(or any language) when you didn't need it. Or making an engine when there was an engine out there(for Free! If you can't find a good free engine by all means make your own save yourself money! Unless you are short on time. Odds are though, there is an engine out there for you. devmaster.net try a look around and see) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.