SolarLune-Game Google Code Project - Current: Light trail / Ribbon System

Hey. So, I thought it would be a good idea to make a central Google Code page for my BGE Python modules. That way, it’s easy to make sure that you have the most up-to-date scripts and functions.


http://i1126.photobucket.com/albums/l620/SolarLuneTP/RibbonLoop_zpse671c44c.gif

  • NEW - LightTrail

Hey. So, LightTrail is a trail system I made because I needed the functionality of a trail / ribbon, but I couldn’t find anything for Blender 2.6. It’s not exceptionally well made, but I’m happy with it.

I wrote a ton more about the system in the blend file, but I’ll put just a little bit of it here.

LightTrail is a trail system that I made since I couldn’t find one for Blender 2.6.

There are a few options that you can use with LightTrail to customize your trail effect.

Note that the trail’s physics mesh is not updated while it moves around - to do that, you have to do it yourself with either the Replace Mesh logic brick, or with Python.

As I’m tending to do with my newer projects, you can grab the script and an example for it at my Google Code page (link’s above). For this one, you should be able to just press P to play (you don’t have to move the script to the examples folder or anything).

Hey, if you want to see more cool stuff from me (resources or game projects), think about donating to me. You can do so on the right side of this page here.

  • OTHER STUFF MOVED DOWN -

OLD NEWS

  • NEW - Motion Blur.

Motion blur is something that’s built into the BGE, but that doesn’t work on all cards (I believe ATI is to blame for their cards not having accumulation buffers). I made my own version of motion blur years ago, and here’s another version.

This one just uses one plane and one of two materials, as opposed to my old method of several hand-created planes with unique materials. This version is most probably more inefficient than the built-in version, though. Still, it should work on basically all computers and graphics card types.

You should just have to

  1. Create a camera in your game scene
    for the motion blur to use.

  2. Append the motion blur scene into your game blend file.

  3. Use a logic brick to add the motion blur scene in-game as an overlay scene.

  4. Set the default camera and scene variables in the
    “MotionBlur” script, or set the logic.motion_blur_source_scene
    and logic.motion_blur_source_camera variables as necessary.

  5. Set the BlurPlane’s material in the MotionBlur scene to the
    one appropriate for your game’s draw mode (i.e. the STMT one
    for Single or Multi-texture, and the GLSL one for GLSL mode).

That should be about all that’s necessary to get it up and running. I’ve included an About text file that explains much more about how to use it.

Check it out on my Google Code page here. You can easily check out all of those modules by using an SVN tool like TortoiseSVN, or you can download it directly by highlighting the blend file in your browser, right-clicking it, and selecting “Save As…”, or something similar.

Anyway, thanks for reading!

-Flatten-

The current newest addition is the Flatten module. The Flatten module allows you to copy the meshes of several objects over to a single one. This is done because the BGE draws a single batch much faster than it draws several. As you can observe in the picture below, 729 objects renders much, much faster when you Flatten everything together, as opposed to the right, where every object is individually drawn. Now, the test isn’t completely correct, as the destination object (where the source objects are flattened to) should be destroyed if you choose not to flatten things, but it’s just a quick-and-dirty example.

Now, there are some downsides to this - the flattened objects are all part of a single mesh, so they all have to share materials, and they’re all ‘stuck together’. However, the advantage is still pretty good, I think. I made this for a little voxel / Minecraft-like test awhile back, and I revisited it just recently to add some functionality.

Now, you can both flatten, as well as remove flattened polygons.

You can also now progressively flatten objects into a single mesh through repeated Flatten() function calls. This is particularly useful as you can spawn an object, alter its vertex info (UV, position, vertex colors) and then flatten it into the destination mesh, and repeat, almost like stamping. Come to think of it, you probably could use the same mesh multiple times.

Usually, spawned objects share meshes internally, so altering vertex info would change every mesh of every similar object in the game scene. However, the flattening process can grab the vertex data before you move on to altering the next object, so the edited mesh data is still valid. You can see the result in the picture above.

Unflattening isn’t that intuitive, but it is not too hard to use. Currently, it works something like this:

  • You make the destination mesh with enough faces to cover all of the source objects you plan to spawn.

  • You flatten the source objects into the destination object.

  • When you flatten the sources, the Flatten function returns a list of lists, consisting of vertex indices. Each vertex index list corresponds to the object in the same position in the source lists (at least, it SHOULD, hah).

  • You later call the Unflatten() function and pass in the destination object and the vertex list to unflatten (remove) them.

It would probably be nicer to pass in the object name for the vertices, rather than a list. If people find this useful, maybe I’ll add that later.

An example for the Flatten module is available on the Google Code page.

  • BGInput -

I made an input module that allows you to set up key bindings easily. For example, rather than checking logic.keyboard.events and logic.joystick for input, you can set up a new binding name, and then poll for that name. Here’s a quick example.



device = CInputDevice()
    
     device.Add('jump', KEYPRESSED, events.ZKEY, 'keyboard') # Add a  keybinding named "jump", reacting to a key being pressed (not held  down), that correlates to the Z Key, and add it to the keyboard group  (unnecessary last step)
    
    device.Poll('keyboard') # Run Poll() only ONCE per CInputDevice per game frame.
    
    print (device.bindings['jump'])


It’s also on the GC page, though there’s no example for it. Use an SVN tool like TortoiseSVN to check everything out. The link to the GC page is at the top of this post, by the way.

  • ALSO ON SOLARLUNE-GAME (The Google Code page) -
  • 2D Sprites
  • SFL (Screen Filter Library)
  • JoyProfile (Joystick Profiles for input indices (i.e. what index the horizontal axis is on the left stick of a 360 controller))
  • TPWindow (Three-Piece Windows; used to allow the developer to make windows of arbitrary size, but have them stretch accordingly to fit the size necessary dynamically)
  • X-Emitter / X-Particle as they were when I uploaded them (so I don’t know if they work or not)
  • BGHelper - Massive BGE helper library; probably not useful to anyone but me, haha
  • RLG - Random Level Generation

Added motion blur example / module.

Updated first post with news about LightTrail, my new trail system. Moved old news down to the second post.

Cool, I made a light trail for a game back in 2.49b but it was quite slow. I’ll check yours out when I get home.

nice!
i needed this for space fighter trails!
thanks!

it just stays a strate orange plane when i play the example

@josiathegreat - What version of Blender are you using? What does the console say?

2.66 the console said nothing

@josiathegreat, add Main(logic.getCurrentController()) to the end to make it work.

The script works great, I can use it, but I’m still going to fry my brain trying to look at it.

@josiathegreat - That’s weird. It should be in module mode, which means it runs a function in the script file. It sounds like it’s running in script mode for you, josiathegreat. Make sure the Python logic brick on the trail object is in module mode.
@PlanetKiller - I’m glad you find it useful.
@luc.ki - No problem.

This is great, I want to came back to my games, I really miss BGE and the comunity!

Congratulations SolarLune and thanks for share this!

@leonnn - Thanks.

Updated with quite a few things; I’ve added my Pixellation GLSL filter from Valchion to the SFL, or Screen Filter Library, module. It now takes a desired resolution to imitate; this way, the pixel size changes with the screen size. I’ve also worked on and updated my BGInput module to have more features. It now works with mouse buttons, and is simpler to poll for state changes (i.e. if a button or axis was just pressed, released, or is being held down).

I think I’m going to need to break up the BGHelper module into smaller modules (maybe BGHelper.Ray, BGHelper.Math, etc., etc.). Some of it is really useful, but I’m sure it’s cumbersome for others to use.

I would love to see a “Physics Sword Rig” that as you swung it left a trail of glowing refraction,

Mouse = X and Z axis (left right up down) and Y axis is like Q stabs, E retracts :smiley:

I could write the sword, if you can add the effect :smiley:

Something like this :smiley:

Attachments

SwordSystemAlpha.blend (462 KB)

@BluePrint - Sorry, I don’t have the time right now. The LightTrail resource is fairly simple to set up, I think; there’s an example for it, as well, so it shouldn’t be too difficult to figure out.

Updated to fix joystick hat input handling for BGInput. It defaults to only one hat, but I don’t know of many controllers that handle more than one anyway, so it may not be anything to worry about immediately. Also, the JoyProfile.py file has been updated to change all profiles from dictionaries to classes (should help with code intelligence-capable IDEs like Komodo Edit). So, it would look something like:



jp = JoyProfile.Xbox360

print (jp.A) # The A button on a 360 / X-Input controller
print (jp.Stick_LeftHorizontal) # Horizontal axis of the left analog stick


hi solarlune, im just wondering if you could teach me how you copy the location and rotation of the parent to the pair of verts? i’m not good in programming but i’m eager to learn.
i’m going to try to spawn a plane and leave the 1st pair of verts at the spawn point then the 2nd pair will follow the parent’s Loc and Rot.
thanks in advance

This is a relatively simple task that doesn’t require moving vertices at all, if I understand your question. You just want to basically have a bar from one point (the home point) to an end point (the targeted object), right? If so, you can ask this on the Game Engine Discussion and Support forum. You should be able to get an answer relatively quickly.

Only the sprite stuff is on your Google Code page: the light trail isn’t being shown. :frowning:

^ Yes, the sprite example is the only file up for download, but the actual script files and example files are there in the source. You can get all of it by using SVN to download the source files and examples.