Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Something like Linepick() in Blitz3d

Sam
Guest
Quote
2024-01-14 05:46:58

I'm currently using a script to see how far the player is from lights and make them not visible at a distance.

Course that doesn't work well as you might be above or below it and it still will turn on.

I was wanting just to turn off the directional light when i was in a structure . but this wont work with that. is there anyway to check if the directional light is visible and not obscured by something?

Should be This right?
ccbGetCollisionPointOfWorldWithLine(startX, startY, startZ, endX, endY, endZ)

It didn't seem to work, I was trying it against the Camera.
but it seems it should reach the end of the line (that being the player) if it is hit before it hits the world?


Sam
Guest
Quote
2024-01-14 05:52:08

I see there is a post already, cept that person was really asking about raytracing..lol

Im gonna give it another try..lol


Sam
Guest
Quote
2024-01-14 10:48:47

I got it, it does work.

var d_light = ccbGetSceneNodeFromName("DirectionalLight");

var startPos3D = ccbGetSceneNodeProperty(d_light , "Position");

var sm = ccbGetSceneNodeFromName("Camera1");

var endPoint3d = ccbGetSceneNodeProperty(sm,"Position");

//*------------------------------------------------------------------------------------------------------------------------------------------
var col_point = ccbGetCollisionPointOfWorldWithLine(startPos3D.x, startPos3D.y, startPos3D.z, endPoint3d.x, endPoint3d.y+5, endPoint3d.z)

if (col_point != null )

{

ccbSetSceneNodeProperty(d_light, "Visible", false);

}else {

ccbSetSceneNodeProperty(d_light, "Visible", true);
}


//*-----------------------------------------------------------------------------------------------------------------------------------------
// end


Anyone know how costly the function is? Maybe it would be good to hide stuff that cant be seen?


Sam
Guest
Quote
2024-01-14 10:56:26

Don't Need the +5 on endPoint3d.y

I was trying to adjust for the fact that directional light is infinite direction not position. got it close by moving the camera until the shadows were not visible from the view point and putting the light there.


Guest
Guest
Quote
2024-01-15 18:23:40

Why? Just use the proximity behavior.


Sam
Guest
Quote
2024-01-15 22:46:28

Because Directional light is infinite and you would always have to be proximity in a level or world. Even if you used a point light to act as the sun and light the world, its range would have to be bigger than the world , so you would have to always be in proximity there as well.

This will tell you if you are in a structure so you can change the lighting accordingly.


just_in_case
Moderator
Quote
2024-01-16 02:15:23

Hie there, if you are going to check with all the objects in the scene then it might be a bit performance heavy, as the number of objects increases in the scene the fps might drop

But if you are using it with just player or the camera then you can use it, it won't affect the performance that much. Just make sure that you do the collision calculation in the last of your frame, otherwise it will eat lots of performance if you have any other extra code in that script.

As others suggested it's better to use proximity then the collision ray to hide or unhide objecta in the scene.

For occlusion, if it is possible then we might get the occlusion culling in the next version of CC.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact