Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (Grant, AndrewAMD), 911 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Need example and better help on terrainforming #339020
08/23/10 21:17
08/23/10 21:17
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
hi there..

I´m working at a Map Editor, wich uses a terrain as base model. Now i want to make Planing, Digging or raising tools.

But i´ve a big problem getting the vertexes around the cursor (by a given range), and change their position...

Has someone a good example or manual (or something else) for me?

Last edited by Espér; 08/23/10 21:43.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Need example or better help on terrainforming [Re: Espér] #339022
08/23/10 21:33
08/23/10 21:33
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Have a look at my DEFORM TERRAIN for the summer contest. You can include it to your current project or use some codesnippet from it. Hope you can use it wink
Here you go

Re: Need example and better help on terrainforming [Re: Widi] #339024
08/23/10 21:41
08/23/10 21:41
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
not really.. it shows me that it works.. but not HOW it works...

I need this for a real complex thing of editor, wich lets vertices stay where they are, when a model is in the way. And only for a raster (not circled range.. i need it square ranged)..
Means i need to code it by myself..

So looking your demo or copy things out of it (didn´t really know WHAT to copy).. is not helping me ^^

Last edited by Espér; 08/23/10 21:45.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Need example and better help on terrainforming [Re: Espér] #339027
08/23/10 22:00
08/23/10 22:00
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
I try to explain it (sorry for my english):
Declare a var (here: var range)
First make a trace from the mouse in the level. If the trace hits a terrain, then you have the middle position. Now you have to check every vertex of the terrain if x/y smaller or bigger the range:

if (vertex.x > hitpoint.x - range && vertex.x < hitpoint.x + range &&
vertex.y > hitpoint.y - range && vertex.y < hitpoint.y + range)

so you become a square around the given hitpoint. Now you can move all vertices in the if() loop by ent_getvertex and ent_setvertex.

Last edited by Widi; 08/23/10 22:02.
Re: Need example and better help on terrainforming [Re: Espér] #339028
08/23/10 22:01
08/23/10 22:01
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
tips:

terrain vertices are in a certain order, you can get closest vertex number to a c_trace hit (hit.vertex), then by adding numbers you can get the number of the vertices around that vertex. +1 is next vertex and -1 is previous, and depending on number your terrain vertices in x and y direction. you can get that number with ent_status in modes 2 and 3.

after you get find the vertices you need, you only need to trace up from each of them to see if there is something sitting on them before trying to raise them.(ent_setvertex)

Last edited by Quadraxas; 08/23/10 22:02.

3333333333
Re: Need example and better help on terrainforming [Re: Widi] #339029
08/23/10 22:03
08/23/10 22:03
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
yes.. that way i thought too..

But how to move all vertices at the same time (best with less performance killing)?


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Need example and better help on terrainforming [Re: Espér] #339031
08/23/10 22:05
08/23/10 22:05
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
move them all in same frame using ent_setvertex/ent_getvertex in a for loop.


3333333333
Re: Need example and better help on terrainforming [Re: Espér] #339032
08/23/10 22:07
08/23/10 22:07
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Set my if() in a loop to check all vertices and if it is true, than move it.

Re: Need example and better help on terrainforming [Re: Widi] #339033
08/23/10 22:08
08/23/10 22:08
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
hmm..
will try it..


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Need example and better help on terrainforming [Re: Espér] #339035
08/23/10 23:05
08/23/10 23:05
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
ok.. i tried it (hope) like Quadraxas said...
Code:
void change_terrain()
{
	traceposition.x = mouse_pos.x;
	traceposition.y = mouse_pos.y;
	traceposition.z = mouse_range;
	vec_for_screen (traceposition,camera);
	c_trace(camera.x,traceposition,IGNORE_ME | IGNORE_PASSABLE);
	vec_set(traceziel.x, target.x);
	if(you == ground && mouse_left == 1)
	{
		hitting = 1;
		var vertice = ent_status(ground, 1); //Gesamtanzahl
		var vert_nr = vertice;
		var vertice_x = ent_status(ground, 2); //Anzahl in X_Richtung
		var vertice_y = ent_status(ground, 3); //Anzahl in Y_Richtung
		
		CONTACT* vertcontact;
		VECTOR* vert_pos = nullvector;
		
		for(;vert_nr > 0;vert_nr--)
		{
			vec_for_vertex(vert_pos, ground, vert_nr);
			if(vec_dist(vert_pos.x, traceziel.x) <= range*32)
			{
				error("kleiner");
				ent_getvertex(ground, vertcontact, vert_nr);
				vertcontact.z += 5.0*time_step;
				ent_setvertex(ground, vertcontact, vert_nr);
			}
		}
	}
	else
	{
		hitting = 0;
	}
}



But nothing happens.
the variable "hitting" is set to 1.. means it hits the ground...


i always get a "Crash in CHANGE_TERRAIN SYS"

Last edited by Espér; 08/23/10 23:07.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Page 1 of 2 1 2

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