Page 1 of 1

Texturing to match object size

Posted: Thu Mar 22, 2018 2:59 am
by Zehra
Hi all

I'm currently working on some texturing for an object, but I've noticed the texture pattern repeats or stretches oddly.
I currently would like it to use the texture and have it be the size of the object.
So the size of the texture does not matter, just the way it renders it.

Like if I create a box being 2x2, the texture is increased/decreased in size to be 2x2.(So it does not repeat.)
The textures do not appeared to be centered most of the time as well.
If someone could shed some light on how to center the textures and have them scale to the objects size, it would be much appreciated.
(Examples would be highly appreciated too.)

-Zehra

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 3:12 am
by JeffM
Define the object as a mesh not a box (and no, not a mesh box a real mesh) and define your own UV coordinates. All automatic texture mapping’s will repeat.

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 3:16 am
by Zehra
Creating meshes requires use of a 3D editor, and I haven't been able to successfully use one.
(Blender and Wings3D are pretty confusing.)

-Zehra

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 3:56 am
by JeffM
That is the easiest way, but you can code them by hand too.

But you have to uses a mesh to get what you want. That what meshes are for, tota control over geometry and texture placement.

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 4:17 pm
by Zehra
Creating a mesh with a 3D editor or writing it by hand is not a solution for me.
(I'd be making some really nice mesh maps, if I could do meshes.)
I also don't want textures repeating, just them to match the size of the object by scaling up or down.(Increasing or decreasing in size.)

I was sort of hoping for a very simple way of having it scale or adjust to the size of the object.
Mostly the idea was to have some textured meshboxes and not have repeating textures.
(The texture increases/decreases in size to match the meshbox.)

-Zehra

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 4:48 pm
by JeffM
What you are hoping for does not exist. The feature to support what you want is implemented in bzflag as meshes....
There is no "Secret" other way. I know, I developed some of the code.

Meshes are how people do billboards. They aren't that hard, just go learn a little.

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 4:53 pm
by Zehra
If there only was a good, simple to use mesh editor...
JeffM wrote: Thu Jun 25, 2009 5:04 pm The blender tools are probably the most complete "2.0" editing solution, but blender does have a bit of a learning curve. It is not too hard for modelers to make maps, but it seems to be rather difficult for mappers to learn how to model. There is a level of detail and knowledge that is required to use blender that most mappers have never had to worry about before.
Edit: Sadly, I'm not a modeler learning to make maps.

-Zehra

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 5:11 pm
by JeffM
Dude, making a cube is trivial, just TRY a little.

Code: Select all


material
	name cube
	texture bzflag-256x256
end

mesh

  vertex -0.500000 -0.500000 1.000000
  vertex 0.500000 -0.500000 1.000000
  vertex -0.500000 0.500000 1.000000
  vertex 0.500000 0.500000 1.000000
  vertex -0.500000 0.500000 0.000000
  vertex 0.500000 0.500000 0.000000
  vertex -0.500000 -0.500000 0.000000
  vertex 0.500000 -0.500000 0.000000
  
  normal 0.000000 0.000000 1.000000
  normal 0.000000 1.000000 0.000000
  normal 0.000000 0.000000 -1.000000
  normal 0.000000 -1.000000 0.000000
  normal 1.000000 0.000000 0.000000
  normal -1.000000 0.000000 0.000000
  
  texcoord 0.000000 0.000000
  texcoord 1.000000 0.000000
  texcoord 0.000000 1.000000
  texcoord 1.000000 1.000000
  
  face
    vertices 0 1 2
    normals 0 0 0
    texcoords 0 1 2
    matref cube
  endface
  face
    vertices 2 1 3
    normals 0 0 0
    texcoords 2 1 3
    matref cube
  endface
  face
    vertices 2 3 4
    normals 1 1 1
    texcoords 0 1 2
    matref cube
  endface
  face
    vertices 4 3 5
    normals 1 1 1
    texcoords 2 1 3
    matref cube
  endface
  face
    vertices 4 5 6
    normals 2 2 2
    texcoords 3 2 1
    matref cube
  endface
  face
    vertices 6 5 7
    normals 2 2 2
    texcoords 1 2 0
    matref cube
  endface
  face
    vertices 6 7 0
    normals 3 3 3
    texcoords 0 1 2
    matref cube
  endface
  face
    vertices 0 7 1
    normals 3 3 3
    texcoords 2 1 3
    matref cube
  endface
  face
    vertices 1 7 3
    normals 4 4 4
    texcoords 0 1 2
    matref cube
  endface
  face
    vertices 3 7 5
    normals 4 4 4
    texcoords 2 1 3
    matref cube
  endface
  face
    vertices 6 0 4
    normals 5 5 5
    texcoords 0 1 2
    matref cube
  endface
  face
    vertices 4 0 2
    normals 5 5 5
    texcoords 2 1 3
    matref cube
  endface
end

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 5:26 pm
by blast
Tried adding "texsize 1 1" to your box object?

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 5:42 pm
by Zehra
Thank you very much blast, it works now.

-Zehra

Re: Texturing to match object size

Posted: Thu Mar 22, 2018 6:04 pm
by JeffM
Yeah, I was totally wrong, sorry about that. There is an object class called meshedbox that I missed. it's not in the map format but triggered when a legacy paremetric object is given material properties.

this works like you expect

Code: Select all


material
	name cube
	texture bzflag-256x256
end

box
	postion 0,0,0
	size 1,1,1
	rotation 0
	matref cube
	texsize 1 1
end


Re: Texturing to match object size

Posted: Thu Mar 22, 2018 6:30 pm
by Zehra
No problem Jeff.
I guess my search into meshboxes left me overlooking boxes, which had the solution I was looking for. :doh:

-Zehra

Re: Texturing to match object size

Posted: Sun Mar 25, 2018 2:10 am
by optic delusion
You can also do this with a "fixedscale" texture matrix.
If you do that, you should know that by default, textures repeat every 8 units.

Code that Trepan had prepared but never made it into official source had this material option.
texautoscale 8 8 # world view generated texcoord scales

Re: Texturing to match object size

Posted: Mon Mar 26, 2018 11:18 pm
by Zehra
@Optic Delusion

I tried "fixscale", but it seems it isn't working.

Code: Select all

options
 -set _worldSize 100
end

textureMatrix
  name example_texmat
  fixedscale 0.0 0.0
end

material
 name example_material
 texture std_ground
 texmat example_texmat
end

meshbox
 position 0 0 0
 size 2 2 4
 matref example_material
end
I've tried a few other options, but can't seem to get the textures to do what this does.

Code: Select all

options
 -set _worldSize 100
end

material
name test
texture std_ground
end

box
  position 0 0 0
  rotation 0
  size 2 2 4
  texsize 1 1
  matref test
end
-Zehra

Re: Texturing to match object size

Posted: Mon Mar 26, 2018 11:23 pm
by optic delusion
fixedscale 0 0 doesn't look right to me, try fixedscale 2 2

but i guess you've already found your solution with texsize

Re: Texturing to match object size

Posted: Tue Mar 27, 2018 1:30 am
by Zehra
Thanks Optic, it seems to work fine with fixedscale 2 2.

-Zehra