Render Targets

From RAGE Multiplayer Wiki
Jump to: navigation, search

You can use drawSprite, drawRect, drawText, and drawScaleformMovie on certain props to draw to them in 3D real-time.

Note: You HAVE to set the drawing to use layer 4. Other layers do not work. Blame China Rockstar interns.

Limitations: Multiple objects that have the same render target name (tvscreen for example), will all display the exact same thing at once on the whole map. This means to display different things, you have to use different props.

Functions usable:

isNamedRendertargetLinked

isNamedRendertargetRegistered

linkNamedRendertarget

registerNamedRendertarget

releaseNamedRendertarget

getNamedRendertargetRenderId

setTextRenderId

Example script which spawns a large screen and draws to it.

//Load texture dictionary for example
if(!mp.game.graphics.hasStreamedTextureDictLoaded("mpweaponsgang0"))
	mp.game.graphics.requestStreamedTextureDict("mpweaponsgang0", true);
while(!mp.game.graphics.hasStreamedTextureDictLoaded("mpweaponsgang0"))
	mp.game.wait(0);

//Create object for example
function CreateModel(model, pos, rot)
{
	if(!mp.game.streaming.hasModelLoaded(mp.game.joaat(model)))
		mp.game.streaming.requestModel(mp.game.joaat(model));
	while(!mp.game.streaming.hasModelLoaded(mp.game.joaat(model)))
		mp.game.wait(0);
	return mp.objects.new(mp.game.joaat(model), pos,
	{
		rotation: rot,
		alpha: 255,
		dimension: mp.players.local.dimension
	});
}

function CreateRenderTarget(name, model)
{
	if(!mp.game.ui.isNamedRendertargetRegistered(name))
		mp.game.ui.registerNamedRendertarget(name, false); //Register render target
	if(!mp.game.ui.isNamedRendertargetLinked(mp.game.joaat(model)))
		mp.game.ui.linkNamedRendertarget(mp.game.joaat(model)); //Link it to all models
	if(mp.game.ui.isNamedRendertargetRegistered(name))
		return mp.game.ui.getNamedRendertargetRenderId(name); //Get the handle
	return -1;
}

function RenderThings(id)
{
	mp.game.ui.setTextRenderId(id); //Set render ID of render target
	mp.game.graphics.set2dLayer(4); //Only layer 4 works
	
	mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 255, 0, 0, 255); //Draw rect is always behind text/sprites
	
	mp.game.graphics.drawText("~r~Rage~w~MP", [0.5, 0.35], //Draw text is always the most top element
	{ 
	  font: 0, 
	  color: [255, 255, 255, 255], 
	  scale: [2.0, 2.0], 
	  outline: true
	});
	
	//Scaleforms work too although the majority have messed up scaling
	mp.game.graphics.drawScaleformMovie(scale, 0.5, 0.5, 1, 1, 255, 255,255, 255, 0);
	
	//Draw sprites. The layering for this is last drawn is the most top element
	mp.game.graphics.drawSprite("mpweaponsgang0", "w_ar_advancedrifle", 0.25, 0.5, 0.25, 0.25, 0, 255, 255, 255, 255);
	mp.game.graphics.drawSprite("mpweaponsgang0", "w_ex_grenadefrag", 0.25, 0.5, 0.25, 0.25, 0, 255, 255, 255, 255);
	
	mp.game.ui.setTextRenderId(1); //Do not forget to reset the render ID. 1 is always the default render target the game uses
}

var TargetsToRender = [];
var scale = 0;

mp.keys.bind(69, false, () => //Button E
{
	var pos = mp.players.local.position;
	pos.z += 1;
	
	scale = mp.game.graphics.requestScaleformMovie("cellphone_ifruit");
	while(!mp.game.graphics.hasScaleformMovieLoaded(scale))
		mp.game.wait(0);
	
	var x = CreateModel("xm_prop_x17dlc_monitor_wall_01a", pos, new mp.Vector3());
	pos.x += 10;
	var x = CreateModel("xm_prop_x17dlc_monitor_wall_01a", pos, new mp.Vector3());
	var id = CreateRenderTarget("prop_x17dlc_monitor_wall_01a", "xm_prop_x17dlc_monitor_wall_01a");
	if(id != -1)
		TargetsToRender.push(id);
	else
		mp.gui.chat.push("Could not create render target.");
});

mp.events.add("render", () =>
{
	for(var i = 0; i < TargetsToRender.length; i++)
	{
		RenderThings(TargetsToRender[i]);
	}
});
Example of drawRect and drawText
Fullscreen drawRect and drawText
Reacts to object alpha properly
cinscreen example
drawSprite, drawRect, and drawText
drawSprite, drawRect, and drawScaleformMovie
Render Target Name Prop Name
tvscreen des_tvsmash_start
tvscreen des_tvsmash_root
tvscreen des_tvsmash_end
tvscreen prop_cs_tv_stand
tvscreen prop_flatscreen_overlay
tvscreen prop_laptop_lester2
tvscreen prop_monitor_02
tvscreen prop_trev_tv_01
tvscreen prop_tv_02
tvscreen prop_tv_03_overlay
tvscreen prop_tv_06
tvscreen prop_tv_flat_01
tvscreen prop_tv_flat_01_screen
tvscreen prop_tv_flat_02b
tvscreen prop_tv_flat_03
tvscreen prop_tv_flat_03b
tvscreen prop_tv_flat_michael
tvscreen prop_monitor_w_large
tvscreen prop_tv_03
tvscreen prop_tv_flat_02
tvscreen hei_prop_hst_laptop
tvscreen hei_bank_heist_laptop
tvscreen hei_heist_str_avunitl_03
tvscreen hei_heist_str_avunits_01
tvscreen hei_heist_str_avunitl_01
prop_x17dlc_monitor_wall_01a xm_prop_x17dlc_monitor_wall_01a
cinscreen prop_big_cin_screen
taxi prop_taxi_meter_1
taxi prop_taxi_meter_2
rev_phone prop_cs_trev_overlay
npcphone prop_phone_cs_frank
npcphone prop_phone_proto
big_disp prop_huge_display_01
big_disp prop_huge_display_02
planning prop_muster_wboard_01
planning prop_muster_wboard_02
planning hei_prop_hei_muster_01
prop_battle_touchscreen_rt ba_prop_battle_hacker_screen
prop_x17_p_01 xm_prop_x17_sec_panel_01
slow_text bkr_prop_slow_down
prop_clubhouse_laptop_01a bkr_prop_clubhouse_laptop_01a
prop_clubhouse_laptop_square_01a bkr_prop_clubhouse_laptop_01b
big_disp2 prop_projector_overlay
pbus_screen ba_prop_battle_pbus_screen
club_computer ba_prop_battle_club_computer_01
club_computer_02 ba_prop_battle_club_computer_02
laptop_dj ba_prop_club_laptop_dj
laptop_dj_02 ba_prop_club_laptop_dj_02
bikerlogo bkr_prop_biker_scriptrt_logo
bikertable bkr_prop_biker_scriptrt_table
bikerwall bkr_prop_biker_scriptrt_wall
clubname_blackboard_01a bkr_prop_clubhouse_blackboard_01a
memorial_wall_active_01 bkr_prop_rt_memorial_active_01
memorial_wall_active_02 bkr_prop_rt_memorial_active_02
memorial_wall_active_03 bkr_prop_rt_memorial_active_03
memorial_wall_president bkr_prop_rt_memorial_president
memorial_wall_vice_president bkr_prop_rt_memorial_vice_pres
clubhouse_plan_01a bkr_prop_rt_clubhouse_plan_01a
clubhouse_table bkr_prop_rt_clubhouse_table
clubhouse_wall bkr_prop_rt_clubhouse_wall
smug_monitor_01 xm_prop_x17_computer_01
smug_monitor_01 sm_prop_smug_monitor_01
tv_flat_01 xm_prop_x17_tv_flat_01
tv_flat_01 sm_prop_smug_tv_flat_01
monitor_02 prop_x17_computer_02
tvstand_screen xm_prop_x17_tv_stand_01a
prop_x17_8scrn_01 xm_prop_x17_screens_02a_01
prop_x17_8scrn_02 xm_prop_x17_screens_02a_02
prop_x17_8scrn_03 xm_prop_x17_screens_02a_03
prop_x17_8scrn_04 xm_prop_x17_screens_02a_04
prop_x17_8scrn_05 xm_prop_x17_screens_02a_05
prop_x17_8scrn_06 xm_prop_x17_screens_02a_06
prop_x17_8scrn_07 xm_prop_x17_screens_02a_07
prop_x17_8scrn_08 xm_prop_x17_screens_02a_08
prop_x17_tv_ceil_scn_01 xm_prop_x17_tv_ceiling_scn_01
prop_x17_tv_ceil_scn_02 xm_prop_x17_tv_ceiling_scn_02
prop_x17_tv_scrn_01 xm_prop_x17_tv_scrn_01
prop_x17_tv_scrn_02 xm_prop_x17_tv_scrn_02
prop_x17_tv_scrn_03 xm_prop_x17_tv_scrn_03
prop_x17_tv_scrn_04 xm_prop_x17_tv_scrn_04
prop_x17_tv_scrn_05 xm_prop_x17_tv_scrn_05
prop_x17_tv_scrn_06 xm_prop_x17_tv_scrn_06
prop_x17_tv_scrn_07 xm_prop_x17_tv_scrn_07
prop_x17_tv_scrn_08 xm_prop_x17_tv_scrn_08
prop_x17_tv_scrn_09 xm_prop_x17_tv_scrn_09
prop_x17_tv_scrn_10 xm_prop_x17_tv_scrn_10
prop_x17_tv_scrn_11 xm_prop_x17_tv_scrn_11
prop_x17_tv_scrn_12 xm_prop_x17_tv_scrn_12
prop_x17_tv_scrn_13 xm_prop_x17_tv_scrn_13
prop_x17_tv_scrn_14 xm_prop_x17_tv_scrn_14
prop_x17_tv_scrn_15 xm_prop_x17_tv_scrn_15
prop_x17_tv_scrn_16 xm_prop_x17_tv_scrn_16
prop_x17_tv_scrn_17 xm_prop_x17_tv_scrn_17
prop_x17_tv_scrn_18 xm_prop_x17_tv_scrn_18
prop_x17_tv_scrn_19 xm_prop_x17_tv_scrn_19
prop_x17_tv_ceiling_01 xm_screen_1
ex_tvscreen ex_prop_ex_tv_flat_01
prop_ex_computer_screen ex_prop_monitor_01_ex
prop_ex_office_text ex_prop_ex_office_text
gr_bunker_laptop_01a gr_prop_gr_laptop_01a
bunker_laptop_sq_01a gr_prop_gr_laptop_01b
gr_trailer_monitor_01 gr_prop_gr_trailer_monitor_01
gr_trailer_monitor_02 gr_prop_gr_trailer_monitor_02
gr_trailer_monitor_03 gr_prop_gr_trailer_monitor_03
gr_trailertv_01 gr_prop_gr_trailer_tv
gr_trailertv_02 gr_prop_gr_trailer_tv_02
heist_brd hei_prop_dlc_heist_board
tablet hei_prop_dlc_tablet
hei_mon hei_prop_hei_monitor_overlay
blimp_text sr_mp_spec_races_blimp_sign
id_text prop_police_id_text
id_text_02 prop_police_id_text_02
crew_emblem_base xm_prop_base_crew_emblem
orbital_table xm_prop_orbital_cannon_table
prop_impexp_lappy_01a imp_prop_impexp_lappy_01a
port_text apa_prop_ap_port_text
starb_text apa_prop_ap_starb_text
stern_text apa_prop_ap_stern_text
digiscanner weapon_digiscanner