Duck and Cover Forum Index


Use these links, buy stuff from Amazon and help us out, nubs.
Amazon.com | Amazon.ca | Amazon.co.uk | Amazon.de
  Duck and Cover  •  FAQ  •  Search  •  Memberlist  •  Usergroups   •  Register  •  Profile  •  Log in to check your private messages  •  Log in

 Support DAC!
 Lets take a breathe moment to review this code. (Fallout 3) View next topic
View previous topic
Post new topicReply to topic
Author Message
Pizzahut Lover
Cakester Alt; I'm going places in life


Joined: 12 Apr 2011
Posts: 233

PostPosted: Fri Mar 16, 2012 4:10 am Reply with quoteBack to top

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:
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 (nX <= 0 && nY <0>= 0 && nY <= 0)
        nQuad = 4;

    if (outQuad != nQuad)
    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(nY) * nResolution + abs(nX);
    short shVal = ppHeightmap[nQuad-1][nIndex];

    return nHeightValue;
}

void falloutgame()
{
    bool bInWasteland = true;
    int nPlayerQuadrant = 0;
    while (bInWasteland == true)
    {
        int nPlayerX = 0;
        int nPlayerY = 0;

        const int nAreaLengthX = 5;
        const int nAreaLengthY = 5;
        for (int xxx = 0; xxx < nAreaLengthX; ++xxx) {
            for (int yyy = 0; yyy < nAreaLengthY; ++yyy) {

                int nHeight = XYToZ(nPlayerX + xxx, nPlayerY + yyy, nPlayerQuadrant);

                /*
                * 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 (fluids) using the position data.
                */

            }
        }


    }
}


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.
View user's profileSend private message
Pizzahut Lover
Cakester Alt; I'm going places in life


Joined: 12 Apr 2011
Posts: 233

PostPosted: Fri Mar 16, 2012 4:30 am Reply with quoteBack to top

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:

 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(nY) * nResolution + abs(nX);
    short shVal = ppHeightmap[nQuad-1][nIndex];

    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
View user's profileSend private message
Pizzahut Lover
Cakester Alt; I'm going places in life


Joined: 12 Apr 2011
Posts: 233

PostPosted: Fri Mar 16, 2012 4:54 am Reply with quoteBack to top

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

Code:

namespace liquidfallout
{
const int QuadrantResolution = 1024;
const int QuadrantPixelLength = 1023;
const int QuadrantScaling = 65535 / QuadrantResolution;
void ConvertPosition(int &X, int &Y)
{
    X = X / 2;
    X = X / QuadrantScaling;

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

}


int  DetermineQuadrant(const int &X, const int &Y)
{
    int nQuad = 1;
    if (X >= 0 && Y >= 0)
        nQuad = 2;
    else if (X <= 0 && Y <0>= 0 && Y <= 0)
        nQuad = 4;

    return nQuad;
}
 
int GetHeightValue(const int &X, const int &Y, short* pHeightmap)
{
    int nX = X;
    int nY = Y;
 
    int nHeight = 0;
 
    int nIndex = abs(nY) * QuadrantPixelLength + abs(nX);
    short shVal = pHeightmap[nIndex];
    nHeight = (int)shVal;
 
    return nHeight;
}
 
}
 
 
short ** ppHeightmap;
 
void falloutgame()
{
    bool bInWasteland = true;
    int nPlayerQuadrant = 0;
    while (bInWasteland == true)
    {
        int nPlayerX = 0;
        int nPlayerY = 0;
 
        const int nAreaLengthX = 5;
        const int nAreaLengthY = 5;
        for (int xxx = 0; xxx < nAreaLengthX; ++xxx)
        {
            for (int yyy = 0; yyy < nAreaLengthY; ++yyy)
            {
 
                int nX = nPlayerX + xxx;
                int nY = nPlayerY + yyy;
 
                nPlayerQuadrant = liquidfallout::DetermineQuadrant(nX, nY);
                liquidfallout::ConvertPosition(nX, nY);
                int nHeight = liquidfallout::GetHeightValue(nX, nY, ppHeightmap[nPlayerQuadrant-1]);
 
 
            }
        }
 
    }
}
View user's profileSend private message
Pizzahut Lover
Cakester Alt; I'm going places in life


Joined: 12 Apr 2011
Posts: 233

PostPosted: Fri Mar 16, 2012 5:09 am Reply with quoteBack to top

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
View user's profileSend private message
Pizzahut Lover
Cakester Alt; I'm going places in life


Joined: 12 Apr 2011
Posts: 233

PostPosted: Fri Mar 16, 2012 6:01 am Reply with quoteBack to top

fucking bitch.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb205779%28v=vs.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.
View user's profileSend private message
Retlaw83
Goatse Messiah
Goatse Messiah


Joined: 17 Jul 2004
Posts: 5327

PostPosted: Fri Mar 16, 2012 6:17 am Reply with quoteBack to top

Doesn't the rain in Honest Hearts act like you want already?
View user's profileSend private message
Pizzahut Lover
Cakester Alt; I'm going places in life


Joined: 12 Apr 2011
Posts: 233

PostPosted: Fri Mar 16, 2012 6:37 am Reply with quoteBack to top

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.
View user's profileSend private message
Megatron
Mamma's Gang member
Mamma's Gang member


Joined: 19 Apr 2002
Posts: 7841
Location: The United Kingdoms

PostPosted: Mon Mar 19, 2012 9:30 am Reply with quoteBack to top

why not just go out into the street and rub dog shit all over your eyes
View user's profileSend private message
Mad Max RW
Paparazzi
Paparazzi


Joined: 23 Apr 2002
Posts: 2257
Location: Balls Deep in the Wasteland

PostPosted: Tue May 15, 2012 9:34 pm Reply with quoteBack to top

STOLEN
View user's profileSend private messageSend e-mailYahoo MessengerICQ Number
St. Toxic
Haha you're still not there yet
Haha you're still not there yet


Joined: 31 Dec 2004
Posts: 3379
Location: One-man religion.

PostPosted: Thu May 17, 2012 6:32 am Reply with quoteBack to top

Fuck yeah, I put the code in my android game and now it's selling like hot shit on the market. icon_dance
View user's profileSend private messageSend e-mailAIM AddressYahoo Messenger
Retlaw83
Goatse Messiah
Goatse Messiah


Joined: 17 Jul 2004
Posts: 5327

PostPosted: Fri May 18, 2012 12:41 am Reply with quoteBack to top

I uploaded this code to my toaster and haven't stopped having sex with it since.
View user's profileSend private message
Gimp Mask
Mamma's Gang member
Mamma's Gang member


Joined: 18 Apr 2002
Posts: 3525
Location: 18 Apr 2012

PostPosted: Sat May 26, 2012 3:59 pm Reply with quoteBack to top

yeah, pretty awesome code bro
View user's profileSend private message
Blargh
▄berkommando
▄berkommando


Joined: 09 Nov 2003
Posts: 6316

PostPosted: Sun May 27, 2012 2:16 am Reply with quoteBack to top

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:

icon_drunk
View user's profileSend private message
S4ur0n27
Mamma's Gang member
Mamma's Gang member


Joined: 01 Jun 2002
Posts: 15143
Location: Motherfucking Plateau

PostPosted: Thu May 31, 2012 2:07 pm Reply with quoteBack to top

Blarghe.
View user's profileSend private messageVisit poster's websiteMSN MessengerICQ Number
Pizzahut Lover
Cakester Alt; I'm going places in life


Joined: 12 Apr 2011
Posts: 233

PostPosted: Sat Jun 02, 2012 3:51 am Reply with quoteBack to top

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.
View user's profileSend private message
Retlaw83
Goatse Messiah
Goatse Messiah


Joined: 17 Jul 2004
Posts: 5327

PostPosted: Sat Jun 02, 2012 4:45 am Reply with quoteBack to top

Of course your code didn't work in a videogame. It's obviously for enabling the secret sex function in toasters.
View user's profileSend private message
S4ur0n27
Mamma's Gang member
Mamma's Gang member


Joined: 01 Jun 2002
Posts: 15143
Location: Motherfucking Plateau

PostPosted: Mon Jun 04, 2012 2:06 pm Reply with quoteBack to top

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

Agreed? icon_dance
View user's profileSend private messageVisit poster's websiteMSN MessengerICQ Number
Gimp Mask
Mamma's Gang member
Mamma's Gang member


Joined: 18 Apr 2002
Posts: 3525
Location: 18 Apr 2012

PostPosted: Tue Jun 05, 2012 7:18 am Reply with quoteBack to top

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
View user's profileSend private message
Jesus Christ
Mamma's Gang member
Mamma's Gang member


Joined: 08 Mar 2006
Posts: 1313

PostPosted: Tue Jun 05, 2012 9:02 am Reply with quoteBack to top

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

Agreed? icon_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.
View user's profileSend private message
Display posts from previous:      
Post new topicReply to topic


Jump to:  



View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group