Forum | 3d documentation

You must be logged in to post Login Register

Search Forums:


 






3d documentation

No Tags
UserPost

11:05 am
August 9, 2011


firefly431

Member

posts 13

Hello. I've been looking at the examples and other people's games. The documentation is missing some commands, namely: mesh, surf3d, and examine hide. (I'm not sure whether examine hide is actually valid or deprecated.) I really want docs on surf3d because I can't figure out the arguments.

10:48 pm
August 9, 2011


saluk

Admin

posts 144

Thanks for the post, I will fix the errors and missing documentation as soon as I can.

Yay, someone who wants to use the 3d!

Examine hide is valid, just not documented. It will prevent the labels of what the crosshairs are over from being shown. This lets you use the same examine code for pointing out photo locations to the court, or even for weird custom interfaces.

For surf3d, which creates a rectangle on the screen to display the 3d object on, the arguments are x, y, width, height, scaled width, scaled height. The x and y govern the upper left hand corner of the surface, the width and height are the width and height of the surface in actuality, and the scaled width and height are how big the surface is scaled to. To start, figure out what rectangle you want to use for your display, and set the x, y, and both widths and both heights the same. It will be slow, so you can lower the resolution by changing the first set of width and height.

mesh will load a wavefront obj file from the art/meshes directory. The origin will be in the center of the surf3d. Meshes can be rotated with "rotate" and moved with "scroll", as with any other object, although they have an added z component for scrolls, and an added "axis=y" or "axis=z" for rotate.

Let me know how far you get.

8:28 pm
August 10, 2011


firefly431

Member

posts 13

Oh. I thought the surf3d was for loading a texture or something.Confused

9:01 pm
August 10, 2011


saluk

Admin

posts 144

Ah, nope. surf3d just creates the surface that renders the 3d world. The texture is defined in the object file. Check examples/3d_real/art/models. The .obj file contains polygons and vertices, the .mtl file describes how to map the texture, and the .bmp is the texture itself. I didn't make this model, it was one I downloaded. This file format with .obj and .mtl is called wavefront .obj.

But if you look at the text of the .obj file, you will see this line:

mtllib m16.mtl

Which tells it to use m16.mtl for its material.

And then in m16.mtl, there is this line:

map_Kd m16.bmp

Which is telling it what texture to use.

It's one of the simplest 3d formats to deal with, especially for programmers, and there was already some base python code for loading it, so that's why I chose it. Also on many 3d object sites they offer the models in that format.

11:23 am
August 12, 2011


firefly431

Member

posts 13

Post edited 12:51 pm – August 12, 2011 by firefly431


I tried to load my sword model like: (swordcheck.txt)


bg 3dgrid z=-10
surf3d 0 0 256 192 256 192
mesh SwordExport.obj
fg fg3d z=1
gui Button right x=180 y=140 name=rb hold rotate
gui Button left x=50 y=140 name=lb hold rotate
gui Button push x=0 y=50 name=pushb hold zoom
gui Button pull x=0 y=110 name=pullb hold zoom
examine3d

But then it says Undefined. (line 3)

But when I replace it in 3d_real, it works, but it's really small. But when I use: scroll name=mesh z=100 speed=10

it doesn't work. (It barely does anything)

EDIT:

Also, when trying to rotate it on the Z axis, it rotates on the Y axis.

9:24 pm
August 12, 2011


saluk

Admin

posts 144

There might be some issues with scale. Can you upload/link to the model file? If you can edit the model and make it bigger that might help. If not (i.e. you downloaded the model from somewhere and dont know how to edit it), I can look into adding a scale function.

And the axis work as follows:

x is the horizontal axis. So if you rotate along it, things should rotate up and into the screen, or down and out of the screen. Think of it like a rotating wheel of a car thats coming at you.

y is the vertical axis, so it rotates to the left and right, like a carosel.

z points into the screen, and is the default rotation axis. It will make things rotate in a flat way (not into or out of the screen). Think of it like looking at a rotating wheel as you watch a car drive to the right. This is the only axis that works for rotating 2d objects in pywright.

9:25 am
August 20, 2011


firefly431

Member

posts 13

I just built a new computer because someone took my old one. I just got a fresh copy of PyWright so all my are on my other computer. Sorry. (I was on mac, now win. I'm also going to get Linux.) I made the model+tex myself so no explanations necessary. Please close this now.

9:27 am
August 20, 2011


firefly431

Member

posts 13

Post edited 9:28 am – August 20, 2011 by firefly431


One last question: How do you add a movie? There's a movie folder and I'm confused. (It seems as though there is a Z limit?)

No Tags