XNA Game Development Forums
2012/05/21 19:53:01 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1] 2
  Print  
Author Topic: Tranforming a model's vertices  (Read 6880 times)
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« on: 2007/07/18 14:38:16 »

I recently have integrated a basic physics/collision system into my game engine. At first it was just AABBs and spheres but now i have found a way to integrate actual model-triangle colision, unfortunately if i scale the model, rotate it, or move it i can not get the vertices of the bounds change accordingly, i have tried getting the positions of the vertices and transforming it by the entities world matrix but that doesnt seem to work and when i debug the vertices positions i get values like infinity or -infinity. I got the position of the vertices through my custom model processor and that seems to work fine, so i believe it has to do with the transformation of the vector3's that i use. Are a model's vertices stored an positioned a certain way so that i can transform there coordinates correctly? If you can please help, thank you.
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #1 on: 2007/07/18 15:16:09 »

I imagine the vert's position is relative to the models position so model.Pos + model.vert.pos should give you the actual position of the vert. Just guessing so I may be well off the mark.
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #2 on: 2007/07/18 15:35:57 »

when you say the model position u mean the root bone's transform correct? or are you referring to the mesh's parent bone's one? and if i need to calculate the positions like that how would i integrate scale and rotation?
« Last Edit: 2007/07/18 15:38:03 by DoomMarine » Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #3 on: 2007/07/19 00:45:39 »

I presume you are using the HMEngine and the HMModel object to do this, so I am guessing that you can use the HMModel.Position + the HMModel.Mesh.Verts[v].position to get the correct position of the vert.

Having not seen your code I can only make assumptions...
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #4 on: 2007/07/19 14:09:13 »

heres the code i use to move the triangle's vertex's position
Code:
public void RefreshTris(Matrix world)
        {
            Vertex1 = Vector3.Transform(vertstore1, world); 
            Vertex2 = Vector3.Transform(vertstore2, world); 
            Vertex3 = Vector3.Transform(vertstore3, world); 
        }
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #5 on: 2007/07/19 15:01:12 »

Say you arnt giving much away there....

It looks like you could do with doing this
Code:
    Vertex1 = Vector3.Transform(this.Position + vertstore1, world);

Again, this is an asumption....
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #6 on: 2007/07/19 15:19:45 »

sry bout not giving much away havent decided if i wanted to show everything yet, but the world matrix that i use is made like this
Code:
RefreshTris( RotationMatrix * Matrix.CreateScale(Scaling) * Matrix.CreateTranslation(position), position);
im wondering if thats how it should have been made
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #7 on: 2007/07/20 01:18:58 »

hmm the world matrix looks odd to me.

Mike uses Scale * Rotation * Position
You are using Rotation * Scale * Position

maybe this is your issue??
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #8 on: 2007/07/20 08:47:45 »

ive tried the scale *rotation * position but that doesnt seem to be making a difference, i wonder if it is how i get the vertices positions that my be the problem. To get the vertices positions i have a binary reader read the models data from a memory stream, should i be using something else?
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #9 on: 2007/07/20 11:40:32 »

Not that I know where, but in the Refresh don't they give you access to the mesh verts as standard now?
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #10 on: 2007/07/20 12:18:54 »

wow, lol, i did not know that, ill check that out now
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #11 on: 2007/07/20 13:56:10 »

it doesnt seem to make a difference i am still gettin screwed up collision but the tri's points seem to be fine, it might have something to do with my triangles collision so ill check that out next
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #12 on: 2007/07/20 15:11:18 »

not the collision either so it must be the transformation of the vertices, are the vertices already transofrm to the mesh's parent bone transform?
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #13 on: 2007/07/20 15:41:57 »

I don't know, one way to find out would be to remove the transform code you have and try it with out...
Logged
DoomMarine
Newbie
*
Offline Offline

Posts: 24


View Profile
« Reply #14 on: 2007/07/23 10:28:17 »

now the vertices positions seem to screw up the collision, i am getting very strange results from it, how exactly are you supposed to get the vertices data from the model? i used the getdata function for the index and vertex buffers but i wasnt to sure on how to get the total amount for the array that i use to store the data, if you can help with this it will be appreciated
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Tut 6: Model Class Hazy Mind XNA Engine MicahN 2 2258 Last post 2006/11/15 09:43:47
by MicahN
Tutorial 6 :: Getting a Model on Screen Tutorial Discussion mikeschuld 11 5587 Last post 2007/02/18 10:35:28
by Iarus
How To: Render a model with a texture?? Hazy Mind XNA Engine Quinn 6 2324 Last post 2007/01/07 00:33:58
by mikeschuld
Detecting Model Collision...? General Discussion « 1 2 » DaphydTheBard 15 4291 Last post 2007/03/27 01:29:52
by Nemo Krad
I can't see anything on tutorial 4 More Rendering, Vertices and Indexes Hazy Mind 3D Engine moonsvista 5 2906 Last post 2007/03/30 14:37:05
by moonsvista
Model & Shader Problems Hazy Mind XNA Engine Themodem 5 2070 Last post 2007/03/26 11:12:53
by Tiago
Model exporters General Discussion EclipsE 13 3719 Last post 2007/04/26 12:25:03
by EclipsE
Loading a model in runtime? General Discussion XNASorcerer 10 3311 Last post 2007/05/06 21:22:42
by XNASorcerer
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.207 seconds with 19 queries.