Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Animating a Billboard... is it possible?

Author
Message
Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 25th Nov 2011 20:58
So I want to make a new laser effect for my space shooter. The old effects works, but its very basic. Right now my laser is nothing more than a .png on a billboard that scrolls. For my new effect, I want the laser beam to start off very thin and then grow to its full width. I know that I could just increase the width of the billboard little by little to get this effect, but thats not what I want either. What I want is for the white core of the laser beam to grow exponentially, taking up a larger precent of the beam.

Take a look at the screen capture I attached to get an idea of what I want to do.

So my idea was to animate the billboard. Unfortunately, I have not experience using animation in game. So I came to the TGC forum for adivce.Should I use and animation program or a sprite sheet? What are the pros and cons of each method. I would also like to have the beam fluctuate in size when it reached full stength.Is that an important factor in determining which method I use? Any comments or help would be greatly appreciated.[href]null[/href][img]null[/img][img]null[/img]
EdzUp
23
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 25th Nov 2011 21:05
Couldnt you just 'retexture' the beam mesh to achieve the desired effect, this would require some textures of the beam for each width then apply the relevant one at the required time.

Another option is as you say scaling the mesh to get the effect but doing this would stretch the whole image leaving a undesirable effect.

-EdzUp
Graveyard Dogs
Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 25th Nov 2011 21:15 Edited at: 25th Nov 2011 21:16
I orginally thought of "re-texturing" the billboard, but I have no idea if that is possible. And is essense "re-texturing" the billboard is animation since I am using multiple images. So I guess my real question is weather to animate it in game or outside the game and import it.
EdzUp
23
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 25th Nov 2011 21:16
Hmm the bonus that comes from retexturing is simply that you can choose the order in which the images are shown in, and how they are shown.

-EdzUp
Graveyard Dogs
Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 25th Nov 2011 21:18
That is true. But how would I go about re-texturing the billboard?
EdzUp
23
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 25th Nov 2011 21:19
create a plane, texture it, change it scale to suit and retexture as required. Off the top of me head IIRC its 'Set Object Texture Object, TextureID'

-EdzUp
Graveyard Dogs
Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 25th Nov 2011 21:41
I was thinking about making a sprit sheet or breakout tiles, since I know that method was used in the past, but I really don't understnad the coding behind it.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 25th Nov 2011 22:19
You can play animation to image and then apply as a texture to your object plain, and then set object transparency. For that, you have to paste image to 0,0 and get a second image that will be the correct image to use. If you want, I can show you an example.


Cheers.

I'm not a grumpy grandpa
Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 25th Nov 2011 22:39
Does DBpro support animated .png files? If it does then i wouldn't have to mess around with the transparency.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 25th Nov 2011 22:44 Edited at: 25th Nov 2011 22:48
I'm not sure if it works with png, but it does with animated gifs


Edited just checked, and png didn't work

Cheers.

I'm not a grumpy grandpa
Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 25th Nov 2011 23:29
Isnt there a command to divide a single picture up into multiple images, and the then load the pictures with an x loop?
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 25th Nov 2011 23:50 Edited at: 25th Nov 2011 23:57
What do you need exactly ?

You could paste an image and then get several images from it.

Edited

something like that:




Download example.

Cheers.

I'm not a grumpy grandpa
Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 26th Nov 2011 01:50
I am trying to do something like this:see link.
However, instead of attaching the images to a sprite to make an animation, I want to use the images as a texture for a billboard.[href]null[/href]http://forum.thegamecreators.com/?m=forum_view&t=6696&b=10
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 26th Nov 2011 02:27
instead of cutting out multiple images, you can set up the texture like a sprite sheet and use the scoll texture command to jump the uv coords over an image width each time. it lets you run through an object texture the same as you would for sprite.


Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 26th Nov 2011 02:52
Could you explain that last comment some more and possible offer a code snippet? I really have never worked with 2d graphics so I have no idea what you just said.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 26th Nov 2011 03:27
Quote: "Could you explain that last comment some more and possible offer a code snippet?"


Have you test my example?

Cheers.

I'm not a grumpy grandpa
Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 26th Nov 2011 04:16
@Chafari,
Yes I did see your suggestion, and I am currently working on something similar. My last comment was directed towards Ortu and his UV mapping idea. I am not familar with game design or 2D, so I just wondering what he was talking about.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 26th Nov 2011 05:12
Ortu meant that you can scale object texture, and then scroll the texture to reach the portion of image that you need for each frame.

Cheers.

I'm not a grumpy grandpa
Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 26th Nov 2011 17:19 Edited at: 26th Nov 2011 17:37
It the uv scrolling less CPU intensive than using multiple images and pasting then in rapid succession? If so does anyone know of a good tutorial or code example. Like I said I new to graphics coding.Also while I have a moment, I thought I would try to explain what my current thought process is for this effect. I figured I could make 6 png that would start off very thin with almost no with core and then get large with with core proportionally ( see the example pics I posted earlier). Then load the png in a certain sequence to make the laser effect. For example, start with 1 (the thinnest) and then go all the way up to 6 (the thickest). The have the png images fluctuate between png 4 and png 6 for a few seconds to give the laser some visual character. Finally, when it is time, have the start at png 6 and go back to 1 before the laser effect disappears.
Now I know game creators use to use bmp files with multiple effects on them ( say 4 laser effects) and split the one image into 16 ( 4 images per effect). However, I have no idea how to code that. I have an example of so such bmp file, but it's at the house so maybe I will post it later so everyone can see what I am talking about. I am pretty sure that this method requires a sprite, but I believe sprite are hard to do collision with so I don't want to use a sprite. Instead, I want to paste the image for the effect onto a plain that I intend to billboard so the effect is always facing the camera. However I have no idea if that is possible. Hope this clears up what I am trying to do a little.
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 26th Nov 2011 18:44 Edited at: 26th Nov 2011 18:53
basically if you have an 200px wide image with 4 texture panels of 50px wide each you can load that image, apply it to the object as a texture, and use:

'scroll object texture obj,u,v' = scroll object texture obj,50,0

to advance the frame. at the end when you want it to pulse, you would alternate u=50 and u=-50 to flip between the last 2 frames.

if you have a multiple row sequence to keep the image a square power of 2 (ideally) then when you hit the end of a row, the next frame jump you will increase the v by one row height to drop to the next row. I beleive the u will automatically wrap back around by default so you can leave the u=50. return v to 0 to continue running horizontally.

speed wise it's probably slightly faster than cutting. either way you have to load the full image, but with cutting you then have to allot extra image numbers for each frame and apply a new texture again and again. I might run some performance tests if I get a chance it would be good to know for sure.


Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 26th Nov 2011 19:46 Edited at: 28th Nov 2011 05:01
Thanks for pointing me in the right direction Ortu. I will give that a try when I get home.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 26th Nov 2011 23:56
You could alter the UV coordinates of the object to match a subdivided image. Like this:

Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 27th Nov 2011 02:08 Edited at: 27th Nov 2011 02:18
Thanks for the code snippet. I have another question about uv scrolling. If I scroll the texture will it scroll like the side scrolling background on some old 2d shooter? Because it that is the case then I don't think that uv scrolling will work for what I want to do.
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 27th Nov 2011 08:14
no, not unless you scroll it by a very small amount each frame. if you scroll it by a full panel width it will change immediately from one panel to the next, you won't see it 'sliding' or anything. I think that's what you are getting at.

the scroll object texture command really just sets the uv coords from the current values to a new value by the amounts specified. it's an instant shift.


Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 27th Nov 2011 09:21 Edited at: 27th Nov 2011 22:45
Has anyone actually tested the 'scroll object texture' command for this? Cause I don't see how it could possibly work. There's no way for you to set what frame you want, from the frame your on since all the command does is shift the UV's at the speed of whatever you set it to. Also you'd have to combine it with 'scale object texture' since scrolling would scroll the entire image, when all you want is a single frame. All this is just to messy.

Here's another example of using the snippet I posted:

Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 27th Nov 2011 16:05 Edited at: 27th Nov 2011 16:19
here is a video clip that show how I wanr to make my lasers look. http://www.youtube.com/watch?v=j715YuoVkuc
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 27th Nov 2011 19:43 Edited at: 27th Nov 2011 19:46
ok, I did some testing and it does work, however there are two issues that I came across:

first the scroll value is a decimal form % of the whole image so if you have a 200px image with 4 panels of 50px each, where I said before that you would scroll the u value by 50, that is incorrect. you will need to scroll it by 0.25 as 50 is 25% of 200

second, I was making an assumption based on personal habits which ended up causing some confusion, sorry I wasn't really thinking about it. Basically Sasuke is right in that this will not work with darkbasic primitive created plain (make object plain obj,x,y). You need to use a UV mapped plain.

I almost never use the code based primitives for anything and this led to the mentioned assumption.

Anyway there several benefits to using a mapped and loaded plain object rather than creating one in code: textures will auto load and apply with it if the are in the same directory, you can use this scrolling texture technique, and you can set the object center to the edge instead of the center so that you can position it easier without messing with abunch of offset calculation and so on.

here is my test and the media is attached




Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 27th Nov 2011 22:02 Edited at: 27th Nov 2011 22:24
Ok, so that work really well, so thank you all for your help. Unfortunately, I have one more question, how do you make uv mapped plains?

edit: never mind. I googled uv mapping, and it should be rather easy for a simple plain. However, if I map it in Blender, I still need ti load object and texture?
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 27th Nov 2011 22:45 Edited at: 27th Nov 2011 22:45
I was thinking, you could map the UV's of a darkbasic primitive using the function I provided and combine it with your method of scrolling:

Spectre 117
16
Years of Service
User Offline
Joined: 18th Apr 2010
Location: *Insert cheesy location here*
Posted: 27th Nov 2011 23:08
I could. but I think it would be easier to use blender.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 27th Nov 2011 23:23
The problem with mapped objects is you could only use a set sprite sheet for it, where as the method I have provided could be anything. Though, I would still opt out of using DBP primitives, but just not alter the UV's. Then again, you could just create multiple objects for different sheet sizes.
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 27th Nov 2011 23:53 Edited at: 27th Nov 2011 23:58
Quote: " if I map it in Blender, I still need ti load object and texture?"


if you set the texture image in the material settings before you export it, you will only need to load the object, it will pick up the texture on it's own as long as they are in the same folder. you can load and apply other textures later if you want.

on a side note, that laser test looks much better if you scale the object x down to 25%, and of course it'll be smoother if you use more frames.

also, thanks for the uv code Sasuke. I think I'll play around with it a bit, I can definately see where it can be handy.


Login to post a reply

Server time is: 2026-07-10 01:59:12
Your offset time is: 2026-07-10 01:59:12