Sign in to follow this  
HarryDE

[HELP] Create Object on Cursor position

Recommended Posts

Hello. So I'd want to create an object on the cursor position. I have calculated everything, it works fine but there are some objects that do not fit to the calculation. I think the problem can be that the bounding box of this objects are also buggy and I don't know what should I change in my calculation.

Calculation: 

local sx, sy = guiGetScreenSize()
local relX, relY = getCursorPosition()
cursorX, cursorY = relX * sx, relY * sy
local camX, camY, camZ = getCameraMatrix()
local cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ = getWorldFromScreenPosition(cursorX, cursorY, 1000)
local hit, hitX, hitY, hitZ, hitElement, normalX, normalY, normalZ = processLineOfSight(camX, camY, camZ, cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ, true, true, true, true, true, true, false, true)

Picture about it: (The red lines show the bounding box of the object)

40oqDuT.png

Share this post


Link to post
Posted (edited)

The most likely cause is the collision of the bed is exported at around -2 offset. This is typically the case for models found in GTA_INT img archive, I don't know why that is.

I don't know if you're scripting-wise able to center pivot/axis of the collision to the game mesh or if your only option is to remodel the collision. For the latter solution I'm not sure if it's possible to use engineReplaceModel for other archives than gta3. I think not, at least not player.img. @HarryDE

Edited by Tut
added link
  • Like 1

Share this post


Link to post
17 hours ago, Tut said:

The most likely cause is the collision of the bed is exported at around -2 offset. This is typically the case for models found in GTA_INT img archive, I don't know why that is.

I don't know if you're scripting-wise able to center pivot/axis of the collision to the game mesh or if your only option is to remodel the collision. For the latter solution I'm not sure if it's possible to use engineReplaceModel for other archives than gta3. I think not, at least not player.img. @HarryDE

I have checked this function in the map_editor and these object are buggy in the map editor too. 

Is there any possibility to check the "offsets" of these elements? Because then I could just set another offset for this objects.

Share this post


Link to post
Posted (edited)

I can compile a list of offsets if you note the obj names. 
(that is, if it isn't the entirety of interior objs)

Edited by Tut
  • Like 1

Share this post


Link to post
12 hours ago, Tut said:

I can compile a list of offsets if you note the obj names. 
(that is, if it isn't the entirety of interior objs)

I'd appreciate if you could tell me your technique to get these offsets because there are lot of objects that I want to use and it would be a hard work to compile all the offsets. So I would do this hard work instead of you :)

Thanks in advance!

Share this post


Link to post

I have linked a thread to get started with modeling in one of my previous posts. You'll need to load in collisions from base game and center the pivot to collision model in order to see its offsets on the coordinates display. I'll be looking into writing a guide on how exactly to work with collisions and also how to do your process. @HarryDE

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.