Assistance needed with a mist transformation effec
#21
Posted 12 April 2012 - 04:11 PM
#22
Posted 13 April 2012 - 12:19 AM
My question this time pertains to using scaling and rotation on primitives. My issue is that if I scale a primitive it will actually "move" from it's initial location appearance wise. X and Y value wise, it of course doesn't change but visually it looks like it does. The same thing happens with rotation; it appears to move in a circle around the screen instead of just spinning in the same spot.
I understand that both of these are because for primitives the origin is set at 0,0, but how can I correct this issue and make it rotate in the same spot, or scale with it's center staying in the same location constantly?
NOTE: my game is 2d and does not use 3d views at all or z values; both scales and image_angle are incremented in end step
//draw event for primitive d3d_transform_add_scaling(image_xscale, image_yscale, 1); d3d_transform_add_rotation_z(image_angle); d3d_transform_add_translation(x,y,0); d3d_primitive_begin_texture(pr_trianglefan, mist_gradient) //center point d3d_vertex_texture_color(20,30,0,0.5,0.5,c_white,gradient_alpha); //top point d3d_vertex_texture_color(20,10,0,0.5,0,c_white,gradient_alpha); //upper right point 1 d3d_vertex_texture_color(31,10,0,0.81,0.1,c_white,gradient_alpha); //upper right point 2 d3d_vertex_texture_color(31,22,0,0.98,0.4,c_white,gradient_alpha); //right point d3d_vertex_texture_color(31,30,0,1,0.5,c_white,gradient_alpha); //lower right point 1 d3d_vertex_texture_color(31,38,0,0.98,0.6,c_white,gradient_alpha); //lower right point 2 d3d_vertex_texture_color(31,50,0,0.81,0.9,c_white,gradient_alpha); //bottom point d3d_vertex_texture_color(20,50,0,0.5,1,c_white,gradient_alpha); //lower left point 1 d3d_vertex_texture_color(9,50,0,0.19,0.9,c_white,gradient_alpha); //lower left point 2 d3d_vertex_texture_color(9,38,0,0.02,0.6,c_white,gradient_alpha); //left point d3d_vertex_texture_color(9,30,0,0,0.5,c_white,gradient_alpha); //upper left point 1 d3d_vertex_texture_color(9,2,0,0.02,0.4,c_white,gradient_alpha); //upper left point 2 d3d_vertex_texture_color(9,10,0,0.19,0.1,c_white,gradient_alpha); //top starting point d3d_vertex_texture_color(20,10,0,0.5,0,c_white,gradient_alpha); d3d_primitive_end(); d3d_transform_set_identity();
#23
Posted 13 April 2012 - 01:10 AM
//center point
d3d_vertex_texture_color(0,0,0,0.5,0.5,c_white,gradient_alpha);
and so on..
quick fix for the moment
cx = 20
cy = 32
d3d_vertex_texture_color(20-cx,30-cy,0,0.5,0.5,c_white,gradient_alpha);
...
note that point when scaled or rotated will not move
but the -cx,-cy in all your current calls.
anything >0 or <0 will stretch with the scale and rotate....
the translation call will position the effect on the screen where you want
#24
Posted 13 April 2012 - 01:41 AM
first I would make sure the effect is centered on 0,0,0...
//center point
d3d_vertex_texture_color(0,0,0,0.5,0.5,c_white,gradient_alpha);
and so on..
quick fix for the moment
cx = 20
cy = 32
d3d_vertex_texture_color(20-cx,30-cy,0,0.5,0.5,c_white,gradient_alpha);
...
note that point when scaled or rotated will not move
but the -cx,-cy in all your current calls.
anything >0 or <0 will stretch with the scale and rotate....
the translation call will position the effect on the screen where you want
I don't really get what you mean bro; if I center all my vertexes at 0,0 they will all be on top of each other and then my code will be useless.
#25
Posted 13 April 2012 - 02:01 AM
I understand that both of these are because for primitives the origin is set at 0,0, but how can I correct this issue and make it rotate in the same spot, or scale with it's center staying in the same location constantly?
If your object isn't constructed around the point you wish to rotate/scale (the origin), it's just a matter of first translating that point to the origin, then performing the rotation/scaling, then using another translation to move it to where you wish to draw it.
Altered code found in object3 of download:
d3d_transform_set_identity();
//now draw the fog
image_angle+=1;
// minus offset {20,32}
d3d_transform_add_translation(-20,-32,0);
d3d_transform_add_rotation_z(image_angle);
d3d_transform_add_scaling(1.5,1.5,0)
// translation {x,y} + offset*scaling
d3d_transform_add_translation(x+1.5*20,y+1.5*32,0);
#26
Posted 13 April 2012 - 05:42 AM
d3d_transform_set_translation( -(20+x_value[0]), -(30+y_value[0]), 0 );
d3d_transform_add_rotation_z(image_angle);
d3d_transform_add_scaling(image_xscale, image_yscale, 0 );
d3d_transform_add_translation(x,y,0);
#27
Posted 16 April 2012 - 04:33 AM
I am actually amazed how it looks just like the one in SOTN, and actually a bit better.
#28
Posted 16 April 2012 - 07:04 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users



This topic is locked







