Assistance needed with a mist transformation effec

27 replies to this topic

#21 icuurd12b42

icuurd12b42

Self Formed Sentient

• Global Moderators
• 14446 posts
• Version:GM:Studio

Posted 12 April 2012 - 04:11 PM

Yes, remember to show us the final result!
• 1

#22 esco

esco

GMC Member

• GMC Member
• 211 posts

Posted 13 April 2012 - 12:19 AM

Ok everyone, it's time for round 12 of "let's teach esco how to properly use d3d so he will stop asking so many ****ing questions about it!!!"

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
//center point
//top point
//upper right point 1
//upper right point 2
//right point
//lower right point 1
//lower right point 2
//bottom point
//lower left point 1
//lower left point 2
//left point
//upper left point 1
//upper left point 2
//top starting point
d3d_primitive_end();
d3d_transform_set_identity();
```

• 0

#23 icuurd12b42

icuurd12b42

Self Formed Sentient

• Global Moderators
• 14446 posts
• Version:GM:Studio

Posted 13 April 2012 - 01:10 AM

first I would make sure the effect is centered on 0,0,0...

//center point

and so on..

quick fix for the moment
cx = 20
cy = 32
...

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
• 0

#24 esco

esco

GMC Member

• GMC Member
• 211 posts

Posted 13 April 2012 - 01:41 AM

first I would make sure the effect is centered on 0,0,0...

//center point

and so on..

quick fix for the moment
cx = 20
cy = 32
...

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.
• 0

#25 xot

xot

media multimixer

• Global Moderators
• 4653 posts
• Version:GM:Studio

Posted 13 April 2012 - 02:01 AM

I wrote this quite a while before posting it (phone call) so sorry if it is redundant.

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.

```d3d_transform_set_identity();

//now draw the fog
image_angle+=1;
// minus offset {20,32}
// translation {x,y} + offset*scaling

• 1

#26 esco

esco

GMC Member

• GMC Member
• 211 posts

Posted 13 April 2012 - 05:42 AM

Thanks to Xot for solving my issue!

d3d_transform_set_translation( -(20+x_value[0]), -(30+y_value[0]), 0 );
• 0

#27 esco

esco

GMC Member

• GMC Member
• 211 posts

Posted 16 April 2012 - 04:33 AM

Here is a page with videos of the finished effect in action. One with particles and one with out: http://sotnhacked.wo...ist-form-in-gm/

I am actually amazed how it looks just like the one in SOTN, and actually a bit better.
• 0

#28 xot

xot

media multimixer

• Global Moderators
• 4653 posts
• Version:GM:Studio

Posted 16 April 2012 - 07:04 AM

Cool! Nice to see a follow-up.
• 0

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users