I tried to get the normals using dark physics commands but the normals return something confusing.
This seems like it would work in theory. If the normals would actually return the normal it should work.
Here is the source to understand what the normals are returning:
AutoCam Off
Phy Start
Sync On : Sync Rate 60
Make Object Cube 1, 100
Phy Make Rigid Body Static Box 1
Make Object Plain 2, 10, 10
Color Object 2, RGB(255, 255, 255)
Null = Make Vector3(1)
Null = Make Vector3(2)
Move Camera -400
Do
Control Camera Using ArrowKeys 0, 1, 2
If MouseClick() = 1
Object = Pick Object(MouseX(), MouseY(), 1, Object Count())
If Object <> 0
Set Vector3 1, Get Pick Vector X(), Get Pick Vector Y(), Get Pick Vector Z()
Normalize Vector3 2, 1 ` Normalize it
Temp = Phy Ray Cast All Shapes(Camera Position X(), Camera Position Y(), Camera Position Z(), X Vector3(2), Y Vector3(2), Z Vector3(2))
`PHY GET RAY CAST HIT() ` Why isn't this needed.
If Temp > 0
Object2 = Phy Get Ray Cast Object()
Dist# = Phy Get Ray Cast Distance()
`Get position for bullet hole
PosX# = Phy Get Ray Cast Hit Point X()
PosY# = Phy Get Ray Cast Hit Point Y()
PosZ# = Phy Get Ray Cast Hit Point Z()
Text 0, 0, "X: " + Str$(PosX#) + " Y: " + Str$(PosY#) + " Z: " + Str$(PosZ#)
` What could I use this for?
`tempu=phy get ray cast tu()
`tempv=phy get ray cast tv()
NormX# = Phy Get Ray Cast Hit Normal X()
NormY# = Phy Get Ray Cast Hit Normal Y()
NormZ# = Phy Get Ray Cast Hit Normal Z()
Text 0, 20, "X: " + Str$(NormX#) + " Y: " + Str$(NormY#) + " Z: " + Str$(NormZ#)
` Have to compensate for the image size to center it
Position Object 2, PosX# + NormX#, PosY# + NormY#, PosZ# + NormZ#
Point Object 2, PosX# + NormX#, PosY# + NormY#, PosZ# + NormZ#
EndIf
EndIf
EndIf
Sync
Loop
There are several things I am trying to do:
- Create decals and position and rotate them against any object
- Deform the decal to shape to the object (adjust vertexdata)
- Paint the decal on the object as an alternative using the tu and tv (texture u and v)
I don't entirely understand how to use the Phy Ray Cast All Shapes the correct way so that the normals returned work for my example. I tried a technique that someone from the forums suggested.
Tersculpt paints textures on an object. I am trying to figure out how to do this with decals. This would be the technique I would use if I can figure out how to get it to work. First I have to understand the Phy Ray Cast All Shapes command before I can start working on a way of adding my decal image to the object's texture.
I have been looking though the forums for an answer for a long time and no one seems to have one quite yet. I have tried several attempts at this with no luck.
I tried using a sphere positioning and rotating it so it is in front of the camera at all times. (fixed to the camera)
then:
Temp = Phy Ray Cast All Shapes(Camera Position X(), Camera Position Y(), Camera Position Z(), Object Position X(2), Object Position Y(2), Object Position Z(2))
I know that I can use normalize vector to get the normals and just use that, but I want to use Dark Physics instead. The raycasting was made for a reason and I want to learn how to use it.
I know I can use sparkies collision dll as well, but it is to much extra code on top of using physics. (so lower fps, more looping time, ect ect ect)
Any help would be appriciated.
Thanks,
Dark Fire
My future self met up with one day to teach me what I know today.