AlignToVector

Blitz3D Forums/Blitz3D Programming/AlignToVector

Yue(Posted 2016) [#1]
What really makes this command. I appreciate a simple example.


Zethrax(Posted 2016) [#2]
There's some examples at the link below.

http://www.blitzbasic.com/b3ddocs/command.php?name=AlignToVector&ref=3d_cat


Yue(Posted 2016) [#3]


Graphics3D ( 800, 600, 32, 2 )
SetBuffer (BackBuffer())



Local camera% 	= CreateCamera()
Local cube1%	= CreateCube()
Local cube2%    = CreateCube()
Local light%    = CreateLight()

PositionEntity 	( cube1%, 0, 0, 10 )
PositionEntity 	( cube2%, 0, 0, 5 )
EntityAlpha cube1%, .5

Local x#, y#, z#

While KeyDown(1) = False 
	
	
	If KeyDown(200) TranslateEntity ( cube2%, 0, 0, .1 ) 
		If KeyDown(208) TranslateEntity ( cube2%, 0, 0, -.1 )
			If KeyDown(203) TranslateEntity ( cube2%, -.1, 0, 0 ) 
				If KeyDown(205) TranslateEntity ( cube2%, .1, 0, 0 )	
			
	
	x# = EntityX( cube2% )
	y# = EntityY( cube2% )
	z# = EntityZ( cube2% )
	
	AlignToVector ( cube1%, x#, y#, z#,0,1)
	
	UpdateWorld
	RenderWorld 
	Flip
	
Wend 



Sorry , I do not speak English , I think I need something more simple to understand .

In this case , I see that the organization is aligned with the other, and this is very similar to PointEntity , in this case , this lines up with another entity ?


RemiD(Posted 2016) [#4]
As i understand it, AlignToVector will align an entity according to a vector, on one specified axis (x,y,z).

This is usually used to align an entity on a terrain (the normal of a triangle of a terrain is a vector), or a decal (example : a bullet hole) on a wall (the normal of a triangle of a wall is a vector)...

You seem to have already used this in your project with the robot on mars, when you align the tracks of the tires according to the terrain relief.


Yue(Posted 2016) [#5]
What mde Mars Project , unfortunately a lot of code is copied and pasted , but not understood , so I want to understand this.


Kryzon(Posted 2016) [#6]
Try this:
http://www.blitzbasic.com/Community/posts.php?topic=98358#1148878

AlignToVector rotates the entity so that one of its axes (that you choose as the 'axis' parameter) is aligned with (becomes parallel to) the vector you provided.
The vector you provide is a direction in 3D space. (EDIT: it's actually more than that, but it's simpler to imagine it as just a direction.)


Yue(Posted 2016) [#7]
@Kryzon
Thanks You.





Try again to understand these commands transformations .


Rick Nasher(Posted 2016) [#8]
See:


aligntovector to create bullet holes using sprites..bb


AlignToVector To guide a missile towards a moving target.bb



Yue(Posted 2016) [#9]


I think I'm about to learn something, as happened when I discovered TFormPoint operation.

Then after the image of our friend Kryzon, a vector is a line that runs from the side of a polygon, this line or vector marks the angle looking side, in this case if we have a cube, each side we have two vectors normal for each triangle of the face, and two pointing left (-1) two others point to the right (1), and the same for the top and bottom.

When using this AlignToVector command, what I want is to know the angle at which point these vectors, I repeat myself based on the image, and this will have to do for example with PickedNX, CollisionNX, etc commands, where N tells me is a vector of normal, which is not normal, I think it's the same as a vector.

I'm right ?, in this case when two bodies collide, for example with the CollisionNX command, I can find the angle of rotation of the normal vector and paste a sticker of a shot on the object that receives the collision.

I am right?...


RemiD(Posted 2016) [#10]

a vector is a line that runs from the side of a polygon


No, this would be a normal. But a normal is a normalized vector.

A vector is a line with a start point and an end point, which has a direction and a length.

A normal is a normalized vector (which means that the length is always 1.0), and is used to shows a direction. (Where the triangle looks at, to where it faces)

For collisions, a collided normal vector is useful if you want to calculate a "reflection angle", like with pool or marbles.

For movements, a vector is useful to translate an entity in the world, for example i have made a spaceship exploration/fighting game prototype in which the spaceship turns/moves with angularvelocities and linearvelocities, similarly to a body in a physics engine.

Vectors are also used to calculate lighting/shading of the vertices or of the texels in an environment. ("vertexlighting" or "texellighting" (also know as "lightmapping"))


Yue(Posted 2016) [#11]
@RemiD

You have given me the respuesto why never do a video game. I think it's time ebandonar this and keep what if I can do .


The translator is not much help .


Rick Nasher(Posted 2016) [#12]
This might be helpful:
CREATING AND USING NORMAL MAPS - A Tutorial


RemiD(Posted 2016) [#13]
(maybe it is my english that is bad and not understood by the translator !)


Yue(Posted 2016) [#14]




These are normal two vectors?


Rick Nasher(Posted 2016) [#15]
Hmm, never heard of that, but I'm not an expert on this too."Learning all the time.."( as Benny Hill would say). That probably only applies when a surface has a backface(please correct me if I'm wrong).


RemiD(Posted 2016) [#16]
With Blitz3d (or maybe it is a directx 7 thing) the normal is a normalized vector perpendicular to the "frontface" of the triangle.

If you try to light a backface you will see how the vertices lighting is not calculated properly on the backface... So i suppose that the considered normal is the one of the frontface.


Yue(Posted 2016) [#17]





Trying to understand the concept of vector.


A vector is a line that is perpendicular to another vector in a plane, or a polygon , or a triangle ?


Yue(Posted 2016) [#18]
Vector:

Definition: In a 3D space , a vector is a segment of a straight line placed at any point in a certain direction.



Normal.


Definition : A normal is a vector that is perpendicular to a polygon .


Definition: A normal is a vector perpendicular to any polygon .

Perpendicular.




So this shows me that AlignToVector command , aligns the axes of an entity with the axes of another entity , in this case a normal shaft alignment for example a stain sprite of a bullet in a building vector.

:)

Thanks You Guys.