GetTerrainTexture(%pos)
by Nicolai Dutka · in Torque Game Engine · 10/05/2007 (5:35 pm) · 6 replies
I would like to be able to do the function I used as my thread topic. Can anyone teach me how?
I want the name of the terrain texture at the player's position.
I want the name of the terrain texture at the player's position.
#2
11/27/2007 (9:02 am)
Take a look at getHeight () inside terrData.cpp. You can easily make a similiar function which does what you want.
#3
11/27/2007 (9:11 am)
Can I assume you mean 'terrData.cc'?
#4
11/27/2007 (9:23 am)
I am looking in the terrData.cc file at the 'bool TerrainBlock::getHeight(const Point2F &pos, F32 *height)'. I really don't know what to do with this. I haven't had any formal training in C++. In class, we learned some basic Torque Script (enough to build a standard game), but I don't know much at all about C++. I know enough to read this 'getHeight' and get a vague understanding of what is going on, but I have no idea how to re-write it so it is useable IN SCRIPT to be able to do a 'getTerrainTexture(%pos)'.
#5
Unfortunately, it is quite a bit harder to get the texture. Instead of calling some simple function to get the height, you need to get the material alphas at your point. It is because you have 4 or 6 or more textures on your map, and each is blended onto the terrain. You might have 25% of texture 1, 25% of texture 2 and 50% of texture 3.
I cannot remember the functions off the top of my head, but you can get the terrain square you are standing on and then the "alpha" values for each texture. Your "getTerrainTexture" function will need to return as many values as you have textures on your terrain.
Unfortunately, again, without a lot of C++ experience, you'll have a hard time adding this capability.
11/27/2007 (10:16 am)
What you really want to look at is the ConsoleFunction getTerrainHeight (in terrData.cc). You need to copy this function to make another called getTerrainTexture.Unfortunately, it is quite a bit harder to get the texture. Instead of calling some simple function to get the height, you need to get the material alphas at your point. It is because you have 4 or 6 or more textures on your map, and each is blended onto the terrain. You might have 25% of texture 1, 25% of texture 2 and 50% of texture 3.
I cannot remember the functions off the top of my head, but you can get the terrain square you are standing on and then the "alpha" values for each texture. Your "getTerrainTexture" function will need to return as many values as you have textures on your terrain.
Unfortunately, again, without a lot of C++ experience, you'll have a hard time adding this capability.
#6
I am wondering what other possible solutions people have come up with for things like:
1. A car driving a race track. Each wheel gets the texture that IT is "on" to determine traction amount.
2. A player wandering a "Final Fantasy Style World Map" with random battles wants to ONLY fight creatures that would be found in the terrain they are standing on. (So standing on the beach gives you a turtle but standing in the woods gives you a wolf).
I guess this could be done with triggers, but that seems like a TON of work placing all those triggers and getting them to line up exactly with the terrain textures (and not overlap eachother). Especially number 2 where you'd have to place triggers over every bit of "walkable" terrain... UGH!
11/27/2007 (10:28 am)
I do have help from a very knowledgable C++ instructor, but I can see the issue with blended textures is going to be a pain in the butt.I am wondering what other possible solutions people have come up with for things like:
1. A car driving a race track. Each wheel gets the texture that IT is "on" to determine traction amount.
2. A player wandering a "Final Fantasy Style World Map" with random battles wants to ONLY fight creatures that would be found in the terrain they are standing on. (So standing on the beach gives you a turtle but standing in the woods gives you a wolf).
I guess this could be done with triggers, but that seems like a TON of work placing all those triggers and getting them to line up exactly with the terrain textures (and not overlap eachother). Especially number 2 where you'd have to place triggers over every bit of "walkable" terrain... UGH!
Torque 3D Owner Nicolai Dutka