Lets take a breathe moment to review this code. (Fallout 3)

Home of discussion, generally. If it doesn't go in any of the other forums, post it in here.
Post Reply
Pizzahut Lover
Cakester Alt; I'm going places in life
Posts: 233
Joined: Tue Apr 12, 2011 10:05 am

Lets take a breathe moment to review this code. (Fallout 3)

Post by Pizzahut Lover »

The following code demonstrates what could of been. I have grown tired of the rain project. I am away from my desktop computer and so even If I wanted, I won't be able to produce demo. I made a switch to the script extender again which provides an easy interface to the player's position, which is key to the decision of what part of the heightmap to start accessing data from.

but whats in a heightmap? Bethesda's creation kit will export the height map into four .raw files. Each raw file is a quadrant. Q1 to Q4. They are fairly consistent in how they represent the data. The entire map your character can be on and more is defined in the raw files. As a fan of rain and wetness in Fallout, I have long fantasized of nonpiercing rain and floods. There is simply no other way to approach the problem of flooding, fluids and rain better than this.

I have one last thing to say. This is not a code snippet that is ready to adapt to rain. Just like I relied on the heightmap data to know where to place floods, you need a map of all objects. using the position of an object and its bounding box you can know which areas rain should not fall. In code we would have these nogo areas in a list so a user would have the same approach of drawing bits of vertexes outward from their player but with no worry it would penetrate objects. in fairness there are multiple ways we could buidl the object map. It be just like the height map but the pixels that are different don't mean how far up or down, but do not drop or in in the user's case draw particise in those positions.

Code: Select all

short ** ppHeightmap;
// 16bit value 0 to 65,535. Player minimum and maximum 65,535 * 2.
//(-131070 to 131070). height values are all capped at 16 bits. max Z = 65,535
int XYToZ(int nX, int nY, int &outQuad)
{
    int nHeightValue = 0;

    int nQuad = 1;

    if (nX >= 0 && nY >= 0)
        nQuad = 2;
    else if &#40;nX <= 0 && nY <0>= 0 && nY <= 0&#41;
        nQuad = 4;

    if &#40;outQuad != nQuad&#41;
    outQuad = nQuad;

    // A complete height map is two by two .raw files
    nPlayerX = nPlayerX / 2;
    nPlayerY = nPlayerY / 2;

    const int nResolution = 1024 - 1;
    int nIndex = abs&#40;nY&#41; * nResolution + abs&#40;nX&#41;;
    short shVal = ppHeightmap&#91;nQuad-1&#93;&#91;nIndex&#93;;

    return nHeightValue;
&#125;

void falloutgame&#40;&#41;
&#123;
    bool bInWasteland = true;
    int nPlayerQuadrant = 0;
    while &#40;bInWasteland == true&#41;
    &#123;
        int nPlayerX = 0;
        int nPlayerY = 0;

        const int nAreaLengthX = 5;
        const int nAreaLengthY = 5;
        for &#40;int xxx = 0; xxx < nAreaLengthX; ++xxx&#41; &#123;
            for &#40;int yyy = 0; yyy < nAreaLengthY; ++yyy&#41; &#123;

                int nHeight = XYToZ&#40;nPlayerX + xxx, nPlayerY + yyy, nPlayerQuadrant&#41;;

                /*
                * one could do a number of things at this time.
                * one could translate amesh or particle up the Z using nHeight as a minimum.
                * one could bake physics simulations &#40;fluids&#41; using the position data.
                */

            &#125;
        &#125;


    &#125;
&#125;
The code is untested. I could not rediscover what values in the 4x4 I switched around so to draw my own meshes in the game is not happening through graphics hooks. I also can't find a way to easily duplicate existing meshes loaded into forms and update the positions. in fucking fact, i couldn't even get meshes placed into the editor, which i could easily locate and change the position, to actually change position. fuck you GECk. set pos asshole. I have had this problem before back i the multiple update postion btichfuck. i have a feeling though that when I return a day or three from now I will find a way to finally demonstrate the rain and floods. don't worry men. i think i could easily export a list of objects placed in the wasteland worldspace , then read them in with a different script calculate how many pixels they take up and finally produce the code that considers these pixels no go.

I sure hope you enjoyed this post. I should also mention this means new vegas could have nice rain too.
Pizzahut Lover
Cakester Alt; I'm going places in life
Posts: 233
Joined: Tue Apr 12, 2011 10:05 am

Post by Pizzahut Lover »

One last thing. the player's position even when halved to account for your x and y being both half of the total 4. um. you need to apply a scaling mechanism because you really ar dealing with a 1024x1024. actually 1023x1023. but whatever.

So redone it would be like this

Code: Select all

 nPlayerX = nPlayerX / 2;
    nPlayerY = nPlayerY / 2;
    
    const int nScaling = 65,535 / 1024;
    nPlayerX = nPlayerX / nScaling;
    nPlayerY= nPlayerY / nScaling;

    const int nResolution = 1024 - 1;
    int nIndex = abs&#40;nY&#41; * nResolution + abs&#40;nX&#41;;
    short shVal = ppHeightmap&#91;nQuad-1&#93;&#91;nIndex&#93;;

    return nHeightValue;
I might go home tomorrow. getting pretty bored. i will likely design a particle point system or make a utility library for all us rain modders
Pizzahut Lover
Cakester Alt; I'm going places in life
Posts: 233
Joined: Tue Apr 12, 2011 10:05 am

Post by Pizzahut Lover »

hey1 . here it is fixed up nice and neat. i will get back to that particle system now.

Code: Select all

namespace liquidfallout
&#123;
const int QuadrantResolution = 1024;
const int QuadrantPixelLength = 1023;
const int QuadrantScaling = 65535 / QuadrantResolution;
void ConvertPosition&#40;int &X, int &Y&#41;
&#123;
    X = X / 2;
    X = X / QuadrantScaling;

    Y = Y / 2;
    Y = Y / QuadrantScaling;

&#125;


int  DetermineQuadrant&#40;const int &X, const int &Y&#41;
&#123;
    int nQuad = 1;
    if &#40;X >= 0 && Y >= 0&#41;
        nQuad = 2;
    else if &#40;X <= 0 && Y <0>= 0 && Y <= 0&#41;
        nQuad = 4;

    return nQuad;
&#125;
 
int GetHeightValue&#40;const int &X, const int &Y, short* pHeightmap&#41;
&#123;
    int nX = X;
    int nY = Y;
 
    int nHeight = 0;
 
    int nIndex = abs&#40;nY&#41; * QuadrantPixelLength + abs&#40;nX&#41;;
    short shVal = pHeightmap&#91;nIndex&#93;;
    nHeight = &#40;int&#41;shVal;
 
    return nHeight;
&#125;
 
&#125;
 
 
short ** ppHeightmap;
 
void falloutgame&#40;&#41;
&#123;
    bool bInWasteland = true;
    int nPlayerQuadrant = 0;
    while &#40;bInWasteland == true&#41;
    &#123;
        int nPlayerX = 0;
        int nPlayerY = 0;
 
        const int nAreaLengthX = 5;
        const int nAreaLengthY = 5;
        for &#40;int xxx = 0; xxx < nAreaLengthX; ++xxx&#41;
        &#123;
            for &#40;int yyy = 0; yyy < nAreaLengthY; ++yyy&#41;
            &#123;
 
                int nX = nPlayerX + xxx;
                int nY = nPlayerY + yyy;
 
                nPlayerQuadrant = liquidfallout&#58;&#58;DetermineQuadrant&#40;nX, nY&#41;;
                liquidfallout&#58;&#58;ConvertPosition&#40;nX, nY&#41;;
                int nHeight = liquidfallout&#58;&#58;GetHeightValue&#40;nX, nY, ppHeightmap&#91;nPlayerQuadrant-1&#93;&#41;;
 
 
            &#125;
        &#125;
 
    &#125;
&#125;
Pizzahut Lover
Cakester Alt; I'm going places in life
Posts: 233
Joined: Tue Apr 12, 2011 10:05 am

Post by Pizzahut Lover »

so i have another idea. whereve we are placing our ::GetHeightValue call its likely to be during a huge set of draws. I think we have a better candiate for how to structure this all.

first all our z values should be looked up ahead of time , even if randomly generated. i mean x,y pairs how many.

next we go to act on a existing stream of vertices, which shall be considered all part of one mesh . once we are finished we pass the entire buffer to the device for drawing. this means we only need 1 draw call.

computationally our focus then is the setting of the height values. accessing the array of bytes from our heightmaps or object maps is already most efficient.

so gosh darnit! setting this values. or depending on what we are doing with the x and y coming up wtih optimizable patterns. so cool. i love repeating myself.

but um. another advantage could be design our particles outside the game, we can find common patterns and establish possible algorithms to truly get to the point of our rain simulations. as long as we keep it simple and focus on our advantage of position we shouldn't get tired at all. this is awsome.


edit: i have idea!

i could create very unique meshes and place them apart in those unique locations. super duper mart, rivety city. because we have a mesh already being set into a definitie position, we can swap out the mesh for a mesh which as vertices that transform around the world. omgosh this is the answer! i have done it! go me!

ok cal mdown. i am going home toda. i have to test this idea out. its actually new for me.

if you still don't understand. I may not be able to edit where a mesh is drawn because i can't recreate the main matrices. but what i can do is edit the vertex buffer of a mesh I hand place in game and locate before it is drawn because i know again its polys and verts. for this reason, i would find it ok to override the vertex buffer or even simply do a stream source change. HEKC YES. i am gonna go cyr
Pizzahut Lover
Cakester Alt; I'm going places in life
Posts: 233
Joined: Tue Apr 12, 2011 10:05 am

Post by Pizzahut Lover »

fucking bitch.

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

The interface used to dump the shader information I already fucking had. FUCK. that bitch i needed its there. men we will see meshes rise from the terrain up into the ksy. it will be epic. and i won't hold back.
User avatar
Retlaw83
Goatse Messiah
Goatse Messiah
Posts: 5326
Joined: Sat Jul 17, 2004 1:49 am

Post by Retlaw83 »

Doesn't the rain in Honest Hearts act like you want already?
"You're going to have a tough time doing that without your head, palooka."
- the Vault Dweller
Pizzahut Lover
Cakester Alt; I'm going places in life
Posts: 233
Joined: Tue Apr 12, 2011 10:05 am

Post by Pizzahut Lover »

Retlaw83 wrote:Doesn't the rain in Honest Hearts act like you want already?
I just discovered ID3DXConstantTable had the capacity to set my nontransposed modelviewproj matrices all along. If I am correct it means I will have a better way than locking/swapping vertex buffers.

Retlaw83, the ability to draw anywere in the game in RT is very nice. I quit honest hearts because I got lost in the grand canyon or whatever. Or the graphics were too good. The rain or particle system they had setup likely had to be extremely tweaked to not pierce. It is also a major annoyance to setup the particle systems in nifskope for us non-bethesda dev pals.

man my knuckle sare strong. the point is,if there was a time where rain didn't pierce it was the level design built around that fact. I would like to believe people would want to place rain anywhere and everywhere, regardless of level design. also one other thing is : floods. major major flooding. maybe you have played fallout 3? but the game has a super atmosphere its just requires some mods to truly bring it out.

imagine hundreds of piles of fresh dog shit falling from the sky rolling off buildings and stacking. we c ould have shit plows! blood washing away. man i tell you it will be so beautiful. because we can inject code we can remote run the simulations and there are plenty of options for interesting effects that otherwise would take forever to create.
User avatar
Megatron
Mamma's Gang member
Mamma's Gang member
Posts: 8030
Joined: Fri Apr 19, 2002 1:00 am
Location: The United Kingdoms

Post by Megatron »

why not just go out into the street and rub dog shit all over your eyes
:chew:
User avatar
Mad Max RW
Paparazzi
Paparazzi
Posts: 2253
Joined: Tue Apr 23, 2002 1:20 am
Location: Balls Deep in the Wasteland
Contact:

Post by Mad Max RW »

STOLEN
User avatar
St. Toxic
Haha you're still not there yet
Haha you're still not there yet
Posts: 3378
Joined: Fri Dec 31, 2004 3:20 am
Location: One-man religion.
Contact:

Post by St. Toxic »

Fuck yeah, I put the code in my android game and now it's selling like hot shit on the market. :dance:
User avatar
Retlaw83
Goatse Messiah
Goatse Messiah
Posts: 5326
Joined: Sat Jul 17, 2004 1:49 am

Post by Retlaw83 »

I uploaded this code to my toaster and haven't stopped having sex with it since.
"You're going to have a tough time doing that without your head, palooka."
- the Vault Dweller
User avatar
Gimp Mask
Mamma's Gang member
Mamma's Gang member
Posts: 5289
Joined: Thu Apr 18, 2002 7:05 pm
Location: / 5327

Post by Gimp Mask »

yeah, pretty awesome code bro
Blargh
Ãœberkommando
Ãœberkommando
Posts: 6303
Joined: Sun Nov 09, 2003 7:11 pm

LET'S RUN THIS <deleted> INTO THE GROUND. :saxophone:

Post by Blargh »

Enheartened by these anecdotes, I decided to 'upload' the 'code' to the noösphere by way of mass chem-trail skywriting and now all the mimes that have been, could be, will be, have cancer. :betterthanLHC:

:drunk:
User avatar
S4ur0n27
Mamma's Gang member
Mamma's Gang member
Posts: 15172
Joined: Sat Jun 01, 2002 10:14 am
Contact:

Post by S4ur0n27 »

Blarghe.
Pizzahut Lover
Cakester Alt; I'm going places in life
Posts: 233
Joined: Tue Apr 12, 2011 10:05 am

Post by Pizzahut Lover »

btw that code never worked. I went through another try of some different code i made to actually draw things based on height map.. but i failed to draw things apart from view. or worse i drawed things properly but when i turned from object the whole rainstorm melted out of sight. not good. man i feel like adding rain again.
si uu
User avatar
Retlaw83
Goatse Messiah
Goatse Messiah
Posts: 5326
Joined: Sat Jul 17, 2004 1:49 am

Post by Retlaw83 »

Of course your code didn't work in a videogame. It's obviously for enabling the secret sex function in toasters.
"You're going to have a tough time doing that without your head, palooka."
- the Vault Dweller
User avatar
S4ur0n27
Mamma's Gang member
Mamma's Gang member
Posts: 15172
Joined: Sat Jun 01, 2002 10:14 am
Contact:

Post by S4ur0n27 »

This guy reminds me of an ancient troll. What was his name? harryp?

Agreed? :dance:
User avatar
Gimp Mask
Mamma's Gang member
Mamma's Gang member
Posts: 5289
Joined: Thu Apr 18, 2002 7:05 pm
Location: / 5327

Re: Lets take a breathe moment to review this code. (Fallout

Post by Gimp Mask »

Pizzahut Lover wrote: const int nResolution = 1024 - 1;
int nIndex = abs(nY) * nResolution + abs(nX);
short shVal = ppHeightmap[nQuad-1][nIndex];
I don't think I fully understood this bit - maybe you could elaborate? thanks
User avatar
Jesus Christ
Mamma's Gang member
Mamma's Gang member
Posts: 1314
Joined: Wed Mar 08, 2006 1:32 am

Post by Jesus Christ »

S4ur0n27 wrote:This guy reminds me of an ancient troll. What was his name? harryp?

Agreed? :dance:
Nah... Haris was just a troll that scripted a spiffy mod and never shared his super-secret secrets with the rest of us. pizzahut has not yet made a mod and has already told us all the somewhat silly secrets of sultry seductive toaster cyphers that he expects on scripting.

Their similar Susan, but not the same sort of spammer.
Our Host!
Post Reply