UE3 - UT3 Accessing the pixel values of a texture

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Okke

New Member
Jan 18, 2010
5
0
0
Hi,

Maybe you are aware of the USARSim 'mod' for UT3 which uses the UT3 engine for a robotics simulation environment for the Urban Search And Rescue competition at RoboCup (http://www.robocup2010.org/competition_Category.php?c=2). In this competition, a team of autonomous robots (not cyborgs, but robots that are 'boringly real life') needs to find it's way through unknown territory to aid rescue teams. They do this by creating maps of the environment, locating victims and navigating dangerous terrain.

I am working on a Masters' project at the University of Amsterdam. Our project is to add smoke and fire to the simulation. We keep alogbook at http://code.google.com/p/usarsim-smoke-fire/ . In unreal, there are many ways to visually create smoke and fire (particle systems, different fogs, etc). Most robots in the simulation do not really use the visual feedback from UT, but 'see' through e.g. laser beams that they send out, like they do in real life.

Now the problem:

To have the different sensors interact with the smoke in a realistic way, I want to load a texture to memory, and request specific pixel values from that texture, like 'the pixel at (20,30)' or 'the pixel at (431,425)'.

I do not want to render the texture, just get specific pixel values from it. Is there any way to do so? I have looked through all Texture-related unreal code files, but couldn't find something like that. There was nothing in the forums either.

Thanks,
 
Last edited:

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
No, it's not possible as far as I know. The closest thing would be taking a screenshot and analyzing it externally, then feeding the results back into the game via a TcpLink.
 

Okke

New Member
Jan 18, 2010
5
0
0
Wormbo, thanks for the quick reply.

It's not necessarily a texture that I want to retrieve. Is it maybe possible to load a reasonably large array of floats from a file or something like that? That would be good enough too.

Otherwise, I'll generate a 'texture' on the fly using a combination of sinusoids.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Indeed. While individual lines should not exceed 1024 chars, the number of lines is not limited. Config variables declared as array<type> are stored as one line per array element in config files. That's not very space efficient though, and every INI file is only read once when the first class referencing it is loaded. Subsequent changes to the INI file might not have any effect in the game.
 

Okke

New Member
Jan 18, 2010
5
0
0
Thanks guys!

I've decided not to store too many values, I'm generating my data by overlaying a number of randomized sine functions and letting them move by time.

I'm running into another problem. We create smoke by using a fog volume (bound to a mesh which collides with weapons). I check to see if the laser runs into this mesh by doing a Trace(). However, if the trace starts INSIDE the fog volume, it immediately hits the fog and returns the position from which the trace originated.

I need to know how far the fog volume extends in the direction of the trace.

Let's say this is the fog volume , seen from above:

Code:
.---------.
|         |
|  X----->|
|         |
'---------'

The X is where my trace starts. The arrow shows what I would like to measure: the distance to the boundary of the fog volume.

I do have a ugly solution: disable the collision on the fog, run a new trace, see what we hit. Then, enable the collision on the fog, run a trace from the hit object in the reverse direction. If we hit something halfway, it's the boundary of the fog.
Code:
The trace from X immediately hits the fog.
.---------.
|         |  %
|  X>     |  %
|         |  %
'---------'

Disable the collision with the fog, to see what would be hit if the fog was not there (A wall! '%')

 - - - - -
|         |  %
   X-------->%
|         |  %
 - - - - - 

Re-enable the collision of the fog, and trace from the previous hit location in reverse direction
.---------.
|         |  %
|  X      |<-%
|         |  %
'---------'

Aaaand we have the location (and subsequently, distance) we were looking for!

I'm afraid disabling the collision and enabling it again is too slow, as I'm running up to thousands of traces per second. It also does not seem right to do it this way, isn't there a more elegant solution?
 
Last edited:

Okke

New Member
Jan 18, 2010
5
0
0
The problem was the following (ignore the blue lines)

RegionalMeshCollision.PNG


We solved it:

FixedCollisionFromInside.PNG


We had to make sure the collision box both surrounds the static mesh perfectly in the unreal static mesh editor and that the option UseSimpleLineCollision is NOT checked.

The building blocks are there, now we "just" have to implement the right behavior :)
 
Last edited:

Okke

New Member
Jan 18, 2010
5
0
0
And just for fun, we did an experiment friday at the firemen's training center at the Schipho airport. Here are the pictures:

http://staff.science.uva.nl/~arnoud/research/roboresc/RoboCup2010/bocas/

[screenshot]http://staff.science.uva.nl/~arnoud/research/roboresc/RoboCup2010/bocas/DSC02439.JPG[/screenshot]

The guy in the middle is me, the other two are Nick and Sander (sander posted on this forum too with a question I think)
 
Last edited by a moderator: