how can i detect if a position of a vector is an empty space?

Posted By: Erick_Castro

how can i detect if a position of a vector is an empty space? - 11/28/09 16:18

Guys, suposse i want to create an entity in a x,y,z point
but before that, i would like to know if that specific point is empty, not filled with other entity or wall.

I think it is possible, but for now i dont know how
Posted By: painkiller

Re: how can i detect if a position of a vector is an empty space? - 11/28/09 16:36

you can use:

c_content(VECTOR* pos,var mode)
Checks the block material at the position given by the vector. The instruction returns a value of CONTENT_EMPTY (1) if empty space, CONTENT_PASSABLE (2) if a passable block, or CONTENT_SOLID (3) if a solid block is detected at the given position. Blocks in the level as well as in map entities are detected - but no other entities. You is set to the entity detected at the position, if any.
Posted By: Erick_Castro

Re: how can i detect if a position of a vector is an empty space? - 11/28/09 17:54

Excelent, paint killer.

My idea is to program an entity , for example a floating enemy saucer, that generate in to a room different and random vectors and fly to that random vectors, but test the vectors before the saucer fly to them. In that way, we would have an enemy saucer that can fly free and randomly and realistic because it never impacts any wall for accident, and the player cant predict the next position of the enemy.

Thanks.
Posted By: Widi

Re: how can i detect if a position of a vector is an empty space? - 11/28/09 21:56

From the manual: Don`t use c_content for newer projects...
Posted By: Walori

Re: how can i detect if a position of a vector is an empty space? - 11/28/09 23:03

Quote:
From the manual: Don`t use c_content for newer projects...


this

And even if you would use c_content think it wouldn't really serve its purpose; there still might be entites a bit further from the c_content positon. You should rather make a function that scans a position for a defined radious. THOUGH I can't remember if c_scan detects walls...
Posted By: Erick_Castro

Re: how can i detect if a position of a vector is an empty space? - 11/29/09 00:24

Widi, you are right, better i use c_trace or c_scan to make that.
I will study the way.

Thanks.
Posted By: Jaeger

Re: how can i detect if a position of a vector is an empty space? - 11/29/09 02:04

There's another way, which MIGHT be more efficient than constant scanning. However, I've NEVER done any benchmarking on Lite-C instructions, so I'm not sure how fast/slow (exactly) things are. The manual does give a bit of a guideline though.

What I would do is create a bounding frustrum (invisible) for the point in 3D space I want to monitor and check. That could simply be an invisible primitive (like a cube). Then I'd create an event handler for an object entering its bounds, and object leaving its bounds. The simplest way of handling the event is to set a bool true/false. However, I would take that a step further. I know I can do it in C#, but not sure if you can in Lite-C or even in 3DGS A7 at all... but, I would create a "bit flag" enumeration to get more detailed data about the state.

For example: myEnum ^= StateEnum.Entity;

Yeah, that's C#-ish, but hopefully you catch my drift. I haven't used Lite-C in ages, so I can't give a working example in it. But if these features aren't present, hopefully they shall be SOON! laugh

Note: My example is a bit contrived; and by MY interpretation of the problem you presented. It might be a silly idea if you need to get the state of any arbitrary/random vector3 at any given time. This would just work well for a FIXED position, or one that moves infrequently. If your point will be any random vector3 in 3D space, you'd better use scanning. But if there's any way to use matrices in Lite-C/A7, that would be even better; but I think it shields you from all the underlying DirectX stuff (that I <3, heheh).
Posted By: Erick_Castro

Re: how can i detect if a position of a vector is an empty space? - 11/30/09 12:06

Thank for all your answers , friends.

for now i am thinking to use c-trace and , Jaeger , i will think about to make an idea like yours in Lite-C.

Thanks again.
© 2023 lite-C Forums