Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
6 registered members (TipmyPip, Niels, dBc, Ed_Love, 3run, 1 invisible), 18,855 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Problem with my beam effect #442694
06/30/14 01:34
06/30/14 01:34
Joined: May 2014
Posts: 179
The lit part of the Truth
C
CyberGhost Offline OP
Member
CyberGhost  Offline OP
Member
C

Joined: May 2014
Posts: 179
The lit part of the Truth
I am testing a particle beam effect for a rocket trail (u may already know from my previous thread). I set vel_x/y/z to a vector handling the difference between rocket's position before and after its c_move() call (which normally controls its behaviour through arrow keys). Then, I checked if any of vel_x/y/z doesn't equal zero (which means that the rocket is moving) ,and if so, I randomize the vel_x/y/z vector by vec_randomize().


I use this image as a bmap for the effect:


Download link: http://www.datafilehost.com/d/48c7bd08



The problem is that: the particle doesn't look any good. It looks like cut strips or thin arcs (which is weird for a rocket trail). When I comment out vec_randomize() instruction, it doesn't look good either. It looks like the previous case. It takes the form of cut strips moving behind the rocket. Here are some screenshots:


1) If vec_randomize() is executed:





2) If vec_randomize() is commented out:




So, what am I doing wrong? Here's my code (Note that I don't use BRIGHT flag):

Code:
BMAP* smoke = "smoke.tga";
VECTOR dist_covered;
ENTITY* vehicle;

function p_fade_beamy(PARTICLE* p)
{
	p.alpha -= 3*time_step;
	if(p.alpha <= 0) p.lifespan = 0;
}

function p_beamy(PARTICLE* p)
{
	VECTOR speed;
	
	vec_set(p.vel_x,dist_covered.x);
	if(p.vel_x != 0 || p.vel_y != 0 || p.vel_z != 0) vec_randomize(p.vel_x,1);
	
	p.alpha = 100;
	p.bmap = smoke;
	p.size = 8;
	
	set(p, MOVE | TRANSLUCENT | BEAM );
	p.event = p_fade_beamy;
}


action movable_vehicle()
{
	VECTOR temp;
	VECTOR vtemp1;
	VECTOR vtemp2;
	
	
	vehicle = my;
	
	
	while(1)
	{
		
		vec_set(vtemp1.x,my.x);
		c_move(my,vector((key_cuu-key_cud)*5*time_step,0,0),nullvector,GLIDE | IGNORE_PASSABLE);
		my.pan -= (key_cur-key_cul)*5*time_step;
		vec_set(vtemp2.x,my.x);
		
		vec_diff(dist_covered,vtemp1.x,vtemp2.x);
		
		
		vec_set(temp.x,vector(-37,0,0));
	   vec_rotate(temp.x,my.pan);
	   vec_add(temp.x,my.x);
	
	   effect(p_beamy,40,temp.x,nullvector);
		
		wait(1);
		
	}
}




You can download a testing sample here (open through "main.c"): http://www.datafilehost.com/d/38f7e3bd


Also, I wanted to ask: Does the particle function preserve my/you pointers from the calling
function? I know in C-script the my pointer is used to point to the particle ,but what about Lite-C?


Thank you for reading & any help would be appreciated laugh ....


Nothing to say ....
Re: Problem with my beam effect [Re: CyberGhost] #442703
06/30/14 13:13
06/30/14 13:13
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The problem obviously is that BEAM is not suited for smoke effects. Just created regular particles (and if the distance per frame between entity.old_x and entity.x is too big, create more particles inbetween).

Regarding the pointers: Probably not, but you can test it. Note though that I was helped finding a near untraceable acknex crash, the reason was a my-pointer in some particle function.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Problem with my beam effect [Re: Superku] #442762
07/02/14 02:05
07/02/14 02:05
Joined: May 2014
Posts: 179
The lit part of the Truth
C
CyberGhost Offline OP
Member
CyberGhost  Offline OP
Member
C

Joined: May 2014
Posts: 179
The lit part of the Truth
I think I enhanced it a little:




Can it be the bmap? Or colors? confused


Nothing to say ....
Re: Problem with my beam effect [Re: CyberGhost] #442778
07/02/14 16:48
07/02/14 16:48
Joined: May 2014
Posts: 179
The lit part of the Truth
C
CyberGhost Offline OP
Member
CyberGhost  Offline OP
Member
C

Joined: May 2014
Posts: 179
The lit part of the Truth
... or maybe I will try more than one effect ...


Nothing to say ....
Re: Problem with my beam effect [Re: CyberGhost] #442793
07/03/14 06:28
07/03/14 06:28
Joined: May 2009
Posts: 5,377
Caucasus
3run Online
Senior Expert
3run  Online
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
You probably just needed to play more with some values laugh
Here, grab this demo:
Smoke Trail
Here is the code itself:
Code:
// include lib:
#include <acknex.h>
#include <default.c>

// game paths:
#define PRAGMA_PATH "data"

// define test level's name:
STRING* levelStr = "";

// particle bmap:
BMAP* smoke_tga = "smoke.tga";

// helper function:
function vec_randomize(VECTOR* vec, var range){
	vec_set(vec, vector(random(1) - 0.5, random(1) - 0.5, random(1) - 0.5));
	vec_normalize(vec, random(range));
}

// fade particles:
function fadeSmoke(PARTICLE* p){
	// decrease alpha:
	p.alpha -= (2 + random(2)) * time_step;
	// increase size:
	p.size += (1 + random(2)) * time_step;
	// if alpha is low enough, kill particle:
	if(p.alpha < 0){ p.lifespan = 0; }
}

// simple smoke particle effect:
function smokeEffect(PARTICLE* p){
	// vector for particle's movement:
	VECTOR vTemp;
	// randomize movement of smoke:
	vec_randomize(vTemp, 1);
	// add calculated movement to particle itself:
	vec_add(p.vel_x, vTemp);
	// define random size for smoke:
	p.size = 1 + random(2); 
	// define random alpha for smoke:
	p.alpha = 65 + random(10);
	// define smoke bmap:
	p.bmap = smoke_tga;
	// define gravity for smoke:
	p.gravity = 0.5; // play with this, or even remove
	// setup some flags:
	set(p, MOVE | BRIGHT | TRANSLUCENT);
	// define fading event for smoke:
	p.event = fadeSmoke;
}
// simple rocket going in circles:
action actRocket(){
	// flags:
	set(my, PASSABLE | BRIGHT | UNLIT);
	// run this loop until we exist:
	while(my){
		// calulate new position each frame:
		my.x = my.skill1 + fsin(total_ticks * 10, 200);
		my.y = my.skill2 + fcos(total_ticks * 10, 200);
		// spawn one smoke particle each frame from my position:
		effect(smokeEffect, 1, my.x, nullvector);
		// wait one frame:
		wait(1);
	}
}

// fog, sky color setup:
void fogSkySetup(){
	// set camera positions/angles:
	vec_set(camera.x, vector(-40, -444, 370));
	vec_set(camera.pan, vector(85, -42, 0));
	// lods:
	vec_set(d3d_lodfactor, vector(12.5, 25, 50)); 
	// sunlight:
	sun_light = 100;
	// camera clipping parameters:
	camera.clip_near = 1;
	camera.clip_far = 3000;
	// fog parameters:
	camera.fog_start = 250; 
	camera.fog_end = 2500; 
	// fog and sky colors:
	fog_color = 4;
	// change fog color:
	vec_set(d3d_fogcolor4.blue, vector(120, 120, 120));
	// change sky color:
	vec_set(sky_color.blue, d3d_fogcolor4.blue);
}

// main game function:
void main(){
	// disable v-sync:
	d3d_triplebuffer = 1;
	// turn doppler effect OFF:
	doppler_factor = 0;	
	// preload in buffer all created models:
	preload_mode = 3;
	// show all errors:
	warn_level = 6;
	// set maximal framerate:
	fps_max = 60;
	// smooth time step:
	time_smooth = 0.5;
	// window title:
	video_window(NULL, NULL, NULL, "Test");	
	// video modes:
	video_set(800, 600, 16, 2);
	video_set(0, 0, 16, 2);
	// no wide-screen:
	video_aspect = 1.333;
	// freeze the game:
	freeze_mode = 1;
	// load the level:
	level_load(levelStr);
	// wait three frames:
	wait(1);
	// unfreeze the game:
	freeze_mode = 0;
	// adjust weather:
	fogSkySetup();
	// seed the random sequence:
	random_seed(0);
	// create a model:
	ENTITY* testEnt = ent_create("bbox.mdl", nullvector, actRocket);
}

And a screen, to show you how does it looks like:



Greets!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Problem with my beam effect [Re: 3run] #442858
07/05/14 01:30
07/05/14 01:30
Joined: May 2014
Posts: 179
The lit part of the Truth
C
CyberGhost Offline OP
Member
CyberGhost  Offline OP
Member
C

Joined: May 2014
Posts: 179
The lit part of the Truth
It seems that your link doesn't work for me frown ..


Nothing to say ....

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1