Page 3 of 6

Re: 2023-10-14 snapshot

Posted: Thu Oct 19, 2023 4:46 am
by ktm161
is there a way we can get /toggledecals back up and working again? its a real pain in the you know what just to save track then exit the game, pull the decals file out and then open the game back up just to put tile down haha

Re: 2023-10-14 snapshot

Posted: Thu Oct 19, 2023 2:41 pm
by Hayden_Scott
Is it a possibility to get 2 stroke smoke in the next update? Could be like a particle box in blender or something and it moves billboards that are the smoke texture inside that box? or could just some sort of box that is named in blender to assign with some script that is used when the game loads up and reads the bike frame.jm?

Re: 2023-10-14 snapshot

Posted: Thu Oct 19, 2023 7:43 pm
by AtlasZoor
Hayden_Scott wrote: Thu Oct 19, 2023 2:41 pm Is it a possibility to get 2 stroke smoke in the next update? Could be like a particle box in blender or something and it moves billboards that are the smoke texture inside that box? or could just some sort of box that is named in blender to assign with some script that is used when the game loads up and reads the bike frame.jm?
so many other things that are needed other than 2 stroke smoke my guy ☠︎☠︎💀💀

Re: 2023-10-14 snapshot

Posted: Thu Oct 19, 2023 8:30 pm
by ScrubDatMx
Hayden_Scott wrote: Thu Oct 19, 2023 2:41 pm Is it a possibility to get 2 stroke smoke in the next update? Could be like a particle box in blender or something and it moves billboards that are the smoke texture inside that box? or could just some sort of box that is named in blender to assign with some script that is used when the game loads up and reads the bike frame.jm?
Would be a cool feature to have, just these little things will really freshen the game up nicely. Tread marking is already a great step.

Re: 2023-10-14 snapshot

Posted: Thu Oct 19, 2023 11:44 pm
by Hayden_Scott
ScrubDatMx wrote: Thu Oct 19, 2023 8:30 pm
Hayden_Scott wrote: Thu Oct 19, 2023 2:41 pm Is it a possibility to get 2 stroke smoke in the next update? Could be like a particle box in blender or something and it moves billboards that are the smoke texture inside that box? or could just some sort of box that is named in blender to assign with some script that is used when the game loads up and reads the bike frame.jm?
Would be a cool feature to have, just these little things will really freshen the game up nicely. Tread marking is already a great step.
thats what im saying i dont think it would be toooooo hard to do. But i am not a game developer so idk

Re: 2023-10-14 snapshot

Posted: Fri Oct 20, 2023 1:16 am
by jlv
ktm161 wrote: Thu Oct 19, 2023 4:46 am is there a way we can get /toggledecals back up and working again? its a real pain in the you know what just to save track then exit the game, pull the decals file out and then open the game back up just to put tile down haha
Yes. I have a fix for it. I have one other thing to fix and I'll upload an update.

Re: 2023-10-14 snapshot

Posted: Fri Oct 20, 2023 1:20 am
by jlv
Hayden_Scott wrote: Thu Oct 19, 2023 11:44 pm thats what im saying i dont think it would be toooooo hard to do. But i am not a game developer so idk
It wouldn't be too hard to do but things like that turn into death by a thousand cuts. I want to focus on bigger things. The next big update will be the culmination of the terrain rendering optimizations. After that I'm not sure but probably shading via HDR environment maps.

Re: 2023-10-14 snapshot

Posted: Sat Oct 21, 2023 12:53 am
by Donut MX
i love this update - looks really clean. the number of turn tracks ive already carved out...

is there a way to toggle the tread decals on/off in-game?

Re: 2023-10-14 snapshot

Posted: Sat Oct 21, 2023 1:22 am
by jlv
Donut MX wrote: Sat Oct 21, 2023 12:53 am i love this update - looks really clean. the number of turn tracks ive already carved out...

is there a way to toggle the tread decals on/off in-game?
You can set "treadmark limit" to 0 to disable dropping the treadmark decals. No way to hide/show already dropped treadmarks though.

Re: 2023-10-14 snapshot

Posted: Sat Oct 21, 2023 8:43 pm
by jgmtbike
Great update JLV. Is there a way to save the treadmarks you create on the track like decals? I'd like to use them to make single track trails and actually save the marks for my next session.

Re: 2023-10-14 snapshot

Posted: Sat Oct 21, 2023 11:39 pm
by Jakob Hubbard
jgmtbike wrote: Sat Oct 21, 2023 8:43 pm Great update JLV. Is there a way to save the treadmarks you create on the track like decals? I'd like to use them to make single track trails and actually save the marks for my next session.
I made a track script that essentially allows you to do this by logging the decals with their coordinates, angle, size, aspect, etc to lastlog.txt. You have to change what treadmark decals associate with what tile number.

You also have to get rid of the date logs, usually doing it with:

Code: Select all

grep -o '@@@<TREAD_NAME>.*@@@' lastlog.txt > treads.txt
where <TREAD_NAME> is the name of the decal in the track script. It will output to a file in the same directory named "treads.txt" Then you can remove the @@@'s in notepad or any other text editor. The only downside to this script is it doesn't have the customization that jlv's has with different speeds dropping different decals and choosing whether to do front or rear or both wheels (it only does rear wheel). I could easily modify the script to do this but not sure how useful it would be.

Here's the script if anyone wants to save treadmarks. If anyone actually uses this and wants me to modify it to meet jlv's treadmark code, then I can do that.

Code: Select all

// Position and velocity variables for riders rear tire
var rearTirePos = [], rearTireVel = [];

// Running order variable
var globalRunningOrder;

// Change the name to your track folder
const trackFolderName = "@TRACKFOLDERHERE";
const decalsToLog = [
    {
        name: "tread",
        size: 6.000000,
        aspect: 1.0000000,
        texture: trackFolderName + "/decal/tread.png",
        spacing: 2.5,
        tileNumbers: [0, 1, 2, 3, 4, 5, 6, 7, 11],
        minSpeed: 5, // minimum speed needed to log a decal in ft/sec
        lastDecalLogged: [],
    },
    {
        name: "disturbed",
        size: 10.000000,
        aspect: 1.0000000,
        texture: trackFolderName + "/decal/disturbed.png",
        spacing: 10,
        tileNumbers: [0, 1, 2, 3, 4, 5, 6, 7, 11],
        minSpeed: 5,
        lastDecalLogged: [],
    }
]
function logDecals() {
    /* Since this loop goes through the running order, decals should overlap correctly. 
        If second happens to place a decal on top of one close to first's it will be on the layer above */
    for (var i = 0; i < globalRunningOrder.length; i++) {
        var slot = globalRunningOrder[i].slot;
        
        // Loop through each decal in the decals to log array
        for (var j = 0; j < decalsToLog.length; j++) {
            // if there is no coordinates stored for this slot and decal yet add them
            if (decalsToLog[j].lastDecalLogged[slot] == undefined) {
                const rearContactMade = mx.get_rear_contact_position(slot, rearTirePos);
                if (rearContactMade == 1) {

                    // Check to see if the tile number the rear tire is on matches the tile number in the decals to log tileNumbers array
                    const tileNumber = mx.get_tile_number(rearTirePos[0], rearTirePos[2]);
                    if (decalsToLog[j].tileNumbers.indexOf(tileNumber) === -1) continue;

                    // store the X and Z variables if the rear tire has made contact
                    decalsToLog[j].lastDecalLogged[slot] = [rearTirePos[0], rearTirePos[2]];

                    // get the rear contact tire velocity and use it as a normal vector for calculating the angle of the tire in world space
                    mx.get_rear_contact_velocity(slot, rearTireVel);
                    // Calculate the rear tire velocity and put it in range of 0 to 2pi and rotate 270 degrees counterclockwise
                    const rearTireAngle = ((Math.atan2((-1 * rearTireVel[2]), rearTireVel[0]) + Math.PI * 2) + (3 * Math.PI / 2)) % (Math.PI * 2);
                    mx.message("@@@" + decalsToLog[j].name.toUpperCase() + "[" + rearTirePos[0].toFixed(6) + " " + rearTirePos[2].toFixed(6) + "] " + rearTireAngle.toFixed(6) + " " + decalsToLog[j].size + " " + decalsToLog[j].aspect + " " + decalsToLog[j].texture + "@@@");
                }
            }

            const rearContactMade = mx.get_rear_contact_position(slot, rearTirePos);

            // if the rider is in the air we don't want to log a decal placement
            if (rearContactMade == 0) continue;

            // Check to see if the tile number the rear tire is on matches the tile number in the decals to log tileNumbers array
            const tileNumber = mx.get_tile_number(rearTirePos[0], rearTirePos[2]);
            if (decalsToLog[j].tileNumbers.indexOf(tileNumber) === -1) continue;

            // calculate distance from current tire contact vs last decal placed and check to make sure it's greater than the minimum distance between decals
            const differenceFromLastPlacement = distanceCalculation2D(decalsToLog[j].lastDecalLogged[slot][0], decalsToLog[j].lastDecalLogged[slot][1], rearTirePos[0], rearTirePos[2]);
            if (differenceFromLastPlacement > decalsToLog[j].spacing) {
                decalsToLog[j].lastDecalLogged[slot] = [rearTirePos[0], rearTirePos[2]];

                // get the rear contact tire velocity and use it as a normal vector for calculating the angle of the tire in world space
                mx.get_rear_contact_velocity(slot, rearTireVel);
                const magnitude = Math.sqrt(Math.pow(rearTireVel[0],2) + Math.pow(rearTireVel[1],2) + Math.pow(rearTireVel[2],2));
                if (magnitude < decalsToLog[j].minSpeed) continue;
                // Calculate the rear tire velocity and put it in range of 0 to 2pi and rotate 270 degrees counterclockwise
                const rearTireAngle = ((Math.atan2((-1 * rearTireVel[2]), rearTireVel[0]) + Math.PI * 2) + (3 * Math.PI / 2)) % (Math.PI * 2);
                mx.message("@@@" + decalsToLog[j].name.toUpperCase() + "[" + rearTirePos[0].toFixed(6) + " " + rearTirePos[2].toFixed(6) + "] " + rearTireAngle.toFixed(6) + " " + decalsToLog[j].size + " " + decalsToLog[j].aspect + " " + decalsToLog[j].texture + "@@@");
            }
        }
    }
}

function distanceCalculation2D(x1,y1,x2,y2) {
    return Math.sqrt(Math.pow(x2-x1,2) + Math.pow(y2-y1,2));
}

function frameHandler(seconds) {
    globalRunningOrder = mx.get_running_order();
    logDecals();
}

mx.frame_handler = frameHandler;

Re: 2023-10-14 snapshot

Posted: Sun Oct 22, 2023 1:36 am
by jlv
jgmtbike wrote: Sat Oct 21, 2023 8:43 pm Great update JLV. Is there a way to save the treadmarks you create on the track like decals? I'd like to use them to make single track trails and actually save the marks for my next session.
No way to save them currently. It merges all the different treadmark textures into one atlas texture for the sake of efficiency. That makes it difficult to save them since it'd have to keep an index mapping the atlased textures back to their original files. I took the easy way out and just skipped saving them.

Looks like Jakob has a pretty good way to get the same effect.

Re: 2023-10-14 snapshot

Posted: Sun Oct 22, 2023 6:56 am
by jgmtbike
Jakob Hubbard wrote: Sat Oct 21, 2023 11:39 pm
jgmtbike wrote: Sat Oct 21, 2023 8:43 pm Great update JLV. Is there a way to save the treadmarks you create on the track like decals? I'd like to use them to make single track trails and actually save the marks for my next session.
I made a track script that essentially allows you to do this by logging the decals with their coordinates, angle, size, aspect, etc to lastlog.txt. You have to change what treadmark decals associate with what tile number.

You also have to get rid of the date logs, usually doing it with:

Code: Select all

grep -o '@@@<TREAD_NAME>.*@@@' lastlog.txt > treads.txt
where <TREAD_NAME> is the name of the decal in the track script. It will output to a file in the same directory named "treads.txt" Then you can remove the @@@'s in notepad or any other text editor. The only downside to this script is it doesn't have the customization that jlv's has with different speeds dropping different decals and choosing whether to do front or rear or both wheels (it only does rear wheel). I could easily modify the script to do this but not sure how useful it would be.

Here's the script if anyone wants to save treadmarks. If anyone actually uses this and wants me to modify it to meet jlv's treadmark code, then I can do that.

Code: Select all

// Position and velocity variables for riders rear tire
var rearTirePos = [], rearTireVel = [];

// Running order variable
var globalRunningOrder;

// Change the name to your track folder
const trackFolderName = "@TRACKFOLDERHERE";
const decalsToLog = [
    {
        name: "tread",
        size: 6.000000,
        aspect: 1.0000000,
        texture: trackFolderName + "/decal/tread.png",
        spacing: 2.5,
        tileNumbers: [0, 1, 2, 3, 4, 5, 6, 7, 11],
        minSpeed: 5, // minimum speed needed to log a decal in ft/sec
        lastDecalLogged: [],
    },
    {
        name: "disturbed",
        size: 10.000000,
        aspect: 1.0000000,
        texture: trackFolderName + "/decal/disturbed.png",
        spacing: 10,
        tileNumbers: [0, 1, 2, 3, 4, 5, 6, 7, 11],
        minSpeed: 5,
        lastDecalLogged: [],
    }
]
function logDecals() {
    /* Since this loop goes through the running order, decals should overlap correctly. 
        If second happens to place a decal on top of one close to first's it will be on the layer above */
    for (var i = 0; i < globalRunningOrder.length; i++) {
        var slot = globalRunningOrder[i].slot;
        
        // Loop through each decal in the decals to log array
        for (var j = 0; j < decalsToLog.length; j++) {
            // if there is no coordinates stored for this slot and decal yet add them
            if (decalsToLog[j].lastDecalLogged[slot] == undefined) {
                const rearContactMade = mx.get_rear_contact_position(slot, rearTirePos);
                if (rearContactMade == 1) {

                    // Check to see if the tile number the rear tire is on matches the tile number in the decals to log tileNumbers array
                    const tileNumber = mx.get_tile_number(rearTirePos[0], rearTirePos[2]);
                    if (decalsToLog[j].tileNumbers.indexOf(tileNumber) === -1) continue;

                    // store the X and Z variables if the rear tire has made contact
                    decalsToLog[j].lastDecalLogged[slot] = [rearTirePos[0], rearTirePos[2]];

                    // get the rear contact tire velocity and use it as a normal vector for calculating the angle of the tire in world space
                    mx.get_rear_contact_velocity(slot, rearTireVel);
                    // Calculate the rear tire velocity and put it in range of 0 to 2pi and rotate 270 degrees counterclockwise
                    const rearTireAngle = ((Math.atan2((-1 * rearTireVel[2]), rearTireVel[0]) + Math.PI * 2) + (3 * Math.PI / 2)) % (Math.PI * 2);
                    mx.message("@@@" + decalsToLog[j].name.toUpperCase() + "[" + rearTirePos[0].toFixed(6) + " " + rearTirePos[2].toFixed(6) + "] " + rearTireAngle.toFixed(6) + " " + decalsToLog[j].size + " " + decalsToLog[j].aspect + " " + decalsToLog[j].texture + "@@@");
                }
            }

            const rearContactMade = mx.get_rear_contact_position(slot, rearTirePos);

            // if the rider is in the air we don't want to log a decal placement
            if (rearContactMade == 0) continue;

            // Check to see if the tile number the rear tire is on matches the tile number in the decals to log tileNumbers array
            const tileNumber = mx.get_tile_number(rearTirePos[0], rearTirePos[2]);
            if (decalsToLog[j].tileNumbers.indexOf(tileNumber) === -1) continue;

            // calculate distance from current tire contact vs last decal placed and check to make sure it's greater than the minimum distance between decals
            const differenceFromLastPlacement = distanceCalculation2D(decalsToLog[j].lastDecalLogged[slot][0], decalsToLog[j].lastDecalLogged[slot][1], rearTirePos[0], rearTirePos[2]);
            if (differenceFromLastPlacement > decalsToLog[j].spacing) {
                decalsToLog[j].lastDecalLogged[slot] = [rearTirePos[0], rearTirePos[2]];

                // get the rear contact tire velocity and use it as a normal vector for calculating the angle of the tire in world space
                mx.get_rear_contact_velocity(slot, rearTireVel);
                const magnitude = Math.sqrt(Math.pow(rearTireVel[0],2) + Math.pow(rearTireVel[1],2) + Math.pow(rearTireVel[2],2));
                if (magnitude < decalsToLog[j].minSpeed) continue;
                // Calculate the rear tire velocity and put it in range of 0 to 2pi and rotate 270 degrees counterclockwise
                const rearTireAngle = ((Math.atan2((-1 * rearTireVel[2]), rearTireVel[0]) + Math.PI * 2) + (3 * Math.PI / 2)) % (Math.PI * 2);
                mx.message("@@@" + decalsToLog[j].name.toUpperCase() + "[" + rearTirePos[0].toFixed(6) + " " + rearTirePos[2].toFixed(6) + "] " + rearTireAngle.toFixed(6) + " " + decalsToLog[j].size + " " + decalsToLog[j].aspect + " " + decalsToLog[j].texture + "@@@");
            }
        }
    }
}

function distanceCalculation2D(x1,y1,x2,y2) {
    return Math.sqrt(Math.pow(x2-x1,2) + Math.pow(y2-y1,2));
}

function frameHandler(seconds) {
    globalRunningOrder = mx.get_running_order();
    logDecals();
}

mx.frame_handler = frameHandler;
Thanks a bunch bro!!!!!! :D :D :D

Re: 2023-10-14 snapshot

Posted: Tue Oct 24, 2023 12:21 am
by jlv
Updated 2023-10-23:
  • Fixed toggledecals.
  • Fixed upsampling to use bilinear filtering when treadmark color/norm/spec maps have mismatched sizes. Previously used point sampling
Windows users: https://mxsimulator.com/snapshots/mx-2023-10-23-1662.exe
Linux users: https://mxsimulator.com/snapshots/mxbin-2023-10-23-1662

Re: 2023-10-14 snapshot

Posted: Tue Oct 24, 2023 5:41 am
by yzmxer608
This does look great after seeing it on the Owens Valley track!

I had some flashbacks, somehow still had it bookmarked. Is this related to this old script? https://forum.mxsimulator.com/viewtopic ... 332#p73332