Gamestudio Links
Zorro Links
Newest Posts
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
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Create Blocks during runtime ||| Zur Laufzeit erstellte Entities #230458
10/05/08 16:35
10/05/08 16:35
Joined: Oct 2008
Posts: 24
Germany
H
Hazardos Offline OP
Newbie
Hazardos  Offline OP
Newbie
H

Joined: Oct 2008
Posts: 24
Germany
[Scroll down for something English-like]

Hallo liebe Leute,

in sämtlichen Tutorials und im Handbuch zu GS konnte ich zu meiner Frage bislang keine Antwort finden. Ich habe folgendes Problem an dem ich zurzeit knusper:

Ausgangssituation:
In einer separaten Datei habe ich ein Level geschrieben. Es ist eine Aneinanderreihung von Blöcken mit entsprechenden Eigenschaften, wie Position, Skalierung und Farbe.

Zuvor die Frage: Wie kann man einen einzelnen Block zur Laufzeit erstellen? (ohne model oder map etc.!!!!!!)

Ich helfe mir mit einem "Einheitsblock" als mdl aus, welchen ich entsprechend skaliere und das material entsprechend der Datei einstelle.
Nun das Problem: Das Material ist bei allen Blöcken gleich!

abstrahierter Code wie folgt:

- Eigenschaften aus Datei auslesen
- Entity mit entsprechender Position erzeugen und dem Pointer my zuweisen
- Entity skalieren
- über my.material... die Materialeigenschaften zuweisen

und das ganze so oft hintereinander wie laut Datei Blöcke benötigt werden.

Warum funktioniert die Positionszuweisung und Skalierung tadellos, nur die materialzuweisung nicht? Wahrscheinlich ein dummer Anfängerfehler o_O

MfG Jörn
-------------------------------
Zuletzt eine kleine Frage nebenbei:
Wie kann ich lite-c sagen, dass ich keine Map brauche?
(Map wird via Code erstellt)



_____________________________________________________

Hello folks,

I've got one question for you:

I want to create blocks during runtime, therefore I have got a file which contains position, size and color of each block. I read this file during runtime and create blocks. I can position and scale them as defined in the file, but the material is the same.

the code does something like:
-read file, get position/size/color
- create an Entity which contains only one block and set the pointer my to the new created Entity
- set Position and scaling
- now i set the material-settings with my.material...

the blocks are created right, but they look all the same! Why??

A little question before the end:
-How can I tell lite-c, that I don't want to use a map or terrain and still run the engine?
- I've helped myself out by using a model which contains a block. But how can I create blocks just with the engine, without extern files?

Whoever may find faults can keep them :-P

Greetings, Jörn

Re: Create Blocks during runtime ||| Zur Laufzeit erstellte Entities [Re: Hazardos] #230479
10/05/08 19:33
10/05/08 19:33
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline
User
Stromausfall  Offline
User

Joined: Dec 2002
Posts: 616
Austria
Hi!
So viel ich weiß werden, wenn man ein Model verändert, alle Einheiten die dieses Model benützten auch verändert (wenn man also z.B.: Model das Model neu skaliert).
Versuch mal deinen Einheitsblock öfters in deinen Ordner im Windows zu kopieren und dann im GameStudio für jede Einheit die du erstellen willst genau eines dieser Modelle herzunehmen - das heisst, dass du nicht das gleiche Model für mehrere Entities hernimmst, sondern für jedes erstellte ein eigenes Model benützt.


Möglicherweise gibts auch einen einfacheren Weg, ohne so viele Entities - kenn ihn aber leider nicht

Gruss,
Stromausfall



Engl.:
you should use one model per entity you create, that means for the first entity you load through your script you use (for example) model_1.mdl and for the second model_2.mdl ....
Because if you change the properties of a model - all entities which use this model, are also changed. Because all entities which use this model only use this ONE model and not copies of it - as far as i know.

But maybe there's an easyer way to solve your problem - but i don't know it.

Cheers,
Stromausfall


get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: Create Blocks during runtime ||| Zur Laufzeit erstellte Entities [Re: Stromausfall] #230490
10/05/08 23:10
10/05/08 23:10
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Try adding a dummy action to the created entities that will run long
enough for you to finish changing its prioerties.
eg. action ent_dummy() { wait(10); }

Otherwise, please post the code chunk that reads the file and creates
the blocks, and I'll have a look.

I think the 'little' answer you're looking for is level_load(NULL);


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Create Blocks during runtime ||| Zur Laufzeit erstellte Entities [Re: EvilSOB] #230500
10/06/08 07:00
10/06/08 07:00
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
Because if you change the properties of a model - all entities which use this model, are also changed. Because all entities which use this model only use this ONE model and not copies of it - as far as i know.

search this up in the manaul

ent_clone(ENTITY*);
ent_cloneskin(ENTITY*);


"empty"
Re: Create Blocks during runtime ||| Zur Laufzeit erstellte Entities [Re: flits] #230501
10/06/08 08:16
10/06/08 08:16
Joined: Oct 2008
Posts: 24
Germany
H
Hazardos Offline OP
Newbie
Hazardos  Offline OP
Newbie
H

Joined: Oct 2008
Posts: 24
Germany
Die verwendete Datei sieht so aus:
The file looks like this:

start/Am Anfang:
2 bytes which defines the number of blocks in the Level
2 bytes, welche die Anzahl der Blöcke angeben

for each Block/für jeden Block:
- X (2 byte)
- Y (2 byte)
- z (1 byte)
- scale_x (1 byte)
- scale_y (1 byte)
- color R
- color G
- color B

The code still works for different positions. But even by using ent_clone/or ent_cloneskin in the for-command the color of all blocks becomes the color of the last block.

Dies ist der Code, welcher die Entitys erzeugt, verschiedene Positionen und Skalierungen zuweist, aber allen das gleiche Material übergibt! ent_clone/ent_cloneskin funktioniert leider nicht.


Code:
fhandle = file_open_read("Level01.txt");
Block_Count = file_asc_read(fhandle)*256 + file_asc_read(fhandle);

	for (i=1; i<=Block_Count; i++)
		{
			my = ent_create("Level01\\Block.mdl", vector (
				file_asc_read(fhandle) + file_asc_read(fhandle)*256,
				file_asc_read(fhandle) + file_asc_read(fhandle)*256,
				file_asc_read(fhandle)), NULL);
			ent_clone (my);
			my.scale_x = file_asc_read(fhandle);
			my.scale_y = file_asc_read(fhandle);
				
			my.material.emissive_blue = file_asc_read(fhandle);	
			my.material.emissive_green = file_asc_read(fhandle);
			my.material.emissive_red = file_asc_read(fhandle);
			
			my.material.ambient_blue = 0;
			my.material.ambient_green = 0;
			my.material.ambient_red = 0;
		}

file_close(fhandle); 



thanks for your help!
dankeschööööön! ;-)

Greetings Jörn


Re: Create Blocks during runtime ||| Zur Laufzeit erstellte Entities [Re: Hazardos] #230520
10/06/08 13:15
10/06/08 13:15
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I can see two possible causes for the problem.

First - does your "block.mdl" have an actual built-in material?
(in MED go to EDIT / MANAGE_SKINS and click SKIN SETTINGS button, and make sure the skin has the
MATERIAL_SETUP tickbox ticked ON. If not, put it ON then save and re-run your existing code. )


Otherwise try this,
Code:
fhandle = file_open_read("Level01.txt");
Block_Count = file_asc_read(fhandle)*256 + file_asc_read(fhandle);

	for (i=1; i<=Block_Count; i++)
		{
			my = ent_create("Level01\\Block.mdl", vector (
				file_asc_read(fhandle) + file_asc_read(fhandle)*256,
				file_asc_read(fhandle) + file_asc_read(fhandle)*256,
				file_asc_read(fhandle)), NULL);
			//ent_clone (my);	// not needed probably
			my.scale_x = file_asc_read(fhandle);
			my.scale_y = file_asc_read(fhandle);
				
			my.material = mtl_create();	// <<< major change
			//my.material.??? = ???;	// <<< may need to change some defaults
			
			my.material.emissive_blue = file_asc_read(fhandle);	
			my.material.emissive_green = file_asc_read(fhandle);
			my.material.emissive_red = file_asc_read(fhandle);
			
			vec_set(my.material.ambient_blue, nullvector);	//for tidyness sake
		}

file_close(fhandle); 
Let us know which helps, if any...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Create Blocks during runtime ||| Zur Laufzeit erstellte Entities [Re: EvilSOB] #230644
10/07/08 12:40
10/07/08 12:40
Joined: Oct 2008
Posts: 24
Germany
H
Hazardos Offline OP
Newbie
Hazardos  Offline OP
Newbie
H

Joined: Oct 2008
Posts: 24
Germany
It works!!!

the line "my.material = mtl_create();" was definetely missing and finally solved my problem!!!

Thanks!!!

Whenever you should get the information on how to create blocks with lite-c and acknex, let me know it!!!

Greetz, Jörn

Re: Create Blocks during runtime ||| Zur Laufzeit erstellte Entities [Re: Hazardos] #230649
10/07/08 13:36
10/07/08 13:36
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Hah! I wish I knew. I am looking at having to create
terrain blocks on the fly using similar to your code.

Best of luck.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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