View topic - CEG Muzzle flare... how the hell do you add one.



All times are UTC + 1 hour


Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 06 Jul 2011, 14:13 
Map Creator
User avatar

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
OK, can someone link me to how you use CEG's? More specificaly, for a muzzle flare? In Lua? Maybe I just sux, but I can't seem to piece together the workings from what I can find here.

aGorm


Top
 Offline Profile  
 
PostPosted: 06 Jul 2011, 14:27 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
Location: ModalitÃ
In the lua scripts forum I posted a directly converted unit for code review. That unit (iirc) the rgm has a muzzle flare emit in the fire weapon 1 block of code.


Top
 Offline Profile  
 
PostPosted: 06 Jul 2011, 14:28 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Do you intend for each weapon to always have the same muzzleFX? If so, I can make your life much easier.


Top
 Offline Profile  
 
PostPosted: 06 Jul 2011, 15:12 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
to teh nubmod!!

I added a muzzle flash effect to the attackvehiclemultimissile unit.
(only in SVN version so far)

click "diff" in this commit:
http://code.google.com/p/springtutorialgame/source/detail?r=64
to see what got changed in both unitDef & script to add the CEG.
If you ignore the comments, it just needs 2 lines in the script.


Top
 Online Profile  
 
PostPosted: 06 Jul 2011, 17:23 
Map Creator
User avatar

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
Thanks guys... knorke you are legend.

FLOZi, nope this is a one of flare. Why what were you going to suggest? (As I may still need a default one for some guns I expect...)


Top
 Offline Profile  
 
PostPosted: 06 Jul 2011, 18:04 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Well in the battletech mod, we associate a particular flare with a particular weapondef.

Then we automagically add them to all unitdefs using that weapondef such that in the script you can just do:

Code:
EmitSFX(thePiece, SFX.CEG + weaponID)


Top
 Offline Profile  
 
PostPosted: 07 Jul 2011, 14:20 
Map Creator
User avatar

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
Attachment:
error.jpg [133.58 KiB]
Downloaded 2 times


Hmmm... one problem, the "dir" the effect gets fed seems to be off to one side. How do you change that?

aGorm


Top
 Offline Profile  
 
PostPosted: 08 Jul 2011, 12:45 
Map Creator
User avatar

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
I guess the silence means no one knows an answer... :-(


Top
 Offline Profile  
 
PostPosted: 08 Jul 2011, 13:36 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Try rotating the emitting piece to the direction of the weapon


Top
 Offline Profile  
 
PostPosted: 08 Jul 2011, 16:16 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
I had this too sometimes, no idea why it happens.
Had it happen too if the emit point was an empty piece at the end of a barrel and rotating the empty piece did nothing. I have no idea what is going on but it it involves randomly rotating the emit pieces in both script and upspring, deleting it and adding it again and eventually it will work. :?


Top
 Online Profile  
 
PostPosted: 08 Jul 2011, 17:41 
Map Creator
User avatar

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
I noticed rotating the emit peice gave no joy... :-( hence the post. I shall try re-adding/rotating the point in upspring to see what happens.

aGorm


Top
 Offline Profile  
 
PostPosted: 08 Jul 2011, 17:51 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
if you get it almost correct by having a muzzle flash that goes 180┬░ in the wrong direction, you can also edit the effect:
length = -35,
or
size = -2
to flip it around.


Top
 Online Profile  
 
PostPosted: 08 Jul 2011, 18:40 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Never am sure on this but some fx (used to?) use direction between vertex 1 and vertex 2 of the emitting piece rather than it's script rotation


Top
 Offline Profile  
 
PostPosted: 08 Jul 2011, 18:46 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
yes, might be something like this:
Spring.GetUnitPiecePosDir:

Returns piece position and direction in world space.[...]The position is defined as the position of the first vertex of the piece and it defines direction as the direction in which the line from the first vertex to the second vertex points.


how that matters for empty pieces, I dont know but seems it somehow does.


Top
 Online Profile  
 
PostPosted: 08 Jul 2011, 19:21 
Spring Developer

Joined: 01 Jun 2005, 10:36
Location: The Netherlands
I think it uses an internal function LocalModelPiece::GetEmitDirPos, which uses a vector in the +z direction in piece space if the piece has no vertices, or the vector from (0, 0, 0) to the vertex if the piece has one vertex, or the vector from vertex 1 to vertex 2 if the piece has two vertices.

In other words, a piece with zero vertices should give the same result as a piece with one vertex (0, 0, z) with z > 0, and as a piece with two vertices (0, 0, 0) and (0, 0, z) with z > 0.

(Or in the last case: two vertices (x, y, z) and (x, y, z2) with z2 > z for the same emit direction, but an emit position of (x, y, z) instead of (0, 0, 0).)


Top
 Offline Profile  
 
PostPosted: 20 Jul 2011, 14:15 
Map Creator
User avatar

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
After a lot of faf I got it to point in the right direction... (put the flare inside another empty object and rotated that parent... only way it seemed to work!)

Now I'm wondering... anyone have an example of how you use "CExpGenSpawner" to que up several effects
Quote:
# You can animate an explosion flip-book style using delays and several bitmaps.


I think I'm using them wrong... each of the two parts work fin if called, but I don't see how the CExpGenSpawner bit works so thatwas my best guess (IE, they will all be called as they have the same name, and the delays wil cause the other effects to start at stagurd times...)

http://pastebin.com/MyjETL2w

aGorm


Top
 Offline Profile  
 
PostPosted: 21 Jul 2011, 14:10 
Map Creator
User avatar

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
http://pastebin.com/nPEN65kh

OK, having looked through more examples (namely:
http://code.google.com/p/zero-k/source/browse/trunk/mods/zk/effects/barney.lua
http://code.google.com/p/zero-k/source/browse/trunk/mods/zk/effects/annabelle.lua) I thought maybe I was on teh right track, but I still can't get anything to happen the second I try calling one CEG from a CExpGenSpawner... Anyone able to take a look? Please?

aGorm


Top
 Offline Profile  
 
PostPosted: 21 Jul 2011, 14:42 
Map Creator
User avatar

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
Thats one of the threads I was looking at yes... (I do use the forum search you know... :P ). I can't spot what I've done differently from anyone elses...

aGorm


Top
 Offline Profile  
 
PostPosted: 21 Jul 2011, 15:01 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Nor can I. Sorry, CEG is one area I am really clueless about. :(


Top
 Offline Profile  
 
PostPosted: 22 Jul 2011, 16:06 
Map Creator
User avatar

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
http://pastebin.com/rQDqyDtB

Succses! Not the final effect, but I atleast got it to work as expected! Have to remember that when using CExpGenSpawner you have to pass on things like "dir" into the ceg your calling... or it wont work and will bug you for days...

aGorm


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Bing [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.