General Question Simulate heat shield

marcogavazzeni

Addon Developer
Addon Developer
Joined
Jan 5, 2009
Messages
219
Reaction score
0
Points
16
Location
Near Verona
Website
orbiteritalia.forumotion.com
Beyond the formulas more or less valid, with the spot light we can not get a very good effect shield, :rolleyes:

I think you need to add a mesh with MESHPROPERTY_MODULATEMATALPHA formula
Code:
[FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]
[SIZE=2][FONT=Courier New][COLOR=#008000]//*******************SIMULATION HEAT SHIELD***********************[/COLOR][/FONT][/SIZE]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] atmTemp = 0.5*(GetAtmDensity()*(GetAirspeed()*GetAirspeed()*GetAirspeed()));[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] alpha = ((atmTemp-40000000) / 100000000);[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] shield;[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (alpha > 1)[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]alpha = 1;[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (alpha < 0)[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]alpha = 0;[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2]
[SIZE=2][FONT=Courier New]SetMeshVisibilityMode (InsertMesh (hMeshReentryShield,5,&offsetsh),MESHVIS_EXTERNAL);[/FONT][/SIZE]
 
[SIZE=2][FONT=Courier New]oapiSetMeshProperty (hMeshReentryShield,MESHPROPERTY_MODULATEMATALPHA,1);[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] opacity = shield ;[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]MATERIAL *mat = oapiMeshMaterial (hMeshReentryShield, 0);[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]mat->diffuse.a = alpha;[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]mat->ambient.a = alpha;[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]mat->specular.a = alpha;[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]mat->emissive.a = alpha;[/FONT][/SIZE]
[/SIZE][/FONT]

and
Code:
[FONT=Courier New][SIZE=2]
[SIZE=2][FONT=Courier New]COLOUR4 col_r1 = {0.015,0.0,0.0}; [/FONT][/SIZE]
[SIZE=2][FONT=Courier New]COLOUR4 col_r2 = {0.5,0,0,0};[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]COLOUR4 col_r3 = {1.5,0,0,0};[/FONT][/SIZE]
 
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] hflux = (0.5*GetDynPressure() * (GetAirspeed()))/50000;[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]shield_proc = min(hflux/1200.0, 1.0);[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] max_proc = 1.0; [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// should always be 1.0[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] min_proc = 0.0001; [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// range from 0 to max_proc[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] heat_at_min_proc = 4e2;[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] heat_at_max_proc = 12e2;[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]shield_proc = min_proc;[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (hflux > heat_at_min_proc)[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]shield_proc = min ( (hflux - heat_at_min_proc) * (max_proc - min_proc)/ (heat_at_max_proc - heat_at_min_proc) , max_proc - min_proc);[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]SpotLight* le1 =(SpotLight*)AddSpotLight(_V(0.0,-5.0,10.0), _V(0,0.2,-1.0), 70, 1e-3, 0, 1e-3, RAD*55, RAD*60, col_r3, col_r2, col_r1);[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]le1->SetIntensityRef(&shield_proc);[/FONT][/SIZE][/SIZE][/FONT]

Result:

Normal temp
20101228035207.png



Over 500°C
20101228035313.png


Over 900°C
20101228035350.png


Over 1200-1300°C
20101228035441.png
 
Top