VStanced/mods
Submit a mod
Mods Guides Forum Submit a mod Log in Register

Forum

Questions, builds, help and the odd argument. The mods and guides are out front.

Adnan54 Workshop
 
Notifications
Clear all

Adnan54 Workshop

313 Posts
66 Users
0 Reactions
229.3 K Views
Holy_Shit_Man
(@holy_shit_man_3240)
Member Moderator
Joined: 14 years ago
Posts: 2251
 

Without any Java knowledge? I doubt so



   
ReplyQuote
JF1
 JF1
(@jf1_12736)
Noble Member
Joined: 12 years ago
Posts: 1166
 

I have java knowledge. Or at least enough to use it in SLR:R.



   
ReplyQuote
Holy_Shit_Man
(@holy_shit_man_3240)
Member Moderator
Joined: 14 years ago
Posts: 2251
 

Trust me, changing names in javas isn't Java knowledge. But sure, you can try 😉



   
ReplyQuote
JF1
 JF1
(@jf1_12736)
Noble Member
Joined: 12 years ago
Posts: 1166
 

It's not just changing java names. But anyway, off the topic of underestimating.

So I'll attempt the gauge, and if successful, send it to Adnan.



   
ReplyQuote
Holy_Shit_Man
(@holy_shit_man_3240)
Member Moderator
Joined: 14 years ago
Posts: 2251
 

It's not underestimating. I'm saying that nobody with common sense would try to do that (even though it sounds simple and I have an idea how could it be done; no Java skills though)

Added 44 seconds later:

Aaaadnan! Show us some bumpers now



   
ReplyQuote
JF1
 JF1
(@jf1_12736)
Noble Member
Joined: 12 years ago
Posts: 1166
 
KJ wrote

"Aaaadnan! Show us some bumpers now"

How very polite. Anyway, I agree, Adnan, can we see more progress.



   
ReplyQuote
adnan54
(@adnan54_2457)
Reputable Member
Joined: 14 years ago
Posts: 252
Topic starter  

# Jfernando1 :
Also, in other news, have you tried the Civic bumpers?

I've checked the EK9 updated by Razine & Joealex, it have all the bumpers from Forza 4 so idk why to export it again. (VS EK9 and my single piece EK9 comes from Forza 4, basically they are the same model with different uvw mapping).

About the digital speedo:
I think it is not that hard to script, but the way that i'm think it could be done require some patience
My idea is something like this:

public void updatevariables()
{
	the_car = null;
 	getCar_LocalVersion();
 
if( the_car && GameLogic.player && GameLogic.player && GameLogic.player.car && the_car == GameLogic.player.car.chassis ) // player is using this car
{
	float speed = player.car.getSpeedSquare();

	switch (speed)
	{
		case 1: //1km/h
		{
			setRenderType(cars.NIS_SkylineGTRVSpecII_02.speedo:0x0002r); //set render to 1km/h
			Thread.sleep( 250 ); // wait 0.25 s
			break;
		}
		case 2: //2km/h
		{
			setRenderType(cars.NIS_SkylineGTRVSpecII_02.speedo:0x0003r); //set render to 2km/h
			Thread.sleep( 250 ); // wait 0.25 s
			break;
		}
		case 3: //3km/h
		{
			setRenderType(cars.NIS_SkylineGTRVSpecII_02.speedo:0x0004r); //set render to 3km/h
			Thread.sleep( 250 ); // wait 0.25 s
			break;
		}
		.
		.
		.
		case 319: //319km/h
		{
			setRenderType(cars.NIS_SkylineGTRVSpecII_02.speedo:0x0320r); //set render to 319km/h
			Thread.sleep( 250 ); // wait 0.25 s
			break;
		}
		case 320: //320km/h
		{
			setRenderType(cars.NIS_SkylineGTRVSpecII_02.speedo:0x0321r); //set render to 320km/h
			Thread.sleep( 250 ); // wait 0.25 s
			break;
		}
		default: //0km/h
		setRenderType(cars.NIS_SkylineGTRVSpecII_02.speedo:0x0001r);  //set render to 0km/h
		Thread.sleep( 100 ); // wait 0.1 s
		break;
	}
}
}

Of course i know that it wouldn't work in exactly that way, i just have started to learn programming few months ago so i'm still a noob xD



   
ReplyQuote
Alexkiller3
(@alexkiller3_20202)
Estimable Member
Joined: 11 years ago
Posts: 110
 

Well that is a genius Idea but you will hav to do it 320 times.Lets say that the gauge takes values from
0-290 km/h.You have to do it 290 times.

Added 15 minutes later:

And something else.In the middle of the dash there is an display which says your gear.It is automatic transmission.Lets say that this is easy to make one automatic.But this how will work.



   
ReplyQuote
RedCarDriver
(@redcardriver_1155)
Member Moderator
Joined: 15 years ago
Posts: 1125
 

Here's the script I wrote for the multiple-scale analog speedometer for the Audi A5/S5/RS5:

Spoiler:

public class SpeedometerBase extends DecorativeBodyPart
{
	// begin movable speedometer script
	Ypr anim_ori; // rotation vector, dynamically assigned
	
int speedo_check_overflow	= 0;
int speedo_check_underflow	= 1;

int speedo_num_regions = 1; // will be equal to last array's index; number of speedometer "chunks"
float[] speedo_value	= new float[5];
float[] speedo_pos	= new float[5];

Thread AnimateThread;
int installed;

public SpeedometerBase( int id )
{
	super( id );
			
	speedo_num_regions = 3;
	speedo_value[0]	= 0.0;
	speedo_pos[0]	= 0;
	speedo_value[1]	= 80.0;
	speedo_pos[1]	= 120;
	speedo_value[2]	= 240.0;
	speedo_pos[2]	= 240;
	speedo_value[3]	= 300.0;
	speedo_pos[3]	= 270;
	
	AnimateThread = new Thread( this, "Animate Thread" );
	//animate_last_time = System.simTime();
	AnimateThread.start();
}

public void resetAnim() // forces animation to reset
{
	if( partOnSlot(991) )
		partOnSlot(991).setSlotPos( 1, new Vector3(0,0,0), new Ypr(0,0,0) );
}

public void setGaugeNeedlePos( float deg )
{
	if( partOnSlot(991) )
		partOnSlot(991).setSlotPos( 1, new Vector3(0,0,0), new Ypr(0,0,deg2rad(deg)) );
}

public float rad2deg( float rad )
{
	return(rad * 180 / 3.1415926);
}
public float deg2rad( float deg )
{
	return(deg * 3.1415926 / 180);
}

public float calcPointSlope( float x, float x1, float y1, float x2, float y2 )
{
	return (y1 + (x-x1)*((y2-y1)/(x2-x1)));
}

public float position_interp( float speed )
{
	float deg;
	if( speedo_pos.length != speedo_value.length )
		return 0;
	int max = speedo_num_regions;
	
	// Anti-Overrun Checks
	if( speedo_check_overflow && speed > speedo_value[max] )
		speed = speedo_value[max];
	else if ( speedo_check_underflow && speed < speedo_value[0] )
		speed = speedo_value[0];
	
	int region = -1;
	int test_looper = 0;
	if( speed < speedo_value[0] )
		region = 0;
	while( region == -1 )
	{
		if( speed >= speedo_value[test_looper] && speed <= speedo_value[test_looper+1] )
			region = test_looper;
		if( test_looper == max-1 )
			region = max-1;
		test_looper++;
	}
		
	deg = calcPointSlope( speed, speedo_value[region], speedo_pos[region], speedo_value[region+1], speedo_pos[region+1] );
	
	return deg;
}

public void run()
{
	while(1)
	{
		if(AnimateThread)
		{
			the_car = null;
			getCar_LocalVersion();
			
			if( the_car && GameLogic.player && GameLogic.player.car && the_car == GameLogic.player.car.chassis ) // player is using this car
			{
				installed = 1;
				
				float speed = Math.sqrt(GameLogic.player.car.getSpeedSquare())*3.6;
				setGaugeNeedlePos(position_interp(speed));
				//setSlotPos( 991, new Vector3(0,0,0), new Ypr(0,0,-3.142) );
				
				if(AnimateThread) AnimateThread.sleep(5); // Wait 0.005 sec (in theory, assuming 29 FPS)
			}
			else
			{
				if( installed )
				{
					setSlotPos( 991, new Vector3(0,0,0), new Ypr(0,0,0) );
					installed = 0;
				}

				if(AnimateThread) AnimateThread.sleep( 2000 ); // Wait 2 sec
			}
		}
	}
}
}

Give me a bit and I'll have a digital version, because believe me, I will have a digital speedometer available in the R33.

(Also, the only reason I used "switch / case / break" instead of "if / then / else" in that snippet of code I sent you is because it was easier. For most cases, it will be significantly easier to do what you want with if / then / else.)



   
ReplyQuote
adnan54
(@adnan54_2457)
Reputable Member
Joined: 14 years ago
Posts: 252
Topic starter  

As i said, i'm still a noob at programming xD
I thought in using "switch case" because my teacher said that it works faster than "if else" especially when you have a lot of entries/values/variations
I don't know if it really makes a huge difference

I'm learning C++ btw


   
ReplyQuote
RedCarDriver
(@redcardriver_1155)
Member Moderator
Joined: 15 years ago
Posts: 1125
 

It doesn't cause any significant speed problems in-game on my machine, but it might on yours.

Also consider that making it check 320 cases is computationally expensive anyway. It should probably just set the hundreds, tens, and units digits separately (using a modulus operator or something like that).

I'll have a digital speedometer added to the R33 (as a custom part) in short order. It should show you how to make this work.

(Now I really wish SLRR actually sent out the engine RPM to the Java files. If so, I could help you make an accurate script for the "kouki" R34 gauges with the multi-scale tachometer, and maybe even a digital gauge cluster too. Not to mention swap-able tachometers.)



   
ReplyQuote
Victor_F
(@victor_f_27845)
Active Member
Joined: 9 years ago
Posts: 17
 

Can you give Beta version BNR34? 😃 😃
Can't waiting, it's hard 😛



   
ReplyQuote
RedCarDriver
(@redcardriver_1155)
Member Moderator
Joined: 15 years ago
Posts: 1125
 

Here's what I came up with for a digital speedometer. Note that this is completely un-tested and I could very well have made some errors. (I will, however, have it tested in short order.)

Also, this is for a "slot machine wheel" way of rendering the digits, where it rotates vertically. If you want to set it up another way, just change the code in setGaugeDigitPos. If you want to use different renders, look at the source code for my Crossfire wing (or for BB93's Community Rimpack) to see how to change the render of an object.
Spoiler:

package java.game.cars;

import java.io.*;
import java.util.*;
import java.util.resource.*;
import java.render.osd.*;
import java.game.*;
import java.game.cars.*;
import java.game.parts.*;
import java.game.parts.bodypart.*;
import java.game.parts.enginepart.*;
import java.game.parts.rgearpart.*;
import java.game.parts.rgearpart.reciprocatingrgearpart.*;


public class SpeedometerDigital extends DecorativeBodyPart
{
	// begin movable speedometer script
	Ypr anim_ori_1; // rotation vector for first digit (units), dynamically assigned
	Ypr anim_ori_2; // rotation vector for second digit (tens), dynamically assigned
	Ypr anim_ori_3; // rotation vector for third digit (hundreds), dynamically assigned
	
// int speedo_check_overflow	= 0;
// int speedo_check_underflow	= 1;

// int speedo_num_regions = 1; // will be equal to last array's index; number of speedometer "chunks"
// float[] speedo_value	= new float[5];
// float[] speedo_pos	= new float[5];

int speedo_units = 0; // 0 = metric, 1 = Imperial / US customary
int speedo_hide_unused_digits = 1; // 1 = yes, 0 = no

Thread AnimateThread;
int installed;

static float math_pi = 3.1415926;
static float kmh_to_mph = 0.621371;
static float deg_to_rad = math_pi / 180;

public SpeedometerDigital( int id )
{
	super( id );
	
	speedo_units = 0;
	speedo_hide_unused_digits = 1;
	
	AnimateThread = new Thread( this, "Animate Thread" );
	AnimateThread.start();
}

public void resetAnim() // forces animation to reset
{
	if( partOnSlot(991) )
		partOnSlot(991).setSlotPos( 1, new Vector3(0,0,0), new Ypr(0,0,0) );
	if( partOnSlot(992) )
		partOnSlot(993).setSlotPos( 1, new Vector3(0,0,0), new Ypr(0,0,0) );
	if( partOnSlot(993) )
		partOnSlot(993).setSlotPos( 1, new Vector3(0,0,0), new Ypr(0,0,0) );
}

public void setGaugeDigitPos( int dig1, int dig2, int dig3 )
{
	if( partOnSlot(991) )
		partOnSlot(991).setSlotPos( 1, new Vector3(0,0,0), new Ypr(0,deg2rad(dig1/10*360),0) );
	else if( partOnSlot(991) ) // checks to see if first speedo digit is installed
		partOnSlot(991).setSlotPos( 1, new Vector3(0,-0.100,0), new Ypr(0,0,0) );
	if( partOnSlot(992) && (dig2 || !speedo_hide_unused_digits) ) // checks to see not only if second digit part is installed, but also if either dig2 >= 0 or hide_unused_digits is false
		partOnSlot(992).setSlotPos( 1, new Vector3(0,0,0), new Ypr(0,deg2rad(dig2/10*360),0) );
	else if( partOnSlot(992) )
		partOnSlot(991).setSlotPos( 1, new Vector3(0,-0.100,0), new Ypr(0,0,0) );
	if( partOnSlot(993) && (dig3 || !speedo_hide_unused_digits) ) // checks to see not only if second digit part is installed, but also if either dig3 >= 0 or hide_unused_digits is false
		partOnSlot(993).setSlotPos( 1, new Vector3(0,0,0), new Ypr(0,deg2rad(dig2/10*360),0) );
	else if( partOnSlot(993) )
		partOnSlot(991).setSlotPos( 1, new Vector3(0,-0.100,0), new Ypr(0,0,0) );
}

public float rad2deg( float rad )
{
	return(rad / deg_to_rad);
}
public float deg2rad( float deg )
{
	return(deg * deg_to_rad);
}

public float kmh2mph( float kmh )
{
	return(kmh * kmh_to_mph);
}

public float mph2kmh( float mph )
{
	return(mph / kmh_to_mph);
}

public int speedo_calc_digit1 ( float speed, int  )
{
	int result;
	float speedtemp;
	if( speedo_units )
		speedtemp = kmh2mph(speedtemp);
	
	while (speedtemp >= 100)
		speedtemp += (-100);
	while (speedtemp >= 10)
		speedtemp += (-10);
	
	result = speedtemp;
	
	return result;
}

public int speedo_calc_digit2 ( float speed, int  )
{
	int result;
	float speedtemp;
	if( speedo_units )
		speedtemp = kmh2mph(speedtemp);
	
	while (speedtemp >= 100)
		speedtemp += (-100);
	
	speedtemp = speedtemp / 10;
	
	result = speedtemp;
	
	return result;
}

public int speedo_calc_digit3 ( float speed, int  )
{
	int result;
	float speedtemp;
	if( speedo_units )
		speedtemp = kmh2mph(speedtemp);
	
	speedtemp = speedtemp / 100;
	
	result = speedtemp;
	
	return result;
}

public void run()
{
	while(1)
	{
		if(AnimateThread)
		{
			the_car = null;
			getCar_LocalVersion();
			
			if( the_car && GameLogic.player && GameLogic.player.car && the_car == GameLogic.player.car.chassis ) // player is using this car
			{
				installed = 1;
				
				float speed = Math.sqrt(GameLogic.player.car.getSpeedSquare())*3.6;
				setGaugeDigitPos(speedo_calc_digit1(speed),speedo_calc_digit2(speed),speedo_calc_digit3(speed));
				//setSlotPos( 991, new Vector3(0,0,0), new Ypr(0,0,-3.142) );
				
				if(AnimateThread) AnimateThread.sleep(5); // Wait 0.005 sec (in theory, assuming 29 FPS)
			}
			else
			{
				if( installed )
				{
					setSlotPos( 991, new Vector3(0,0,0), new Ypr(0,0,0) );
					setSlotPos( 992, new Vector3(0,0,0), new Ypr(0,0,0) );
					setSlotPos( 993, new Vector3(0,0,0), new Ypr(0,0,0) );
					installed = 0;
				}

				if(AnimateThread) AnimateThread.sleep( 2000 ); // Wait 2 sec
			}
		}
	}
}
}


   
ReplyQuote
Alexkiller3
(@alexkiller3_20202)
Estimable Member
Joined: 11 years ago
Posts: 110
 

Do you know something.Adnan.Model first the gauge,make the texture and then we see about how it will work.



   
ReplyQuote
JF1
 JF1
(@jf1_12736)
Noble Member
Joined: 12 years ago
Posts: 1166
 

Okay. We'll see what we can do.

Added 26 seconds later:

That isn't in reference to me doing anything on the main mod, just trying to make a script for it.



   
ReplyQuote
Page 13 / 21
Share: