Naming meshes(?) for animation in xna and how to colour models

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Naming meshes(?) for animation in xna and how to colour models // Game Development

1  |  

Post by dom96 // Aug 22, 2008, 5:26am

dom96
Total Posts: 18
Hello everybody i'm very new to 3d game programming and to truespace, and if somebody could help me with naming meshes(or vertices whatever it's called) for animation in xna, just like in the SimpleAnimation sample (http://creators.xna.com/en-us/sample/simpleanimation) and how do i colour the models, do i need to texture them with an image in xna ?

P.S i'm trying to make an FPS(First Person Shooter) game, and i want the gun to be animated for example when you shoot it goes up a bit, and reload animation would be cool too


well anyway thanks in advance for all the replies

dom96

Post by TomG // Aug 22, 2008, 5:46am

TomG
Total Posts: 3397
You need to ensure all objects are uniquely named to access them like in SimpleAnimation - it's not enough that an object is inside a group with a unique name.


So a group "FrontWheels" and group "BackWheels" - "Wheel1" inside the first group will cause an error if there is a "Wheel1" inside the second group too, as XNA will just see this as 2 "Wheel1" objects, ignoring the higher grouping name. So you'd need to call them "FWheel1" and "BWheel1" say.


For colors, most likely you'd need to apply a texture map. You could try exporting plain color and see if it works, if not, just UV map and export.


HTH!

Tom

Post by dom96 // Aug 22, 2008, 6:41am

dom96
Total Posts: 18
You need to ensure all objects are uniquely named to access them like in SimpleAnimation - it's not enough that an object is inside a group with a unique name.


So a group "FrontWheels" and group "BackWheels" - "Wheel1" inside the first group will cause an error if there is a "Wheel1" inside the second group too, as XNA will just see this as 2 "Wheel1" objects, ignoring the higher grouping name. So you'd need to call them "FWheel1" and "BWheel1" say.


For colors, most likely you'd need to apply a texture map. You could try exporting plain color and see if it works, if not, just UV map and export.


HTH!

Tom

how do i do all of those things ?, as i said i'm a real newbie

Post by TomG // Aug 22, 2008, 8:26am

TomG
Total Posts: 3397
Select the object in workspace - in the bottom right is the object info box, you can type in a name for the object there in the Name field.


Or open the Link Editor (LE) and select an object, click and hold on top left of the object in the LE and choose the Rename option (see manual about manipulating and naming objects in the LE, or some of the video courses like Procedural Animation).


You'll need to do this for each object. It is usually best to name the objects as you create them, much easier than going through later and renaming them!


For applying a color or texture map, refer to the manual on using the Material Editor (workspace preferably though you could go to using the Modeler side one if you wanted, in which case see the manual section on the Modeler Material Editor instead :) ).


HTH!

Tom

Post by dom96 // Aug 22, 2008, 9:02am

dom96
Total Posts: 18
yeah but that renames the whole object, for example i create a cube i select a side of it and rename it to left, then i select a different side and name it top and it renames the whole cube not one side, i don't get it:confused:, am i suppose to create a model with cubes and spheres etc. without for example resizing the cube:confused:

EDIT:For example i can make something like this out of a cube
http://maddogsoftware.web44.net/screenshot86.png
i can't rename invidual sides of this cube

Post by ghost--scout // Aug 22, 2008, 9:20am

ghost--scout
Total Posts: 85
pic
Anything you make out of one cube, sphere, cylinder, etc is considered one object and you name it as a whole, not by the face. If you made, say, a block shaped head and put it on top of a cylinder shaped neck, you would have two objects: the cube head and the cylinder neck. If making a car you could have the body as one object, the front right tire, back right tire, front left tire, back left tire, meaning you have 5 objects. Just make sure when you create the primitive shape in workspace that you rename it as you go, so you don't lose track of it later and have to sift through multiple cubes to find it. TomG explained how to do this in the info box and in the LE (Link Editor) so I won't beat a dead horse. I hope this helps and welcome to the forums and Truespace!

Post by TomG // Aug 22, 2008, 9:26am

TomG
Total Posts: 3397
You can't name individual sides or vertices or edges in tS, and neither do you need to for XNA. Let's take a truck with four wheels - you use four cylinders one for each wheel, and one cube for the body. You group the two front wheels together, and the two back wheels together (so they can turn and rotate together). Then you group the body and the two wheel groups.


You must uniquely name the cube, the front wheel group, the back wheel group, and each of the four wheels. You can then refer to those components of the object in XNA as SimpleAnimation does with the tank components, and make those components change position, rotation, size, etc, using XNA commands.


You would not access individual faces in XNA to animate, just these complete, solid objects or groups of objects. This means naming them in tS is not necessary (as well as not possible) for what you want to achieve.


For your gun going up a bit, you would just move the whole gun object in XNA, changing the position of "Gun" (if you named it that). For a reload, you may have some separate sub-object that would slide back and forward again, changing the position in XNA of "Breech" or whataver you called that part, inside the draw routines for the "Gun" object.


HTH!

Tom


PS - if you modeled them all out of one object ratehr than a cube and four cylinders, you would not be able to access and animate them using the SimpleAnimation approach; same with your gun, you would need to create a separate model for each moving part, grouping it into one overall gun, otherwise the SimpleAnimation approach would fail.

Post by dom96 // Aug 22, 2008, 9:43am

dom96
Total Posts: 18
oh right, i thought that you make models with invidual cubes etc.....

and the gun i didn't even model it i found a sample on the internet of a FirstPeron Camera with the gun , the gun is unfortunately a .fbx file so i can't edit it in truespace, or maybe i'm doing something wrong , well anyway thanks for your help and thanks for the kind wlecome, i'll try my best on making a gun

ps is there anyway to select a whole shape not selecting invidual sides with ctrl and click ?


EDIT: ok now i'm very confused, i created two cubes, i click on ones side name it gun then i click the others name it handle and then click the other and it's named handle.... what is going on ?

Post by TomG // Aug 22, 2008, 10:12am

TomG
Total Posts: 3397
You'd need to post the scene for us to say what is going on. If you were in PE mode when you added the second cube, it will be added as part of the first. If you have grouped them using encapsulate, you might be naming the whole object (in which case you have to go into the hierarchy to name them using the keyboard arrow keys if in the 3D window, or using the Link Editor). Sharing the scene would help us know what the situation was :)


Do this


1. Create cube


2. Create second cube


3. Select first cube, change its name eg Gun


4. Select second cube (ensure the name in the Object info window is just "Cube,2" or similar). Change its name eg Handle


5. Select first cube again, Object info window should now show Gun (or whatever name you chose).


6. Select second, Object info should now show Handle



If you do any point editing, booleaning or encapsulating after creating the cubes and before naming them, then this workflow will need to be different. But following the above lets you name each as you create it.


HTH!

Tom



PS - You can select all faces via several mechanisms, but dont need to select faces to name the object; in fact you shouldn't be in Point Edit mode for naming the object, only for moving around edges, faces and vertices. You can use rectangle tool, click and drag to select all (ensure All Faces and not Front Faces is enabled). Or you can select by material. Check manual for information on how to select parts (and all) of an object.

Post by dom96 // Aug 22, 2008, 10:43am

dom96
Total Posts: 18
http://maddogsoftware.web44.net/screenshot.jpg
http://maddogsoftware.web44.net/screenshot1.jpg
see there both named "Cube" and btw how do you access point edit mode and the link editor ?

PS sorry for the large image

Post by TomG // Aug 22, 2008, 5:52pm

TomG
Total Posts: 3397
You are in Point Edit mode with these meshes, as you are showing a green face selected for them. You access point edit mode either by right clicking with the mouse, or choosing "face select" or similar from the PE tools.


To just select a whole object, use the Object Select tool (looks like a plain white arrow). This will place a widget next to the object, but will not highlight any faces in green.


Naming while in PE mode could well be non-functional, since you can't name faces etc. Also adding a second cube while in PE mode will actually add it as part of the selected cube, not add it as a second cube (making it impossible to name it separately).


HTH!

Tom

Post by dom96 // Aug 23, 2008, 2:41am

dom96
Total Posts: 18
Thanks a lot that works great

Post by dom96 // Aug 23, 2008, 5:40am

dom96
Total Posts: 18
can i ask for one last help ?, i'm still not sure about texturing/colouring and can't really find anything in the manual, so if you or anybody could help me i would be very greatful

btw i got the simple animation to work(with a truck) but the truck is white

Post by dom96 // Aug 23, 2008, 3:22pm

dom96
Total Posts: 18
please anybody how do i colour or colour with a texture my model ?

Post by dom96 // Aug 24, 2008, 1:44pm

dom96
Total Posts: 18
please anybody ? help me with coloring or texturing in truespace or at least give me a link to a manual or something

Post by TomG // Aug 25, 2008, 2:29am

TomG
Total Posts: 3397
You need to use the Material Editor and the material painting tools. Easiest way is to use Plain Color shaders and Paint Face to paint parts of the model different colors.


The section of the manual on the Material Editor will be the one to read. Once you get more advanced, you can get to using Texture Maps, especially when you want to export to other apps as plain color shaders may or may not export.


Texturing is a huge subject, best to read the manual, try it out, and ask specific questions as you go along, as whole books could be written about it :)


HTH!

Tom

Post by dom96 // Aug 25, 2008, 2:39am

dom96
Total Posts: 18
ok, but which chapter do i read, couse there is like 12 plus the "Appendix" or something, and i don't know in which one it is , i'll try to find the correct one but if you told me which one is it it would be a great help.

btw i found a gun texture(picture jpg) and added it to the library, i drag it over a cube and it doesn't work why the other textures seem to work ?

Post by TomG // Aug 25, 2008, 3:00am

TomG
Total Posts: 3397
Chapter 5 and 6, the Surfacing chapters.


HTH!

Tom

Post by dom96 // Aug 26, 2008, 5:09am

dom96
Total Posts: 18
,thanks a lot again, ok i learned how to texture cubes etc. and now i would like to make a gun but where do i start, is there any good tutorials on how to make a gun, or is there anyway i can trace the texture(so that the model is exactly the same as the texture?)

Post by TomG // Aug 26, 2008, 5:39am

TomG
Total Posts: 3397
See Jack's Organic Modeling course on how to set up planes with textures on and use those as the template to make the model.


http://www.caligari.com/products/trueSpace/ts5/Courses/WorkspaceOrganicModeling1.asp?Cate=Training&Subcate=Fundamental


Thanks!

Tom

Post by dom96 // Sep 8, 2008, 9:12am

dom96
Total Posts: 18
i created a knife, i'm very happy with it but the .x exporter doesn't export the textures, how do i fix that ??

here are the screenshot's ....

this is how it's suppose to look like

http://maddogsoftware.web44.net/screenshot36.jpg

and this is how it looks like in xna...

http://maddogsoftware.web44.net/screenshot37.jpg

and here is my DrawModel method in xna:


private void DrawModel(Model m)

{

Matrix[] transforms = new Matrix[m.Bones.Count];

float aspectRatio = graphics.GraphicsDevice.Viewport.Width / graphics.GraphicsDevice.Viewport.Height;

m.CopyAbsoluteBoneTransformsTo(transforms);

float fieldOfView = MathHelper.ToRadians(45.0f);

Matrix projection = Matrix.CreatePerspectiveFieldOfView(fieldOfView,

aspectRatio, 10.0f, 10000.0f);

Matrix view = Matrix.CreateLookAt(new Vector3(20.0f, 20.0f, Zoom), Vector3.Zero, Vector3.Up);


foreach (ModelMesh mesh in m.Meshes)

{

foreach (BasicEffect effect in mesh.Effects)

{

effect.EnableDefaultLighting();



effect.TextureEnabled = true;



//// Begin to render with the specified texture

//effect.Texture = textures[currentTexture];



effect.View = view;

effect.Projection = projection;

effect.World = MyWorldRotation * transforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(Position);

}

mesh.Draw();

}

}

btw. why do you have to select EVERY single part of the model in truespace for it to actually export ??

Post by TomG // Sep 8, 2008, 11:26am

TomG
Total Posts: 3397
It will export the textures - you need to be sure to include them in your content pipeline in your XNA build though, plus be sure they are in the right directory.


Not sure on what you mean about selecting every part of a tS model. The X exporter only exports one model. If you build something as separate parts, simply glue them together using the Glue tools (model side) or Encapsulate tools (workspace side), or use booleans to permanently weld them together. You can then export that as one model, just by selecting it and using the exporter, so it's a one click operation, no need to be selecting all the different parts.


If you don't make them into one model, you'd have to select each part separately and export it separately, and then load each separately in XNA.


HTH!

Tom

Post by dom96 // Sep 8, 2008, 12:07pm

dom96
Total Posts: 18
it doesn't export the textures for me, it only saves the file(i have the "Copy textures" checkbox checked)


i didn't know anything about the glue thing, i'll see how it works

but the most anoyying thing is that it doesn't export the texture

Post by TomG // Sep 9, 2008, 1:21am

TomG
Total Posts: 3397
Can you give some more details about the scene, object, texture and results? It works here, if I save an object called "Cube" and use copy textures, then all textures are placed in a sub-folder called Cube.


Eg I save Cube to C:\XNAObjects and I get C:\XNAObjects\Cube.x, and C:\XNAObjects\Cube\texture.jpg.


I can then move those textures accordingly to be in the right place for loading into XNA by importing them via the XNA content pipeline (which is the same folder as the X format model, not in a sub-folder any more, or that's what I use, eg C:\XNA_Projects\Project1\Content\Models\Cube.x and C:\XNA_Projects\Project1\Content\Models\texture.jp g).


Let me know what is happening with your set-up though.


HTH!

Tom

Post by dom96 // Sep 9, 2008, 5:12am

dom96
Total Posts: 18
i added my knife as an attachment, and there should be only one texture included in the export,the handle texture

Post by TomG // Sep 9, 2008, 5:47am

TomG
Total Posts: 3397
Aha, I can see the problem - you've used a sophisticated real-time shader for the handle - these are specific to the tS render engine and can't be exported, the X format exporter likely doesn't know what to do with it so just uses a default material with no texture.


When planning to export (to another app, game engine, Virtual Earth, etc) be sure to use only the core basic shaders. You should use the "Caligari" texture in the Materials - Textures library, or a simple V-Ray texture map shader in the color channel, and Phong in the reflectance channel (or you can paint the object on the Model side with Lightworks textures, but again the simple texture map shader in the color channel, and basic Phong in the reflectance).


The other advanced shaders are designed specifically for the tS real-time engine (or for the V-Ray render engine, or for the Lightworks render engine, depending), and won't export. Just follow the rule when making something for use outside of tS of keeping to the most basic shaders and you'll be fine! Only go for advanced shaders when the object is destined for use inside tS itself.


HTH!

Tom

Post by dom96 // Sep 9, 2008, 6:14am

dom96
Total Posts: 18
is there anyway i can change it back ??, or could you change it back for me ??

Post by TomG // Sep 9, 2008, 6:52am

TomG
Total Posts: 3397
It's easy to change - simply select the Caligari shader from the Materials - Textures library (right click and choose load). Then in the Material Editor, set it up to load the wood texture you need. Then choose the Paint Over Existing Material tool and click on the handle, this will replace the shader in use there with the new one.


Now when you save it should export the texture also to a sub-folder, like in my earlier example of what I found happening. If you get stuck, take a look at Chapter 5, Surfacing in the Workspace, for a description of the Material Editor. If still stuck, let us know at which point you get stuck and we'll be able to help out here on the forums!


HTH!

Tom

Post by dom96 // Sep 9, 2008, 7:02am

dom96
Total Posts: 18
Yes it works, thanks for the help, i really appreciate it

Post by TomG // Sep 9, 2008, 7:34am

TomG
Total Posts: 3397
Most welcome, that's what the forums are here for! Do keep us updated on how the game is going, would be interested to see items in tS and in game, hear more about your plans for the game (or games), etc. Gaming is a favorite topic of mine :)


Thanks!

Tom
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2021. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn