Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / 2.0.16 Bug - Raycast scaled objects

Author
Message
AJCodes
9
Years of Service
User Offline
Joined: 6th Jan 2015
Location:
Posted: 15th Dec 2015 06:37
- Fixed ObjectRayCast not working on scaled objects

Doesn't appear to be fixed, at least in this situation:

Create a box object. Able to raycast this.

Clone it. Able to raycast this.

Scale the clone. NOT able to raycast this.
Born. Currently living.
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 15th Dec 2015 14:39 Edited at: 15th Dec 2015 14:43
I tried this , but it looks like ray cast works for me ?
( shadows use ray cast , and they look fine ).

I think i remember there is problems with raycast and animated objects , are you using an animated object or using LoadObjectWithChildren ?

Or perhaps you dont roate your cloned object so your hitting a backface ?

BTW: I think ObjectRayCast got pretty slow in this version anyone else seeing this ?
best regards Preben Eriksen,

Attachments

Login to view attachments
AJCodes
9
Years of Service
User Offline
Joined: 6th Jan 2015
Location:
Posted: 15th Dec 2015 14:55
Interesting. I'd post code but I've got just less than 1K lines...overkill.

Stripped down to the basics in another project and found that if I use CreateObjectBox everything works. When loading the .obj I created, it doesn't. The .obj is simply a box object scaled and positioned such that it's 1m wide, 2m high, and .4m thick with it's origin set to one of the corners so I can quickly lay out a room from wall pieces.

Heading to work now so I can't explore to see if it's a bad .obj or of it's ALL loaded .obj's that have this issue.
Born. Currently living.
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 15th Dec 2015 15:18
Yes thats your problem then, your hitting a back face , agk always make double sided planes, so ray cast will work both inside the box and from outside.

If you try to hit your loaded box from outside you will see it works , but if you go inside it will not work ( or the other way around ) , so you just need to create your box using double sided planes , so ray cast is able to hit it from outside and inside.

I only have single sided planes in this house (no door) , so as you can see ( when you lift the house), when the ray cast run from inside the house ( hitting back faces ) it will not generate a shadow. (cast is running from ground to sun)

No need to post code (unless you already have double sided planes in your box).
best regards Preben Eriksen,

Attachments

Login to view attachments
AJCodes
9
Years of Service
User Offline
Joined: 6th Jan 2015
Location:
Posted: 16th Dec 2015 03:39
This has nothing to do with hitting a back face. It's a closed cube. I can hit all sides prior to the scale. Once scaled, I can't hit any side. It may be a badly formed .obj file that partially works, but it's not a backface/reversed poly issue unless the scaling itself is reverse winding the triangles, which would be a bug.
Born. Currently living.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 16th Dec 2015 08:09
Hi

In some case, Scale an object inverse the faces (with a negative scale : SetObjectScale(obj,-2,-2,-2) for example), but we can see it easily because the faces are inversed in the view ^^.
I haven't tried if the bug with raycast and scale is fixed yet.
Do you use cloneobject() or instanceObject() ?
AGK2 tier1 - http://www.dracaena-studio.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 16th Dec 2015 11:33

Could you try to see if it works if you use : SetObjectScalePermanent , instead of SetObjectScale , if that dont work try to sent your object and i will see if it works from here
best regards Preben Eriksen,
AJCodes
9
Years of Service
User Offline
Joined: 6th Jan 2015
Location:
Posted: 16th Dec 2015 15:37
No time to play with workarounds...my coding time is limited by real life.

Just reporting the bug - it will get fixed. And toward that, I just realized that I didn't include:
Tier 1
Windows executable developed on Win10

Played with it some more last night. Here's the steps.
obj = CreateObjectBox(1,1,1)

do some ObjectRayCast while moving the camera around to all angles...get hits as I should

now do SetObjectScale, once, many times, doesn't matter.

do the same ObjectRayCast thing from many angles...get no hits at all.

This appeared to work before and I was only seeing a consistent issue with loaded .objs. More work has shown that it happens with created objects also.

I intermittently get hits after a single scale operation, but that's hard to test using my setup. I've built a landscape editor/texture painter and I'm adding the ability to place objects and create and texture simple objects within it. I've created my own 3d manipulation tool and that's what I'm using to test this so scaling/moving/rotating is constant. If I had more time to test all of this that'd be great...but sadly...real life.

Speaking of which, I have to get to work.
Born. Currently living.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 17th Dec 2015 21:34
Can you send me the .obj file that is failing? I may not be able to look at if for a while due to Christmas holidays but it will help me track down the bug when I get around to looking at it.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 17th Dec 2015 22:47
Quote: "Christmas holidays"
You get holidays!? They're spoiling you!
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
AJCodes
9
Years of Service
User Offline
Joined: 6th Jan 2015
Location:
Posted: 18th Dec 2015 04:04 Edited at: 18th Dec 2015 04:05
@Paul...no need for the .obj. I can consistently recreate the bug using CreateObjectBox.

Quote: "
Played with it some more last night. Here's the steps.
obj = CreateObjectBox(1,1,1)

do some ObjectRayCast while moving the camera around to all angles...get hits as I should

now do SetObjectScale, once, many times, doesn't matter.

do the same ObjectRayCast thing from many angles...get no hits at all.

This appeared to work before and I was only seeing a consistent issue with loaded .objs. More work has shown that it happens with created objects also.
"
Born. Currently living.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 18th Dec 2015 14:27
Quote: "You get holidays!? They're spoiling you! "



Quote: "I can consistently recreate the bug using CreateObjectBox"

Thanks, fixed for the next version.

Login to post a reply

Server time is: 2024-09-29 07:30:53
Your offset time is: 2024-09-29 07:30:53