Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Akow, 1 invisible), 1,404 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Click to deform terrain code not working #180012
01/26/08 06:56
01/26/08 06:56
Joined: Oct 2003
Posts: 2,194
Saturn
Metal_Thrasher Offline OP
Expert
Metal_Thrasher  Offline OP
Expert

Joined: Oct 2003
Posts: 2,194
Saturn
I altered the code from AUM so that when I click it shoots trace and then deforms the terrain at the target...but it dosent do so. It beeps, so i know it got to the end of the code...but nothing is happening.
Here is my code.
Code:
 function create_crate();
function deform(vertex_number);

entity* terrain1;

var vertex_dist[1090];
var hit_coords;


action terrain
{
terrain1 = my; // used by vec_for_mesh and vec_to_mesh
my.ENABLE_SHOOT = ON; // triggers events if it is clicked
my.event = create_crate;
while(1)
{
if (mouse_left == 1)
{

vec_set(temp, mouse_pos);
temp.z -= 500; // trace downwards 500 quants below
c_trace (mouse_pos,temp,ACTIVATE_SHOOT);
vec_set (hit_coords, target); // store rocket's coords before they get lost
}
wait(1);
}
}


function create_crate()
{



wait (1);
my.skill1 = 1; // set the index to 1
my.skill2 = 50000; // set a huge distance at first; skill2 will get smaller and smaller for the vertices that are closer and closer to the explosion
while (my.skill1 < 1090) // go through all the vertices (1...1089) on the 33x33 grid (not using vertex_dist[0])
{
vec_for_mesh (temp, terrain1, my.skill1); // sets temp to vertex1, 2, 3...
vertex_dist [my.skill1] = vec_dist (hit_coords.x, target); // measures the distance between temp (vertex1, 2, 3...) and hit_coords
if (vertex_dist[my.skill1] < my.skill2) // this vertex is closer than the others?
{
my.skill2 = vertex_dist[my.skill1]; // then it might be the one, so store the distance
my.skill3 = my.skill1; // and its index as well
}
my.skill1 += 1; // move on to the following vertex
}
deform (my.skill3);
}


function deform(vertex_number)
{

vec_for_mesh(temp, terrain1, vertex_number);
vec_scale (temp, 0.7);
vec_to_mesh (temp, terrain1, vertex_number);
ent_fixnormals (my, my.frame); // recalculate the normal vectors, not really needed
beep();
}




-Johnny Thrash
Re: Click to deform terrain code not working [Re: Metal_Thrasher] #180013
01/27/08 16:55
01/27/08 16:55
Joined: Oct 2003
Posts: 2,194
Saturn
Metal_Thrasher Offline OP
Expert
Metal_Thrasher  Offline OP
Expert

Joined: Oct 2003
Posts: 2,194
Saturn
sorry, for double posting...but help? please? anyone?
The code "works" but the terrain seems unaffected by it.


-Johnny Thrash
Re: Click to deform terrain code not working [Re: Metal_Thrasher] #180014
01/27/08 19:00
01/27/08 19:00
Joined: Mar 2004
Posts: 92
Dresden
Revo Offline
Junior Member
Revo  Offline
Junior Member

Joined: Mar 2004
Posts: 92
Dresden
maybe you use a chunked Terrain which you can not deform
(try var terrain_chunk = 0; to avoid this)
(sry for my bad eng ...)


-----3d Gamestudio Commercial---------
Vers. 7.8
Focus on Gaming
Re: Click to deform terrain code not working [Re: Revo] #180015
01/28/08 03:41
01/28/08 03:41
Joined: Oct 2003
Posts: 2,194
Saturn
Metal_Thrasher Offline OP
Expert
Metal_Thrasher  Offline OP
Expert

Joined: Oct 2003
Posts: 2,194
Saturn
Quote:

maybe you use a chunked Terrain which you can not deform
(try var terrain_chunk = 0; to avoid this)
(sry for my bad eng ...)



This was a good suggestion, and I tried this. But it made no differance


-Johnny Thrash

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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