0 registered members (),
16,232
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
c_trace
#128565
05/08/07 06:26
05/08/07 06:26
|
Joined: Jan 2003
Posts: 798 New Zealand
Bright
OP
User
|
OP
User
Joined: Jan 2003
Posts: 798
New Zealand
|
Hey guys, I was wondering what the best method is for making a floating object (a really high one) scan for the ground below it and return the exact number (on a z axis) of where the ground is. I am thinking of making an RTS and having a really high pointer that will move around with the mouse. I want this pointer to scan for the ground and place an object there (building, tree, etc). Hope to hear from someone soon. -Bright
KAIN - Coming soon...
|
|
|
Re: c_trace
[Re: Bright]
#128566
05/08/07 07:01
05/08/07 07:01
|
Joined: Apr 2005
Posts: 3,076 Germany, NRW
rvL_eXile

3D Artist
|

3D Artist
Joined: Apr 2005
Posts: 3,076
Germany, NRW
|
Hey Bright, Kannst dir den Code mal anschauen, den habe ich gemacht, läuft soweit, sry habe gerade nicht wirklich Zeit sonst haette ich dir das wichtigste raus genommen! Code:
string Gebaeude = geb1.mdl;
bmap Gebaeude_Selected_bmap = <Metallmine_sel.bmp>; bmap explode_bmap = <explode.bmp>; bmap Slider_bmap = <Slider.bmp>; bmap Slider_HG_bmap = <Slider_HG.bmp>;
font arial_font = "cour",0,16;
Panel Gebaeude_Selected_pan { bmap = Gebaeude_Selected_bmap; pos_x = 600; pos_y = 200; Layer=5; flags =refresh,overlay; button=100,60,explode_bmap,explode_bmap,explode_bmap,explode,null,null;
}
Panel Slider { bmap Slider_HG_bmap; pos_x=600; pos_y=200; VSLIDER = 6,10,230,slider_bmap,0,10,ressis_prozent; Digits = 100,100,3,arial_font,1,ressis_prozent; Layer=6; flags =refresh; }
string Mspawn_str = "Geeignetes Gebiet um die Metallmine zu platzieren";
var mouse_range = 1000000;
font arial_font3 = "cour",0,14;
text Metallmine_Spawn // Textobjekt definieren { font = arial_font3; Red = 255; Green= 255; Blue= 255; layer = 2; pos_x = 385; pos_y = 612; layer=2; strings = 5; // reserviere 5 string pointer... string = Mspawn_str; // ...denen existierende Strings zugewiesen werden. flags = narrow; }
function highlight_sprite() {
if (event_type == event_touch) { //my.ambient += 100; // highlight the unit Metallmine_Spawn.visible=on; } if(event_type == event_release) { Metallmine_Spawn.visible=off; my.ambient = 0; }
}
entity* terrain_ent;
action spawn_sprite_action { my.enable_touch = on; my.enable_release = on;
my.event = highlight_sprite; my.polygon = on; terrain_ent = my; my.passable = off; my.transparent=on; my.alpha=20; my.flare=on; my.bright=off; my.ambient=0; my.light=on; my.red=236; my.green=118; my.blue=0; wait(1);
}
Function Gebaeude_Clicked { if (EVENT_TYPE == EVENT_click) { //If (my.selected_Geb==1) //{ my.ambient=40; my.unlit=on; Gebaeude_Selected_pan.visible=on; Slider.visible=on; selected_ent = my;
//} } }
Action Gebaeude_Function { my.ENABLE_click = ON; // mache Entity sensitiv für Klicks my.event = Gebaeude_Clicked; while(1) { if(mouse_left == on && mouse_ent != my && key_ctrl != on) //wenn geklickt wurde, aber die maus nicht auf mir ist, geh aus selektier modus raus. { Health_pan.visible = off; // andernfalls schalte es ab Kreuzer_unit.visible=off; my.ambient = 0; Gebaeude_Selected_pan.visible=off; Slider.visible=off; my.selected = 0; } wait(1); } vec_set(temp,my.x); if (vec_to_screen(temp,camera)) // falls auf dem Bildschirm sichtbar { Health_pan.pos_x = temp.x; // plaziere die Healthbar Health_pan.pos_y = temp.y; } wait(1); }
} }
Var Spawned; //Variable, damit nur einmal die Metallmine platziert werden kann
Function Spawn_Gebaeude() { var trace_start[3]; var trace_end[3]; trace_start.x=mouse_pos.x; trace_start.y=mouse_pos.y; trace_start.z=1; vec_for_screen(trace_start,camera); trace_end.x=mouse_pos.x; trace_end.y=mouse_pos.y; trace_end.z = 100000; vec_for_screen(trace_end,camera); c_trace(camera.x,trace_end,null); if(you) //wenn ich eine entity getroffen habe wird "you" gesetzt. { if(you.selected == off) { if(you == terrain_ent && Metallmine==1 && Spawned==0) { vec_for_vertex(temp,terrain_ent,hitvertex); you=ent_create(Gebaeude,target,Gebaeude_Function); you.unlit=on; spawned+=1; } }
else { wait(1); } } }
ON_MOUSE_LEFT = Spawn_Gebaeude;
cYa Sebastian
Tutorials: [Blender]Terrain creation ENG/GER [Blender]Low Poly Tree Modeling [GIMP]Create a Texture for Terrains CLICK HERE
|
|
|
Re: c_trace
[Re: tompo]
#128568
05/08/07 10:21
05/08/07 10:21
|
Joined: Apr 2002
Posts: 4,801 Richmond B.C., Canada
Captain_Kiyaku

Dichotomic
|

Dichotomic
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
|
Code:
action actFloating { var vPos; my.z = 1000; while(!mouse_left) { /* add your "follow the mouse" function here */ c_trace(my.x, vector(my.x, my.x, my.z - 2000), ignore_me | ignore_passable); vec_set(vPos, target); /* not sure about this. i think "target" does only exist in it's current frame, so i just save it in a temp vector */ wait(1); } vec_set(my.x, vPos.x); /* set my position to the hitted spot */ return; }
just some fast code oO if i missed what you need, just tell me
My Blog"Tag und Nacht schrei ich mich heiser, Wind weht alle Worte fort, Tag und Nacht schrei ich mein Krähenwort!"Subway To Sally - Krähenkönig
|
|
|
|