|
|
bitmap between two vectors
#305849
01/17/10 20:23
01/17/10 20:23
|
Joined: May 2008
Posts: 2,113 NRW/Germany
alibaba
OP
Expert
|
OP
Expert
Joined: May 2008
Posts: 2,113
NRW/Germany
|
hi there, one more qquestion.  can someone give me a script example, where i can place a bitmap between two objects, i mean : if i click with the mouse on a place, and then click to an other place, then the bitmpa should be created between this two vectors. i hope you understand what i mean german: hallo, gibt es einen weg, das eine bitmap dort platziert wird, wo ich hinclicke? also ich meine das so: ich klicke wo hin dann klicke icxh wo anders hin, dann wird die bitmap von der start position zur endposition hin positioniert. ich hoffe, ihr versteht was ich meine.
|
|
|
Re: bitmap between two vectors
[Re: alibaba]
#305851
01/17/10 20:38
01/17/10 20:38
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
would that be an 2d bitmap(panel) or an 3d sprite? also, do you want to be that bitmap in the middle of these vectors or stretched between them?
3333333333
|
|
|
Re: bitmap between two vectors
[Re: alibaba]
#305857
01/17/10 21:07
01/17/10 21:07
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
Use vec_lerp to set it in the middle between both positions, vec_dist goves you the distance between the two positions to scale the bitmap according, the example from the manual function look_at_me() { vec_to_angle(camera.pan,vec_diff(NULL,my.x,camera.x)); } shows you the way how to turn the bitmap, but you have to multiply the angle, if you use a simple bitmap. Maybe, vec_scale(bitmap.pan, 90); is sufficiant, I didn'z test it. You can make a model with the bitmap as plane in the middle of it. These are just some hints, I still leave you the rest to code! 
|
|
|
Re: bitmap between two vectors
[Re: alibaba]
#305959
01/18/10 17:34
01/18/10 17:34
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
i thought what pappenheimer posted was sufficent but if you still can't do it ill post a code
(edit: im not gonna code clikcing, just stretching a bmap between 2 vectors.)
Last edited by Quadraxas; 01/18/10 17:34.
3333333333
|
|
|
Re: bitmap between two vectors
[Re: alibaba]
#305967
01/18/10 18:23
01/18/10 18:23
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
#include <acknex.h>
#include <default.c>
void stretch_sprite(ENTITY* sprite,VECTOR* vec1,VECTOR* vec2){
VECTOR temp;
//calculating the scale factor, its distance_between_vectors/sprite_length;
//f.e. if sprite is 10 quants and the distance is 100 quants scale factor is 10, so when i scale sprite 10 times i get the desired length
var scale_factor = vec_dist(vec1,vec2)/sprite.skill1;
sprite.scale_x = scale_factor;
//finding the angles between vectors
vec_set(temp,vec1);
vec_sub(temp,vec2);
vec_to_angle(sprite.pan,temp);
//apperantly, sprites stand prep. to x so add 90 to pan.
//do not directly add 90 to pan or you'll screw up the other amgles
ang_rotate(sprite.pan,vector(90,0,0));
//center of the sprite is on the middle, so ew have to move our new long sprite to middle of the vectors
vec_lerp(temp,vec1,vec2,0.5);//temp now stores the middle of the vectors
vec_set(sprite.x,temp);
}
void sprite_act(){
//i only need to calculate these once, so insted of doing it in stretch_sprite function i do it here
my.skill1 = my.max_x-my.min_x;//this stores the sprites original length
}
void sphere_act(){
ENTITY* ent_sprite = ent_create("sprite.tga",nullvector,sprite_act);
while(!ent_sprite) wait(1);
my.skill1 = 0;
my.skill2 = 1;
while(1){
//sphere movement
my.pan += 10*time_step;
my.skill1 += my.skill2*time_step;
my.x -= my.skill1*cos(my.pan)*time_step;
my.y += my.skill1*sin(my.pan)*time_step;
my.z = 100*sin(my.pan);
if(my.skill1>=10) my.skill2 = -1;
else if(my.skill1<=-10) my.skill2 = 1;
stretch_sprite(ent_sprite,my.x,nullvector);
wait(1);
}
}
void main(){
wait(1);
level_load("");
ent_create("sphere.mdl",nullvector,sphere_act);
}
make a sprite.tga and run (i made a 16x16 blue image) what you need is "stretch_sprite" function, dont mind the other parts, they are just some dirty code for demonstration purposes.
3333333333
|
|
|
|