1 registered members (AndrewAMD),
678
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Deform 1 model
#351608
12/27/10 13:54
12/27/10 13:54
|
Joined: Apr 2010
Posts: 23
GieskeBon
OP
Newbie
|
OP
Newbie
Joined: Apr 2010
Posts: 23
|
Hi all, I have a question about deforming just 1 model. If you look at my code below, I create 6 times the same model on different places. Now, I only want to deform the first model. But the problem is that all 6 of them deform. Is there a solution for this problem or do I have to create 6 different models?
////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////
var vertexnumber = 1;
var displayz;
ENTITY* plate;
ENTITY* plate2;
ENTITY* plate3;
ENTITY* plate4;
ENTITY* plate5;
ENTITY* plate6;
PANEL* info =
{
digits (30, 10, "Vertex Number: %.0f", *, 1,vertexnumber);
digits (30, 30, "Display.z: %.0f", *, 1, displayz);
flags = SHOW;
}
function main()
{
video_mode = 9; // 1280x1024
// video_screen = 1; // start in full screen mode
level_load("");
// level_load("small.hmp");
mouse_mode = 4;
plate = ent_create ("Plate128x128.mdl", vector( 0, 0, -30), NULL);
plate2 = ent_create ("Plate128x128.mdl", vector(128, 0, -30), NULL);
plate3 = ent_create ("Plate128x128.mdl", vector(128,128, -30), NULL);
plate4 = ent_create ("Plate128x128.mdl", vector(128,256, -30), NULL);
plate5 = ent_create ("Plate128x128.mdl", vector(256,256, -30), NULL);
plate6 = ent_create ("Plate128x128.mdl", vector(512,128, -30), NULL);
while(1)
{
if (key_1)
{
CONTACT* contact1 = ent_getvertex(plate,NULL,vertexnumber);
contact1.z -= 2;
contact1.v = NULL;
ent_setvertex(plate,contact1,vertexnumber);
displayz = contact1.z;
wait(-0.5);
}
if (key_2)
{
CONTACT* contact1 = ent_getvertex(plate,NULL,vertexnumber);
contact1.z += 2;
contact1.v = NULL;
ent_setvertex(plate,contact1,vertexnumber);
displayz = contact1.z;
wait(-0.5);
}
if (key_8)
{
vertexnumber -= 1;
if (vertexnumber <= 0)
{
vertexnumber = 1;
}
}
if (key_9)
{
vertexnumber += 1;
if (vertexnumber >= 26)
{
vertexnumber = 25;
}
}
wait(1);
}
}
|
|
|
Re: Deform 1 model
[Re: GieskeBon]
#351609
12/27/10 14:00
12/27/10 14:00
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
check the manual under "ent_clone", should do the trick...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Deform 1 model
[Re: GieskeBon]
#351622
12/27/10 14:46
12/27/10 14:46
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
No problems!
BTW, for the sake of efficiency, try to only use ent_clone on the entities that get changed, otherwise you are just wasting resources, and therefore CPU...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Deform 1 model
[Re: EvilSOB]
#351629
12/27/10 15:24
12/27/10 15:24
|
Joined: Apr 2010
Posts: 23
GieskeBon
OP
Newbie
|
OP
Newbie
Joined: Apr 2010
Posts: 23
|
When I use the example from the manual, it won't work. The model from the ent_clone() will also disappear. Can you help?
ENTITY* plate7;
BMAP* NewBmap;
if (key_5)
{
ent_clone(plate);
ent_setskin(plate,NewBmap,1);
ent_setmesh(plate,plate7,0,0);
}
|
|
|
Re: Deform 1 model
[Re: GieskeBon]
#351630
12/27/10 15:51
12/27/10 15:51
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
You could test by using if(plate7) { ent_setmesh(plate,plate7,0,0); } instead. I suspect 'plate' is vanishing because 'plate7' is empty, and so the mesh of 'plate' gets replaced with nothing... BUT ?!?! What you are doing there is BAD! It will clone the entity every frame if the key_5 is held... Go back to your original code, as you posted at the top of this thread, and insert this code AFTER the ent_create's have been done, but BEFORE the while(1) loop starts...
ent_clone(plate); ent_clone(plate2);
ent_clone(plate3); ent_clone(plate4);
ent_clone(plate5); ent_clone(plate6);
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|