Tudor Nita

Members
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

121 Neutral

About Tudor Nita

  • Rank
    Newbie
  1. c++ file reading

    Just personal preference I guess. It's a bit verbose for my liking and enforces type safety at compile time. This nags at me a bit too: [url="http://stackoverflow.com/questions/5164538/how-can-i-speed-up-line-by-line-reading-of-an-ascii-file-c/#answer-5165293."]http://stackoverflow...answer-5165293[/url] Seeing how I'm really used to the fgets way, this is all, of course, highly subjective. Still, it's a valid alternative.
  2. What are the downsides to using Unity?

    [quote] Unity's fbx import will convert it, but have non zero values in the rotation fields, with no way to set the default rotation to identity (0,0,0). Especially when writing scripts to instantiate objects [/quote] I'll have to agree on that. Was thinking from a manual import POV. However I remember you can get a 0,0,0 rotation if you pre-rotate the object/ pivot in 3DS Max before exporting. Will have to check this out again as my memory is not to be trusted.
  3. c++ file reading

    I wouldn't use iostream. Something like this works for me. Imagine an input file like: # a comment a 3.5 3.5 yay_some_text a 3.2 4.5 yay_some_more_text [source lang="java"]FILE *pFile = fopen(filePath, "r"); // the file to load char buffer[512]; // character buffer char temp; // read each line into the buffer while (fgets(buffer, sizeof(buffer), pFile)) { // switch based on leading type switch (buffer[0]) { case '#': // do nothing, it's a comment [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] break; case 'a': // set ambient color ? sscanf(buffer, "%c %f %f %s", &temp, &someFloat, &someOtherFloat, &aString); break; } }[/source]
  4. Pong

    [quote]"stupid long mathematical equation"[/quote] That doesn't sound good regardless of how much I spin it around in my head. Anyway, you could just go with some simple conditional statements and inverse the direction of the ball. If you want something more complex you'd have to do some vector maths with at least the ball's direction vector, the paddle's forward vector and the position the ball hit the paddle. [source lang="cpp"] // edge of playing field if (pong.ball.centre_y > 0.6f) { pong.ball_velocity_y = -ball_speed; } else if (pong.ball.centre_y < -0.6f) { pong.ball_velocity_y = ball_speed; } // ball hit a paddle on the right side if (pong.ball_velocity_x > 0 && collides(&pong.ball, &pong.bats[1]) ) { pong.ball_velocity_x = -pong.ball_velocity_x; } // ball hit a paddle on the left side if (pong.ball_velocity_x < 0 && collides(&pong.ball, &pong.bats[0]) ) { pong.ball_velocity_x = -pong.ball_velocity_x; }[/source]
  5. What are the downsides to using Unity?

    As a long-time user of Unity: [b]downsides:[/b][list] [*]Although it's amongst the best in asset management, the module does have its quirks and can ruin your day if you're not careful. [*]Hard to "patch" asset/ scene files since they are binary (see 500mb comment above ). [They are switching to a text-based scene format so this will change very soon ] [*]Some web-game developers complain about users leaving the game page once they see the Unity logo [ which in the free version has to be there ]. This is a side-effect of so many people having access to the free version and so much shovelware being developed. I have my doubts about it. [*]Jack of all trades dilemma. It does everything but doesn't really shine in any particular category. It's not exactly a downside but surely not an upside either. [*]Really bad GUI implementation. The inbuilt GUI system is a performance drain at best. [ This is bound to change with ver. 4.x ] [*]Binary SDK. As a c++ enthusiast, source code access would make my day. [/list] [b]upsides:[/b][list] [*]Extremely easy-to-use. I love UDK, Corona, Cocos2D and even ShiVa but they just aren't in the same ballpark when it comes to ease-of-use. [*]Awesome cross-platform support. [ with 4.0 ] Linux, Web ( plugin and flash), Windows, Mac, iOS and android. And all of them free [ basic versions anyway ]. [*]Well documented scripting. Some of the best documentation this side of a complex engine. [*]Decent to great performance on mobile devices. Couple of tricks to make it run great but it eventually gives. [*]Great community. They've got their trolls and whiners but overall the community is great. [*]Asset management. Both a blessing and a curse. [/list] [b]corrections:[/b] [ Daaark ] Getting the correct orientation is not a bug nor an inconvenience. It's just the coord. system they use ( common y-up system ). The problem lies rather with the authoring tools [ z-up for 3ds max for example :| ]. Nothing some decent planning won't take care of.
  6. Not exactly an answers, more like a guess but: From a (very) quick look at the code, I assume you are taking a single sample per pixel. That will always generate edge artefacts. Try subdividing the pixel. You could start with a 2 by 2 and just average the results. This is an assumption based on no data though ( can't see your raycast loop ) so take it as is. P.S: Bacterius makes a valid point too. I hit that block early as well. [url="http://www.sci.utah.edu/~wald/PhD/wald_phd.pdf"]Wald's paper might help[/url] [url="http://elib.lvk.cs.msu.su/papers/documents0/26/http:zSzzSzwww.graphicon.ruzSz2007zSzproceedingszSzPaperszSzPaper_46.pdf"]This[/url] was also an eye opener when I was building my raytracer. Probably the most performance oriented intersection technique ( still using barycentric coords.)
  7. Alternatives to Unity?

    [b]1st approach[/b] For a 2D-only implementation, in unity, you could try writing a simple lighting algorithm that pokes bits in a custom texture with texture.SetPixel(); You'd have to poll all shadow casting objects and write into some secondary texture attached to them. To speed things up, you could create the texture at lower resolution and "jitter" the pixels for some simple blurring. Problem is, this will still be slow. Quite slow. And to do custom shadows from what I assume are alpha-textured quads is not only even slower but decently complicated as well. [b]2nd approach[/b] Use the alpha buffer to build your own 2d shadowing system. There's a great article on 2D Shadows[url="http://www.gamedev.net/page/reference/index.html/_/technical/graphics-programming-and-theory/dynamic-2d-soft-shadows-r2032"] right here[/url]. Should be fairly easy to do for basic polygonal shapes. Not so for alpha-textured quads. [b]Alternatives:[/b] Corona comes to mind. UDK might be ok too but UDK's overhead and requirements are a bit harsh for a 2D game. p.s: someone built an alpha-buffer based ( stencil buffer unavailable in free ) hard-shadowing plugin. [url="http://forum.unity3d.com/threads/102079-Dynamic-shadows-in-Unity-Free-Pro-possibly-Mobile"]Could try that first[/url].