Erain 3D
advert here

Why can't I see my object in the world?

One of the most frustrating things is when you can't see or find your object in your world. There are many, many possible reasons for an object not appearing properly.

Here are some general categories of problems (I treat these in more detail below):

In all cases, the key is to start with a simple example, such as Petit's tutorial, and build up the functionality in incremental stages, verifying at each point. If your example previously worked and suddenly stopped working, the obvious culprit is your most recent change. Undo your recent changes (hopefully you've kept a backup of a recent stable version) and see if you can get back to a known working state.

Debugging is the systematic challenging on one's assumptions. So verify each step, and each sub-step of each step, until you find the problem. Sandy is open source, so you can usually examine exactly the code you need to find the problem, which may be in the Sandy library itself, especially when using a beta version. When in doubt, ask for help in the forum (after reading this FAQ of course).

The world was not created/configured/rendered properly

The first task it to create your world and add a camera and root group to it. If you've done that properly and also added at least one visible object to your root group, you should be able to see something in your world.

There are many ActionScript-related issues, having nothing directly to do with Sandy, that can conspire against you. The most common problems are scope-related and having the wrong classPath. This FAQ doesn't address syntax checking or problems getting your code to compile. It assumes that your code compiles without errors but that it fails to perform as desired.

You should always use ActionScript classes for all your Sandy-related code. Compiling classes in the Flash 8 authoring tool will give you lots of syntax checking to help diagnose and avoid problems in your code. For example, if you haven't imported the TextureSkin class, and you're writing timeline-based code, Flash won't warn you of the problem. If however, you attempt to create a TextureSkin in a class that doesn't import the TextureSkin class, Flash 8 will issue a warning when you try to compile. That is all I'm going to say about general ActionScript tips here. There are many more ways to improve your code including meticulous error-checking, typing all your variables, using unit tests, etc., but these are beyond the scope of this FAQ.

Later, I'll add examples of creating a world in 1.1 and 1.2. See Petit's tutorial for Sandy 1.1 code. For 1.2, see the FAQ on changes between the two versions (basically, for 1.2, you must change your Camera3D constructor and use World3D.setCamera() instead of World3D.addCamera()).

To create your world, make sure you've done the following

(Code examples to be added in the future…)

The object was not created properly

If your world was created properly, your initial test object should appear. However, this is a bit of a chicken-and-egg problem. You can't tell if your world was created properly unless you see some object in it. And if the object doesn't appear, you don't know if it is because the object creation was bad or it was put into a non-existent world.

Your initial goal should be to render one object, any object, at any visible location so that you know your world exists and objects can be placed in it. Then you can work on the details of your other problems.

Start with Petit's tutorials and create a known primitive object, such as a Box or Pyramid. Be sure you've set all the constructor parameters correctly for the version of Sandy you are using. If you cannot get his tutorial working (or something similar) keep going back to the simplest possible case (i.e., creating a world with one object in it).

That said, if you can't get one object visible, then you don't know if any object is visible. So always go back to a known example. Petit draws axes in the world, which act as a great reference point.

Remember, your object may be created properly but not be placed in the world properly and may be invisible for other reasons. (see below)

The object was not added to the world properly

Even if your object was created properly, it won't appear until it is added to the world.

If you've successfully created your world, especially if you can view other objects, then your object may not have been added properly.

Try adding it to the rootgroup with addChild().

If you are adding it as a child of another group, again see Petit's tutorials about how to add something to a transform group. Start with default positions and rotations, such as (0,0,0). If you can get it to appear there, then you can move it later.

Your camera can't see your object or world (or a clipping problem)

Seeing your world is dependent on three things:

It is exceedingly common for a problem to be related to your camera either not existing or not looking at the right place.

Therefore, you should check:

Your object is invisible for some other reason

Assuming your world is created properly and your camera is looking at the right place, you still need to put some object in the world at the right location. Assuming you can see at least one object in the world, here are some other reasons a given object might not appear.

Skinning Problems

The most common problem causing an object that would otherwise be visible to be invisible is its skinning. Be sure to import the necessary skinning classes.

To work out the skinning of an object:

Looking at the back or inside of an obejct

By default, the back or inside of an object isn't rendered. So if you rotate a plane away from the camera, it will seem to disappear. Likewise, if you put the camera inside a cube, it will seem to disappear.

To view the backfaces:

Other reasons your object won't appear

There are many other reasons an object might not appear:

An existing object disappears

If an existing object disappears, it is, by definition, because something else changed.

Check the following

Other Problems

There are many other potential pitfalls not discussed in detail here.

For example, if you are loading an external model, it is possible that:

Start with a simple primitive shape and work your way up to the more complex stuff.

Remember these keys:

It is often very helpful to use sliders to control the position of an object or a camera. This allows you to change the parameters at runtime to see their effects. See Petit's tutorials in this regard. But beware, the sliders themselves add a layer of complexity and potentially introduce errors if your code is incorrect.

When in doubt post to the help forums. See you there!

Cheers, Bruce (zeusprod)