|
|
ent_fixnormals / moved bones
#387069
11/13/11 22:49
11/13/11 22:49
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Hi, is that right that ent_fixnormals don't work for models, which were modified by moved bones? I move some bones and execute ent_fixnormals on frame 0, but nothing happens? Here is the model with bones in MED:  Each bone is independent and assigned to a vertex "ring". In the engine, I move them up and down to make a parametrized flattened sphere cap like this:  But as you can see, the right image is wrong, the cap is not smooth by gouraud shading... it should look similar to this (the shape is not yet right, but you can see that the cap must be smoothed):  The model is no multimesh model, has only one group and only one frame. It is named "pTank.mdl". Best regards, -Christian
Last edited by HeelX; 11/13/11 22:50.
|
|
|
Re: ent_fixnormals / moved bones
[Re: HeelX]
#387080
11/14/11 02:51
11/14/11 02:51
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Dude, give this a TRY. For me its often been a 'blind' fix, but thats better than nothing, eh? Where you have the frame number zero in your c_updatehull's, try changing them to ...
c_updatehull(entity, entity.frame);
Just to see if it makes a difference. I was having a similar issue with terrains. Un-animated as you can expect...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: ent_fixnormals / moved bones
[Re: EvilSOB]
#387087
11/14/11 09:42
11/14/11 09:42
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
This fix doesn't make a difference. I tried ent_fixnormals(e, e->frame);, I also tried to do c_updatehull(e, e->frame); before I call ent_fixnormals - but it doesn't help. Thanks anyways 
|
|
|
Re: ent_fixnormals / moved bones
[Re: jcl]
#387109
11/14/11 14:06
11/14/11 14:06
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
How do you know that it doesn't work? Because I can see it:  source code:
ENTITY* eRef0 = ent_create("refTank0.mdl", vector(0,100,0), NULL);
ENTITY* e = ent_create("pTank_0.mdl", vector(0,0,0), NULL);
ENTITY* eRef16 = ent_create("refTank16.mdl", vector(0,-100,0), NULL);
float radius = 32, height = 64, cap = 16;
while (1)
{
radius = maxv(1, radius + key_force.x * 5 * time_step);
height = maxv(1, height + key_force.y * 5 * time_step);
cap = minv(maxv(0, cap + (key_g-key_f) * 5 * time_step), minv(height/2, radius));
char strDebug [128];
sprintf(strDebug, "key left, right: RADIUS = %.2f\nkey up, down: HEIGHT = %.2f\nkey F,G: CAP HEIGHT = %.2f", (double)radius, (double)height, (double)cap);
draw_text(strDebug, 10, 25, COLOR_WHITE);
draw_text("Left and right models are reference models with radius = 32, height = 64.\nLeft model has cap height = 0, right model has cap height = 16.\n\nThe dynamically adjusted model (middle) does not get correct gouraud shading when\ncap height is > 0 and ent_fixnormals was called.", 10, screen_size.y - 120, COLOR_RED);
ent_bonereset_all(e);
vec_set(e->scale_x, vector(1,1,1));
c_setminmax(e);
e->scale_z = height / (e->max_z - e->min_z);
e->scale_x = e->scale_y = (2 * radius) / (e->max_x - e->min_x);
char boneUp [32], boneDown [32];
VECTOR vBoneUp, vBoneDown;
int i;
for (i = 1; i <= 8; i++)
{
sprintf(boneUp, "up%d", i);
sprintf(boneDown, "down%d", i);
vec_for_bone(&vBoneUp, e, boneUp);
vec_for_bone(&vBoneDown, e, boneDown);
float nx = ((absv(vBoneUp.x) + absv(vBoneDown.x)) / (e->max_x - e->min_x)) / e->scale_x;
float ny = 1-cos(asin(nx));
float m = ny * (cap/e->scale_z);
ent_bonemove(e, boneUp, vector(0,0,-m));
ent_bonemove(e, boneDown, vector(0,0,m));
}
ent_fixnormals(e, 0); // doesn't work?
c_setminmax(e);
wait(1);
}
|
|
|
Re: ent_fixnormals / moved bones
[Re: jcl]
#387115
11/14/11 14:39
11/14/11 14:39
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Hm. The bones are independent and the vertex-"rings" (as you can see above in the very first image) are assigned to it - I use the bones to move vertices as a group. I do this, so that LOD stages are shaped the same and I don't need to clone the mesh for each instance of a differently parametrized entity.
Isn't it somehow possible to generate the normals depending to the animation-transformed mesh?
Last edited by HeelX; 11/14/11 14:40.
|
|
|
|