Jump to content

GetVertexPosition usage


VeTaL
 Share

Recommended Posts

I didnt find info on the wiki: http://leadwerks.com/wiki/index.php?title=GetVertexPosition&redirect=no

But at least i get syntax info: http://www.leadwerks.com/wiki/index.php?title=Surfaces#GetVertexPosition

 

Also i found my old post, where i asking about this first time: http://leadwerks.com/werkspace/index.php?/topic/1640-access-to-vertex-position/page__p__15160__hl__vec_for_vertex__fromsearch__1#entry15160

 

In 3DGameStudio i can open model in Model EDitor, then select needed vertex (for example, point in hand, where i want to place weapon, or point on the weapon, where i want to place bullet) and then get position in 3d space.

In Leadwerks i saw only

FindChild(m_currentAnimationEntity, "FIRESPOT")

but how can i get the position of firespot without bone, just with vertex coordinates?

 

In the other worlds, how can i get the number of needed vertex in model?

Working on LeaFAQ :)

Link to comment
Share on other sites

Having a bone for the firespot obviously would be the easiest solution, but you could always just create the emitter in front of the gun using the TForm commands or even just create a Pivot that is parented to the front of the gun at the right spot. Using a vertex position for this can be done, but seems like an overkill for what you are trying to accomplish.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

But the center of the gun is not affected by animation, so i would have static spot.

 

I just want to get the coordinates of the bullet-firing point using not bones, but vertexes. But i have no idea how to find number of needed vertex (maybe i need to make little standalone application, where i wound run through all vertexes, highlight current one and cout current number)

Working on LeaFAQ :)

Link to comment
Share on other sites

but thats just it... even with animation you will only be firing the gun when its aiming which also means for all intents and purposes the gun barrel is in one spot consistently... but in any case, finding the vertex is not that hard... there are several useful commands in the wiki that let you pull information about a mesh's vertex...

 

require("Scripts/constants/keycodes")
RegisterAbstractPath("")
Graphics(800, 600)
fw=CreateFramework()
fw.main.camera:SetPosition(Vec3(1, 2, 1))

dlight= CreateDirectionalLight()
dlight:SetRotation(Vec3(45, 60, 30))

mesh = LoadMesh("abstract::oildrum.gmf")
surface = GetSurface(mesh,1)
vertcount = CountVertices(surface)
vertnumber=0
marker = CreateCube()
marker:SetScale(Vec3(.02,.02,.02))
marker:SetColor(Vec4(1,0,0,1))
fw.main.camera:Point(mesh,3,1,0)
fw.renderer:SetWireFrame(1)

while KeyHit(KEY_ESCAPE)==0 do
if KeyHit(KEY_UP)==1 and vertnumber <= vertcount-1 then vertnumber = vertnumber + 1 end
if KeyHit(KEY_DOWN)==1 and vertnumber >= 1 then vertnumber = vertnumber - 1 end
vertpos = GetVertexPosition(surface,vertnumber)
marker:SetPosition(vertpos)
campos=CameraUnproject(fw.main.camera,vertpos)

       fw:Update() 
       fw:Render()

SetBlend(1)
DrawText(vertnumber,campos.x,campos.y)
DrawText("Press UP/DOWN to increase/decrease vertex number",0,20)
DrawText("Number of Vertices: "..vertcount,0,40)
DrawText("Current Vertex Number: "..vertnumber,0,60)
DrawText("Current Vertex Position: "..vertpos.x..","..vertpos.y..","..vertpos.z,0,80)
SetBlend(0)

Flip()
end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...