2 registered members (AndrewAMD, Nymphodora),
1,592
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Weird effect with spline function
#449828
04/01/15 07:36
04/01/15 07:36
|
Joined: Apr 2005
Posts: 796 U.S.A. Michigan
exile
OP
User
|
OP
User
Joined: Apr 2005
Posts: 796
U.S.A. Michigan
|
Hey guys, I was working on changing the old "sword trail" code into something we could all use a bit easier, and for more than one intended purpose. I notice a really weird bug which makes the trail only viewable from selective angles. For example, if you were to move around the map while looking at the trail effect it will appear and disappear depending on how close/far you are from the center of the map. I am pretty sure its a pointer issue but I wanted someone to take a look to see if they have any solutions. Here is the code I am using, I am trying to keep the entire function as self contained as possible for future adaptation. action trail() { ENTITY* afterimage = me; set(afterimage,PASSABLE|BRIGHT|TRANSLUCENT); afterimage.alpha=100; ENTITY* cloner = ent_clone(afterimage); vec_sub(afterimage.x,cloner.x); while(afterimage.alpha>0) { afterimage.alpha-=time_frame*5; wait(1); } ent_remove(afterimage); }
void trail_ribbon(var vert1, var vert2, ENTITY* ent) { ent = me; VECTOR trailpos1; VECTOR trailpos2; VECTOR trailpos3; VECTOR trailpos4; VECTOR oldpos; ENTITY* trail1; var sspeed = 0; while(ent.active) { sspeed++; if(sspeed%2==0) { trail1 = ent_create("trail1mdl.mdl",ent.x,trail); vec_for_vertex(trailpos2,ent,vert1); vec_for_vertex(trailpos1,ent,vert2); vec_to_mesh(trailpos1,trail1,1); vec_to_mesh(trailpos2,trail1,2); vec_to_mesh(trailpos3,trail1,3); vec_to_mesh(trailpos4,trail1,4); vec_set(trailpos3,trailpos1); vec_set(trailpos4,trailpos2); vec_set(oldpos.x,ent.x); wait(1); trail1=NULL; } } }
If anyone has any ideas let me know. If you want to know how I am implementing it, I am using multiple test environments with one being the most recent multiplayer tutorial from the AUM (for replication purposes).
|
|
|
Re: Weird effect with spline function
[Re: exile]
#449941
04/03/15 13:40
04/03/15 13:40
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
Serious User
|
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
it will appear and disappear depending on how close/far you are from the center of the map. That sounds like a clip_far issue. Try increasing Clip far to a larger number.
Last edited by DLively; 04/03/15 15:26.
|
|
|
Re: Weird effect with spline function
[Re: DLively]
#449950
04/03/15 18:41
04/03/15 18:41
|
Malice
Unregistered
|
Malice
Unregistered
|
@exile please package the models for testing and I have some errors trying to run the test script. "ent.active" unknown. There seems to be some code parts missing.
You provide a trail, and ribbon function, however a basic entity action and models to call all this would allow 'OTHERS" to run it.
I am using 3dgs free, however I wonder if this is better achieved with model particles and beam+streak effects. After all the old-old sword trail was written for the A5.
|
|
|
Re: Weird effect with spline function
[Re: ]
#449952
04/03/15 19:53
04/03/15 19:53
|
Joined: Apr 2005
Posts: 796 U.S.A. Michigan
exile
OP
User
|
OP
User
Joined: Apr 2005
Posts: 796
U.S.A. Michigan
|
Malice, Hey thanks for the reply! You can actually just replace that with a while(my) if you want, its essentially doing the same thing. Here is a portable version of the code. void trail() { set(my,PASSABLE|BRIGHT|TRANSLUCENT); my.alpha=100; ent_clone(me); vec_sub(my.x,you.x); while(my.alpha>0) { my.alpha-=time_frame*0.25; wait(1); } ent_remove(me); }
void trail_ribbon(var vert1, var vert2, ENTITY* ent) { ent = me; VECTOR trailpos1; VECTOR trailpos2; VECTOR trailpos3; VECTOR trailpos4; ENTITY* trail1; var sspeed = 0; while(ent) { sspeed++; if(sspeed%2==0) { trail1 = ent_create("trail1mdl.mdl",ent.x,trail); vec_for_vertex(trailpos2,ent,vert1); vec_for_vertex(trailpos1,ent,vert2); vec_to_mesh(trailpos1,trail1,1); vec_to_mesh(trailpos2,trail1,2); vec_to_mesh(trailpos3,trail1,3); vec_to_mesh(trailpos4,trail1,4); vec_set(trailpos3,trailpos1); vec_set(trailpos4,trailpos2); wait(1); trail1=NULL; } } }
I am currently modifying the multiplayer code written by George and Superku to make it a bit more "visually appealing" for a bit of practive. I uploaded the stuff to my dropbox in case you want to download it. https://www.dropbox.com/s/8ugywqd51sq89yt/mp_template_v0.1.zip?dl=0The problem with using beam/streak effects is that, quite frankly, they look disgusting. As far as I am aware there isn't a way to get a "unified" or spline-like result which makes the trail look like its one singular "unit". Using particles, you will run into an issue where the trailing effect will look choppy based on the speed of the emitting entity. Which, as said earlier, looks gross lol. Here is a video showing the effect I am trying to achieve, minus the actual movement of the "smoke" or trail. https://www.youtube.com/watch?v=vKAvvauNQ8M
|
|
|
Re: Weird effect with spline function
[Re: alibaba]
#449957
04/03/15 22:45
04/03/15 22:45
|
Malice
Unregistered
|
Malice
Unregistered
|
@exile I can't test with the free version. However Alibaba seems on the case, so best luck.
|
|
|
|