Visualize the worlds axis!

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Visualize the worlds axis!

Post by Bjarne BZR »

After trying to place a spawned model correctly over a clip I had to hide in an SP map I'm making into OBJ, I got this elegant idea:

Image

...I used spawned func_beams to visualize the X Y and Z axis in the world, and suddenly it took no tima at all to place the model, because by looking at the 3 lines I can pretty quickly say if it should be moved about -50 in X, and +30 in Y :)

Not really any rocket science, but very useful if you like scripting stuff into a map.

The code:

Code: Select all

debug_draw_axis local.origin:
	
	local.beam_end = ( local.origin + ( 100 0 0 ) )
	local.beam = spawn func_beam origin local.origin endpoint local.beam_end maxoffset 0
	local.beam doActivate
	local.beam color (1 0 0)
	
	local.beam_end = ( local.origin + ( 0 100 0 ) )
	local.beam = spawn func_beam origin local.origin endpoint local.beam_end maxoffset 0
	local.beam doActivate
	local.beam color (0 1 0)
	
	local.beam_end = ( local.origin + ( 0 0 100 ) )
	local.beam = spawn func_beam origin local.origin endpoint local.beam_end maxoffset 0
	local.beam doActivate
	local.beam color (0 0 1)
end
And how to draw it:

Code: Select all

thread debug_draw_axis ( 0 0 0 )
No need to place it in ( 0 0 0 ), in the image above I used:

Code: Select all

thread debug_draw_axis ( -2801.40 -3280.21 259.46 )
Admin .MAP Forums
Image
Head above heels.
Elgan
Lieutenant General
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

im pretty sure their is a cvar for this sowwy. ive seen cvars that spawn random lines and arrows but they always crash mohaa when u reoad so script can be better. nice lil thing though. nice work:P cudnt u put lil x,y's and z's on em:D for show:P
User avatar
Pollo_Expresss
Sergeant
Posts: 60
Joined: Thu Jan 08, 2004 12:18 am
Location: Spain

Great

Post by Pollo_Expresss »

Hey, that?s great.

Recently i?ve been spawning models in stock maps and now I?ll be faster when doing the job, hehe.

Great idea Bjarne, thanks for sharing it.

Well, now I have a question that have to do with that.

You called the thread giving it an argument. Can I do the same but giving a thread three arguments?

I mean if I want to spawn three models of the same .tik file, will this work?

Code: Select all

spawn_bikes local.originx local.originy local.orignz:

    local.bike = spawn models/vehicles/bmw.tik
    local.bike.origin = ( local.originx local.originy local.originz )
    blah blah blah and scale, hide or solid stuff
And then call it like that:

Code: Select all

thread spawn_bikes 1200 -300 35
Well, just now I?ve noticed that I should try it and then ask it, but hehe, if someone had tried it before he could tell us.

Thanks again Bjarne.
*(ICE)*-Sd_Pollo_Expresss
http://www.iceclanweb.net

Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Sure you can have 3 parameters to a function, but in this particular case it is not nessesary. You can just send the locatin as a vector like I did:

Code: Select all

spawn_bike local.origin:
    local.bike = spawn models/vehicles/bmw.tik
    local.bike.origin = local.origin
    // blah blah blah and scale, hide or solid stuff
end
... but there is no problem doing it like you sugggested either:

Code: Select all

spawn_bike local.X local.Y local.Z:
    local.bike = spawn models/vehicles/bmw.tik
    local.bike.origin = ( local.X local.Y local.Z )
    // blah blah blah and scale, hide or solid stuff
end
Calling difference is small, but I think mine:

Code: Select all

thread spawn_bikes ( 1200 -300 35 )
...is more obvious as to what the parameter is ( a vector ) than your version:

Code: Select all

thread spawn_bikes 1200 -300 35
But they both do the exact same thing.
Admin .MAP Forums
Image
Head above heels.
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Elgan wrote:cudnt u put lil x,y's and z's on em:D for show:P
Yes I could, and arrows at the end of the lines, and a sparkling blue star at the worlds origin :)

But I made it to save time, not to waste it by winning an art award... ;)
Admin .MAP Forums
Image
Head above heels.
Elgan
Lieutenant General
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

:) lol
User avatar
Pollo_Expresss
Sergeant
Posts: 60
Joined: Thu Jan 08, 2004 12:18 am
Location: Spain

Color of script objects?

Post by Pollo_Expresss »

Sorry about refreshing this post, but I have a question that have to do with this, hehe.

Is there anyway for giving a script_object a color like in Bjarne?s code he did with func_beam?

I tryed something like that:

Code: Select all

local.mywall = spawn script_object
local.mywall = blah, blah, origin and setsize stuff
local.mywall color (1 0 0)
And like that:

Code: Select all

local.mywall = spawn script_object
local.mywall = blah, blah, origin and setsize stuff
local.mywall.color = (1 0 0)
And it doesn?t seem to work, I guess it?s possible that what I ask can?t be done, but if someone knows the answer it?ll be apreciated.

Thanks.
*(ICE)*-Sd_Pollo_Expresss
http://www.iceclanweb.net

Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

I dont think there is anything in a script_object that you can give a color... The beam has shaders attached to it and can be colored or textured.

Not saying it is impossible, just that I don't know how to do it.
Admin .MAP Forums
Image
Head above heels.
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Re: Color of script objects?

Post by Grassy »

Pollo_Expresss wrote:Sorry about refreshing this post, but I have a question that have to do with this, hehe.
Is there anyway for giving a script_object a color like in Bjarne?s code he did with func_beam?
Dont think so, but you could apply a light to it.

local.ent light 0 0 1 50 // = blue
local.ent lighton
An ambiguous question will get a similar answer...
Post Reply