chrismiles / CMTraerPhysics

Objective-C/Cocoa port of the Traer v3.0 physics engine; with iOS demo app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to modify imagesize for cloth simulation?

niravspaceo opened this issue · comments

Hey Chris,
You have made a fantastic code for cloth simulation.
I want to ask you a question and that is how to modify the image size which you have used in cloth simulation, right now that image has size 1024*1024 , but in device it is showing small.So i want to modify the height and width of that particular image.

Thanks,
Nirav

The image used as the texture? You can replace it with any sized image, it will be scaled to fit. You can modify the texture coordinate calculations to adjust how it is mapped to the cloth if needed.

If you mean the size of the rendered geometry, you want to adjust how the physics particles are mapped to screen vertices. Look in -drawFrame: where the gridVertices array is being updated.

Cheers,
Chris

Yes, i want to modify the size of image which is used as texture that is "sandy_beach.jpg"(the code you have written is self.gridTexture = [CMGLESKTexture textureNamed:@"sandy_beach.jpg"];)

Actual size of that image is 1024*1024 but the image is so small in device...I am looking into code to modify the image size.Can you please tell me which line of code will i have to modify???

Thanks,
Nirav

Do you mean you want to increase the size of the cloth on screen? If so, look in setupPhysicsInFrame:. The geometry of the cloth is specified by the physics particles, which are laid out relative to the view frame. Play with sp, sx, sy in particular.

If this is not what you mean, please explain in more detail. Tell me what you have already tried to do.

Cheers,
Chris

Hi Chris,
I got it.I just changed the gridSize that you have defined in - (id)initWithNibName...... function . I made gridSize larger and i can modify the size of image.Thank you so much for your help.I am still understanding your code, If i will get confused then i will tell you.

Cheers,
Nirav