playMaker

Author Topic: Collision Info for Get Pixel Color  (Read 2981 times)

YeBoi

  • Playmaker Newbie
  • *
  • Posts: 4
Collision Info for Get Pixel Color
« on: May 28, 2018, 06:47:01 PM »
Okay, so interesting concept here but I'm trying to make a little FSM for VRChat.
Basically, I'm trying to put a collider on a cube that's in my avatars finger, that collides with a color wheel to select the color my fingers on for the texture, then change a materials color based off of the position my finger is on.

I've seen it done, just lacking the expertise for this asset.

What I have right now seems to be incapable of sending the correct info but here's what I have.


State 1 :


State 2:
Ignore the Set Color Value, it was a test and it worked without it, just forgot to remove it lol



Essentially, I'm trying to take the cubes collision info and translate it to a color value for the material to change colors.
In turn, this allows me to drag my finger across the color wheel to change colors of the material while it's constantly updating as my finger moves.
But in the actual test, this doesn't work at all.
I've made sure the color change works, as I tried it with a mouse-down to get X and Y coordinates for the color (which kind of worked? it was only doing about 20% of the texture, the rest changed it to black and the 20% was only blue and green but it still worked just had to keep clicking to change instead of it constantly updating).

Any help would be great, I'm new to playmaker so apologies if I reply kind of stupidly about certain features. It took me forever to realize ecosystem is where I had to find Get Pixel Color lol.
« Last Edit: May 28, 2018, 06:56:28 PM by YeBoi »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Collision Info for Get Pixel Color
« Reply #1 on: May 30, 2018, 03:03:32 AM »
Hi,

 so you are all set now right?

 Bye,

 Jean

YeBoi

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Collision Info for Get Pixel Color
« Reply #2 on: May 30, 2018, 07:20:06 PM »
Hi,

 so you are all set now right?

 Bye,

 Jean

What? No?
No one's even replied yet o.o
What made you think I'm all set?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Collision Info for Get Pixel Color
« Reply #3 on: May 31, 2018, 02:04:08 AM »
Hi,

 "It took me forever to realize ecosystem is where I had to find Get Pixel Color lol."

 I though that was what you needed... I just misunderstood... :)

so,

-- do you have the uv coordinates from your click using raycast info or similar action right?

once you have the UV, you can translate it as a pixel coordinate.

-- do you know what UV coordinates are?

Bye,

 Jean



YeBoi

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Collision Info for Get Pixel Color
« Reply #4 on: May 31, 2018, 02:42:00 PM »
Ah, fair enough.
I was just adding that in to say I finally figured out how to add that action.

And no, I can't add raycast as it's in scripts which VRChat does not allow.
Playmaker is the only version of scripts that are being added, therefore I have to do everything inside of Playmaker.

As for UV Coordinates, no.

I'm not using my mouse to gather click info, it was only for a test to see if collision would work alone, removing the GetPixelColor as the issue.

In short, I'm trying to gather the coordinates of the collision on the color wheel to translate to a color for a different material.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Collision Info for Get Pixel Color
« Reply #5 on: June 01, 2018, 02:56:31 AM »
Hi,

ok, a Texture is applied on a mesh using UV coordinates, U and V are like x and y axis but mapped onto the mesh over each faces. they range from 0 to 1 and are defined usually in your 3d model design. But for a simple face or cube, or quad UV 0,0 is the bottom left corner, UV 1,1 is the top right corner.

 so when you raycast or collide onto a mesh, the ray or collision info will give you the UV coordinates of the impact, then what you do is you take your texture and map the uv coordinate to a pixel.

 for a U value of 0.5, and a texture width of 256 pixels, the pixel you want  is 0.5*256 -> 128

 does that make sense?

 now you seem to have a problem to get the uv coordinate in the first place.

 so to start on this, do this without vr char, with just a regular sphere colliding on a cube where you have your texture, and try to get the pixel at the collision point, make sure that works, and then the second step is to plug this with vrchat.

 Let me know how you progress.

 Bye,

 Jean
« Last Edit: June 11, 2018, 03:23:52 AM by jeanfabre »

YeBoi

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Collision Info for Get Pixel Color
« Reply #6 on: June 01, 2018, 11:21:53 PM »
Hi,

ok, a Texture is applied on a mesh using UV coordinates, U and V are like x and y axis but mapped onto the mesh over each faces. they range from 0 to 1 and are defined usually in your 3d model design. But for a simple face or cube, or quad UV 0,0 is the bottom left corner, UV 1,1 is the top right corner.

 so when you raycast or collide onto a mesh, the ray or collision info will give you the UV coordinates of the impact, then what you do is you take your texture and map the uv coordinate to a pixel.

 for a U value of 0.5, and a texture width of 256 pixels, the pixel you want  is 0.5*256 -> 128

 does that make sense?

 now you seem to have a problem to get the uv coordinate in the first place.

 so to start on this, do this without vr char, with just a regular sphere colliding on a cube where you have your texture, and try to get the pixel at the collision point, make sure that works, and then the second step is to plug this with vrchat.

 Let me know how you progress.

 Bye,

 Jean
 Bye,

 Jean

Given all of that, I still don't understand how to convert the Collision Event with Get Collision Info, there's no actions to convert the info from the collision event to UV coordinates at all?
Mind explaining a bit more in depth or explain if there's some custom actions I'm supposed to be adding in...?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Collision Info for Get Pixel Color
« Reply #7 on: June 11, 2018, 03:27:18 AM »
Hi,

 no, there is no built in solution, but I found one when googling, I'll add it to the ecosystem this week.

https://forum.unity.com/threads/get-uv-coordinate-from-collision.12720/

 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Collision Info for Get Pixel Color
« Reply #8 on: September 19, 2018, 02:39:31 AM »
Hi,

 sorry, a bit late :)

 basically the trick is to do a raycast from the collision infos and then you have access to the texturecoordinates ( using the custom action GetRaycastHitInfoExtras)

 but I created an action that does it all, it lets you get all the collision infos, as well as the raycast from that collision ( using the direction of the collision)

it's on the ecosystem: GetCollisionRayCastInfo

Let me know how it goes.

Bye,

 Jean