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 / OBJECT-RAYCAST Doesn't Detect Scaled Objects!

Author
Message
OminusPrime
9
Years of Service
User Offline
Joined: 30th Jun 2015
Location:
Posted: 30th Jun 2015 18:15 Edited at: 30th Jun 2015 19:19
Hi
I have a 3D program with objects that can be selected on screen with the mouse. works great i can position and rotate the objects and select them. But when i scale any objec the ObjectRaycast command cant see the objects anymore.

I Wrote some sample code below that reproduces the error.

It displays two cubes that are identical in every way they are both rotating and positioned on screen
when you pass the mouse over them they display the ID of whichever Object you are pointing at..

now if you click the mouse button the right cube grows to x3 size. and is no longer detectable. even though the only difference is the Scale

i did notice that once in a while it does seem to detect randomly but its very rare.

another experiment i tried was uniform scale (xyz all scaled the same amount) which does detect sometimes but detects as if it wasnt scaled at all . only the small cube area in the middle of the scaled cube selects it ignores the scaled portions. very strange. it also selects only at certain angles to the cube.

Anyway try the code below it doesn't use any external .OBJ files or anything.
And let me know if anyone else verifies this or has a fix.

Thks OminusPrime



// Project: TestScale
// Created: 2015-06-30
// set window properties
SetWindowTitle( "TestScale" )
SetWindowSize( 1024, 768, 0 )

// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )

CreateLightDirectional(1,0,-1,-1,255,255,255)
CreateLightPoint(1,0,0,200,600,155,155,255)


hhh=CreateObjectBox(100,100,100)
ggg=CreateObjectBox(100,100,100)
SetObjectPosition(ggg,70,0,300)
SetObjectPosition(hhh,-70,0,300)

SetObjectLightMode(ggg,1)
SetObjectLightMode(hhh,1)


SetCameraPosition(1,0,0,0)

SetCameraLookAt(1,0,0,300,0)
angle=0

do
print("Move Mouse From Cube to Cube to get ID")
print("Press L_Mouse for Scale")
print("When Cube 2 is scaled RayCast Fails")
//Rotate our object
inc angle
if angle>=360 then angle=0

SetObjectRotation(ggg,angle,angle,0)
SetObjectRotation(hhh,angle,angle,0)

//Code to allow mouse to probe objects
xx=GetPointerx()
yy=GetPointery()
X3D=1000*Get3dVectorXfromScreen(xx,yy)+GetCameraX(1)
Y3D=1000*Get3dVectorYfromScreen(xx,yy)+GetCameray(1)
Z3D=1000*Get3dVectorZfromScreen(xx,yy)+GetCameraz(1)
ObjectRayCast(0,GetCamerax(1),GetCameraY(1),GetCameraZ(1),X3d,Y3d,Z3d)
Hit=GetObjectRayCastHitID(0)

printc("CUBE ID="):print (Hit)

//This Code Gives us some scale if Left mouse Clicked
if GetRawMouseLeftState()
setobjectscale(ggg,1,1,3)
else
setobjectscale(ggg,1,1,1)
endif

Sync()
loop
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 30th Jun 2015 19:02 Edited at: 30th Jun 2015 19:04
Definite bug, I tried adding SetObjectCollisionMode( ggg, 1 ) to try to reset the shape but to no avail.

I know the collision code is based on Paul's DBPro collision code (sparky's) which had a command for resetting the object's shape, perhaps this command just needs to be called internally after rescaling an object. I will put a link to this thread in the main AGK2 blog thread as Paul often looks in there.

DONE

Using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-11-16 18:09:12
Your offset time is: 2024-11-16 18:09:12