Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: IPAndrews on January 30, 2006, 09:39:22 am

Title: Can anyone help - random background bitmap placement
Post by: IPAndrews on January 30, 2006, 09:39:22 am
Hi,

I'm using calls to add-background-bitmap to ... erm... add background bitmaps... to my mission. I'm doing this completely at random by passing rand-multiple 0 179 as the first parameter, 0 359 as the second and third parameters. Problem is the placement does not seem entirely random. Most of the bitmaps end up getting piled on one spot whilst much space always ends up empty of bitmaps.

Can anyone explain this behaviour? More importantly does anyone know how I can work around it?
Title: Re: Can anyone help - random background bitmap pla
Post by: CP5670 on January 30, 2006, 11:50:42 am
I guess it sort of makes sense. The pitch/heading coordinate pairs are closesly concentrated around the points where the heading is 90 or 270, so the probability of getting a point in one of those areas there is higher than anywhere else. (if the heading falls between, say, 70 and 110 or 250 and 290, then the value of the pitch has little effect and you always get a nebula bitmap in one of those areas). I guess the natural way to get around this is to just add in some kind of a weight function so that the probability of choosing a point diminishes as its heading approaches 90 or 270.

Although adding these things at random doesn't work very well anyway IMO; you just end up with a lot of small splotches around the skybox instead of any coherent pattern.
Title: Re: Can anyone help - random background bitmap pla
Post by: StratComm on January 30, 2006, 12:07:17 pm
You aren't using the background-changing SEXPs to actually place your mission background, are you?  That's totally the wrong way to go about it.  You should be using the background editor and placing them manually.  You'll get better patterns and more coherent locations for everything.  I'm also somewhat curious as to how you get a sun in there with this method.
Title: Re: Can anyone help - random background bitmap placement
Post by: Trivial Psychic on January 30, 2006, 10:31:59 pm
What IPAndrews is trying to do is for his BHX project which has a series of missions that get repeated in a random pattern.  He wants to have the backgrounds to be alterable so that the mission area appears different as far as the game area is concerned.  You can't do that with the background editor.
Title: Re: Can anyone help - random background bitmap pla
Post by: phreak on January 30, 2006, 11:24:12 pm
The background bitmap parameters are sort of funky.  I can't really describe it, but place a bitmap with a pitch of 60 and a heading of zero.  Start moving the heading over toward 90 and you can see that the bitmap follows a path downwards until it meets the xy plate when the pitch is 90.  I think whats going on is that the background follows a circle that is centered upon the origin and rotated about the line x=0 by however many degrees "pitch" is.

to demonstrate, hold a coaster with two fingers on one hand pinching the center of the coaster.  Push down on the rim of the coaster and it'll pivot up and down.  the background bitmap will be following the edge of it.

all 3 orientation parameters of add-background-bitmap should also be covering [0..359]
Title: Re: Can anyone help - random background bitmap placement
Post by: IPAndrews on January 31, 2006, 03:31:06 am
If we assume that when you create a new blank mission and face "forward" (ie: the place where a bitmap at 0,0,0 would appear) then as far as I understand it:

The top number is the degree rotation around the x axis.
The bottom number is the degree rotation around the y axis.
I think the bottom rotation is applied before the top rotation.

I do not think the middle number has any effect on position itself and just affects the rotation of the bitmap in whatever position the other two numbers put it in. If I've figured all that correctly then surely a top number of 0-180 and a bottom number of 0-360 would cover every possible position in the sky sphere. If I'm wrong please tell me! That might be my problem. Could it be the rand-multiple sexp just, isn't that random?
Title: Re: Can anyone help - random background bitmap pla
Post by: IPAndrews on January 31, 2006, 03:35:16 am
to demonstrate, hold a coaster with two fingers on one hand pinching the center of the coaster.  Push down on the rim of the coaster and it'll pivot up and down.  the background bitmap will be following the edge of it. all 3 orientation parameters of add-background-bitmap should also be covering [0..359]

If the top number represents the tilt of the coaster and the bottom number represents the position on the rim of the coaster then surely the top number only needs to go from 0-180 (coaster facing upwards through to upside down) since the rim then reaches all possible positions in the sphere?

By the by. I'm using "top number, bottom number" etc... here to refer to FRED because the actual names Pitch, Bank, and Heading do not seem veryaccurate or meaningful to me. Again though that could just be me  :nervous:
Title: Re: Can anyone help - random background bitmap placement
Post by: SadisticSid on January 31, 2006, 05:34:56 am
I find it helps to think of a minigun on a rotating turret.

Pitch = how far up or down in the air the barrels are pointing - what it's aiming at on the vertical plane.
Bank = how far the barrels have rotated around from their starting positions when firing.
Heading = how far the turret base has rotated - what it's aiming at on the horizontal plane.
Title: Re: Can anyone help - random background bitmap placement
Post by: Mefustae on January 31, 2006, 05:54:34 am
It would be a lot easier if they showed up when you were in FRED, ala the Suns...
Title: Re: Can anyone help - random background bitmap pla
Post by: StratComm on January 31, 2006, 07:12:31 am
What IPAndrews is trying to do is for his BHX project which has a series of missions that get repeated in a random pattern.  He wants to have the backgrounds to be alterable so that the mission area appears different as far as the game area is concerned.  You can't do that with the background editor.

So the thing to do would be to build 5-6 backgrounds, take all of their values, and have a random number SEXP determine which set you chose to load.  Beats the hell out of random placement, but also lets you randomize the mission environment somewhat.

It would be a lot easier if they showed up when you were in FRED, ala the Suns...

They do for me.  You are using FRED in HTL mode, right?
Title: Re: Can anyone help - random background bitmap pla
Post by: IPAndrews on January 31, 2006, 08:52:50 am
So the thing to do would be to build 5-6 backgrounds, take all of their values, and have a random number SEXP determine which set you chose to load.  Beats the hell out of random placement, but also lets you randomize the mission environment somewhat.

That's going to take a huge number of sexps and even then you're only going to have a handful of backgrounds. They have to be convincing as backdrops for 30 missions involving any 2 of 10 warring factions? Ain't working for me. I did think of using sky spheres and the skysphere swap sexp but to be honest it'd mean creating a large number of skyboxes (say 10 per race of 10, that's 100!) and I wouldn't know where to start creating one never mind 100.
Title: Re: Can anyone help - random background bitmap placement
Post by: Mefustae on January 31, 2006, 09:35:53 am
Quote from: StratComm link=topic=38157.msg778048#msg778048quote
They do for me.  You are using FRED in HTL mode, right?[
Uh... sure... but if I had to tell someone about this who had no idea what you were on about, what would I tell this supposed person?
Title: Re: Can anyone help - random background bitmap pla
Post by: karajorma on January 31, 2006, 10:23:31 am
Create a shortcut for FRED, rightmouse it click properties and change the target to fred2_open_r.exe -fredhtl -jpgtga -spec -glow

You did actually reply to a thread where I told someone else how to do it :D
Title: Re: Can anyone help - random background bitmap placement
Post by: Mefustae on January 31, 2006, 10:26:04 am
...  :nervous:

Great. Still no nebulas in-Fred. But we did succeed in slowing my computer down by a factor of 10, so that's a benchmark we can aim to surpass. Now, let's approach my problem as a team, namely one that doesn't include me. Go team!
Title: Re: Can anyone help - random background bitmap pla
Post by: StratComm on January 31, 2006, 10:31:56 am
That's going to take a huge number of sexps and even then you're only going to have a handful of backgrounds. They have to be convincing as backdrops for 30 missions involving any 2 of 10 warring factions? Ain't working for me. I did think of using sky spheres and the skysphere swap sexp but to be honest it'd mean creating a large number of skyboxes (say 10 per race of 10, that's 100!) and I wouldn't know where to start creating one never mind 100.

Admittedly true, but the quality of a random backdrop is generally so poor that only having a couple of options available is better than that.  The skybox method would be preferable really, but as you say that's a lot of skyboxes to make.  I'd rather have a single background set per race and apply it to all of said race's missions than rely on the random generator for anything approaching sane placement.

But that's just me.  There are a thousand different ways to approach the problem, and everyone must chose their own I guess.
Title: Re: Can anyone help - random background bitmap pla
Post by: IPAndrews on January 31, 2006, 10:39:18 am
There are a thousand different ways to approach the problem, and everyone must chose their own I guess.

And they're all a ludicrous amount of work, and/or rubbish ;)
Title: Re: Can anyone help - random background bitmap placement
Post by: IPAndrews on February 01, 2006, 03:06:46 am
Okay dudes. I've finished this code, and figured away around the nebulae piling problem (each new neb is placed at an offset from the previous one). The results can be seen below.

(http://www.bhx.stargame.co.uk/screenshots/randombackgrounds.jpg)

Anybody want me to upload the code?
Title: Re: Can anyone help - random background bitmap placement
Post by: starfox on February 01, 2006, 04:08:03 am
By all means, IMO  :yes:
That looks fantastic...
Title: Re: Can anyone help - random background bitmap placement
Post by: Mefustae on February 01, 2006, 05:07:30 am
My question remains, however; how the smeg do you get the Nebulae to show up in FRED_Open 3.6.5, if at all?
Title: Re: Can anyone help - random background bitmap placement
Post by: IPAndrews on February 01, 2006, 05:36:20 am
My question remains, however; how the smeg do you get the Nebulae to show up in FRED_Open 3.6.5, if at all?

The mission doesn't have any backgrounds set in FRED. There's no need to.
Title: Re: Can anyone help - random background bitmap placement
Post by: Mefustae on February 01, 2006, 05:50:50 am
Say what!?
Title: Re: Can anyone help - random background bitmap placement
Post by: IPAndrews on February 01, 2006, 06:08:18 am
You've really not followed what I've been trying to do here have you.  :D
Title: Re: Can anyone help - random background bitmap placement
Post by: Mefustae on February 01, 2006, 06:16:28 am
Of course not, I just want to get Nebulas to show up in FRED so I can see what i'm doing with 'em without having to get into the mission every dang time! :)
Title: Re: Can anyone help - random background bitmap placement
Post by: IPAndrews on February 01, 2006, 06:26:02 am
There's an option on the view menu. If it doesn't work, you need a newer FRED build.
Title: Re: Can anyone help - random background bitmap placement
Post by: Mefustae on February 01, 2006, 06:29:31 am
Obviously i've got the 'Background' thing ticked in the 'View' menu, so what new version after 3.6.5 would you recommend?
Title: Re: Can anyone help - random background bitmap placement
Post by: IPAndrews on February 01, 2006, 06:43:07 am
I wouldn't want to recommend one because some of the newer FREDs save missions which have backward compatability problems with the older version of FRED, and for all I know (haven't tested) possibly FSOpen itself. I'm using a build from November last year but hey, that's just me.
Title: Re: Can anyone help - random background bitmap pla
Post by: CP5670 on February 01, 2006, 10:33:45 am
I generally use the 10/24 FRED2, which works with most older pre-3.6.7 FSO builds like the excellent 9/17 one. The only thing I use that it's missing is the flipped briefing icon support. The newer FRED2s won't work with most FSO builds more than about a month old, although it's possible to manually edit a mission and make it work if you have to.
Title: Re: Can anyone help - random background bitmap placement
Post by: IPAndrews on February 01, 2006, 10:42:55 am
For anyone who is bothered and really I can't imagine it being that many people. Here is the random background generation code for BHX. It could probably be simplified for other campaigns, since the BHX one if fancy and picks from two sets of nebs based on where in the galaxy you are.

(the idea being you the nebs change more to a colour befitting a race as you get further into their territory)

[attachment deleted by admin]
Title: Re: Can anyone help - random background bitmap pla
Post by: karajorma on February 01, 2006, 02:35:45 pm
I'm interested. In fact I think this is one for the FRED cookbook :) I'm only waiting to see if you can improve it any :)
Title: Re: Can anyone help - random background bitmap placement
Post by: IPAndrews on February 02, 2006, 02:42:52 am
As it stands it's good for hardcore FRED users only. Since to be any use to most people they'd have to rip out all the "team" related stuff. I don't have time to do that myself. So consider it to have one of those "use entirely at your own risk" stickers slapped on.
Title: Re: Can anyone help - random background bitmap pla
Post by: karajorma on February 02, 2006, 06:46:34 am
The cookbook is meant to be a showcase for good or innovative FREDding. Some of that stuff is there for people to rip out and plug straight into the game. Other stuff is intended to inspire or simply show how much is possible with FRED without having to bother the SCP team for something new.

This is definitely in the latter category :)