playMaker

Author Topic: draw with SetPixel  (Read 5399 times)

logiquefloue

  • Playmaker Newbie
  • *
  • Posts: 35
draw with SetPixel
« on: June 26, 2013, 05:37:30 AM »
Hello,

I'm new in the world of playmaker.

I want to draw a rectangle on the texture at the cursor point when the play clicks.

It is this position that does exactly what I want   But unfortunately I can not put it into practice playmaker 
http://hutonggames.com/playmakerforum/index.php?topic=2778.0
I do not understand how we can draw the rectangle with the script while RaycastX RaycastY and can take only 0 or 1 as the value around?

in advance, thank you for your help   :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: draw with SetPixel
« Reply #1 on: June 26, 2013, 05:58:11 AM »
Hi,

 are looking at drawing a rectangle in 2d or 3d ( from a user point of view) ?

 I would in all cases work with Vectrosity, this is an amazing system to draw very easily and with great powerf any kind of lines.

http://starscenesoftware.com/vectrosity.html

Also, can you explain what you are after? maybe there is a simple way to achieve what you want, and not having to mess with drawing pixels on a texture, which is already quite advanced, even without playmaker.

bye,

 Jean

logiquefloue

  • Playmaker Newbie
  • *
  • Posts: 35
Re: draw with SetPixel
« Reply #2 on: June 26, 2013, 06:15:59 AM »
Hello Jean and thank you for your reply :)

Let me explain what I want to do: I want to give the opportunity to the player to select an area of an object (a part of a wall) and change its color. Should I store this area can 'colored' and the selected color in a database for charging to start the game, make statistics ....

voici le message en français car je suis nul en anglais :(

Bonjour Jean et merci pour ta réponse :)

Je vous explique ce que je souhaite faire : je souhaite donner la possibilité au joueur de sélectionner une zone d'un objet (une partie d'un mur par exemple) et de modifier sa couleur. Il faut que moi je puisse stocker cette zone 'coloriée' et la couleur choisie dans une base de données pour la recharger au démarrage du jeu, faire des statistiques....

Merci beaucoup

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: draw with SetPixel
« Reply #3 on: June 26, 2013, 06:30:15 AM »
Hi,

 Your english is fine, don't worry  ;)


You don't really need to draw on textures then. Simply create planes. It will give you far more raw power.

few things:

-- do not use the default unity plane, too much faces, build your own as a fbx or via code. two face is enough

-- if you work with real mesh, it then means you can also have colliders, which will make user picking far easier to deal with.

 and actually, you could use 2d ui like ngui or 2d toolkit to draw simply squares on given size and coordinates, this would totally remonve any kind of messing with meshes, the 2d framework would do that automatically.

 Not trying to put you away from editing textures, but here this is likely the wrong path.


bye,

 Jean

logiquefloue

  • Playmaker Newbie
  • *
  • Posts: 35
Re: draw with SetPixel
« Reply #4 on: June 26, 2013, 06:48:52 AM »
So you propose to add a square above my mesh, except that it works on flat surfaces. My example was well chosen, sorry. If I want to color a portion of a cylinder or a sphere, how it might work.

The fact of adding plans, over time this would not be too much load the scene mesh?

thank you

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: draw with SetPixel
« Reply #5 on: June 26, 2013, 08:36:07 AM »
Hi,

 ok, I see. then yes texture editing will be needed.

Do you need to only draw pur rectangle with plain colors? I could wrapp this into a custom action, cause doing this with a fsm would be really complex, and not that effective I think.

Don't worry about mesh loads, it's not an issue here. Somes heavy games using ngui extensivly as their 2d interface, have thousands of gameObjects JUST for the ui...

bye,

 Jean

logiquefloue

  • Playmaker Newbie
  • *
  • Posts: 35
Re: draw with SetPixel
« Reply #6 on: June 26, 2013, 09:14:26 AM »
Yes, it is a simple rectangle color. My goal is that the onscreen user draws a rectangle with the mouse to select and change the color of the selection.  :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: draw with SetPixel
« Reply #7 on: June 26, 2013, 02:06:18 PM »
Hi,

 ok, and how to you plan on mouse selection over a sphere, cylinder and other non planar shapes? how do you define the top left and bottom right corner? or is centered to the mouse click and you give then a size? Or do you apply the rectangle as it is drawn on screen? also, what about the user that draws over several shapes?

I need to know that in order to make sure what I am going to provide works for you.

bye,

 Jean

logiquefloue

  • Playmaker Newbie
  • *
  • Posts: 35
Re: draw with SetPixel
« Reply #8 on: June 27, 2013, 03:19:23 AM »
Hello Jean,

I expect the selection rectangle drawn with the mouse (also thank you for custom 'ArrayMaker' functions they help me a lot to understand  ;))
My whole object (consisting of several half-cylinder) is unfolded in a single texture. Thanks to 'Mouse Pick UV I can put in my variable UV coordinates of the starting point of the selection A1 (x1, y1) (mouse down) and the UV coordinates of the arrival A2 (x1, x2) (mouse up). Then use these coordinates in a SetPixel to change the color of the pixels of the texture that were in the marquee. So yes I think 2d (uv texture coordinates) and not 3d selection ... I do not know if this is the right way?

thank you,

bye  :)
« Last Edit: June 27, 2013, 03:29:26 AM by logiquefloue »