#### Archived

This topic is now archived and is closed to further replies.

# Object Rendering in a Level Editor

This topic is 5475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Im currently writing a level editor, and ive run in to a dead end with the rendering of objects, i have my 4 views (Top, Side, Front and 3D View all working and i can render the objects at the moment i break the objects into edges and render the edges as a linelist using d3d. for instance if i want to render a cube i get in my 3 2D views ----------- | /| | / | | / | | / | |/________| or ----------- |\ /| | \ / | | / | | / \ | |/_______\| and want i need is objects that look like ----------- | | | | | | | | ----------- so its not so confusing when there are multiple objects in the same area thanks in advance. ------------------------ agghhhhh it didn't show up correctly ok object (1)is a square with a line from bottom left to top right corner, object (2)is a square with a line leaving each corner going to the opposite corner looking like a cross and object (3) is a plain square [edited by - SKREAMZ on November 18, 2003 9:26:20 AM]

##### Share on other sites
Put your diagrams in <pre> tags. It will keep the spacing.

##### Share on other sites
You need an orthogonal projection matrix rather than a perspective projection matrix. Don''t know exactly what to call but that''s what you are after. Try the MSDN for DX help.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

##### Share on other sites
Well, you're constructing your objects with triangles, right? And when you render them, they look like this:
-----------|\        ||  \      ||    \    ||      \  ||        \|-----------
There's no way around this if you want to keep making your objects out of triangles. However, the vast majority of level editors and 3D software (3DS MAX, q3radiant, Hammer Editor) use polygons with n number of sides to describe the surfaces of their objects. This is why, in 3DS Max, if you draw a cylinder with 20 sides, the top of the cylinder doesn't have 20 triangles, it just has one 20-sided polygon.

Let's take your square-side-made-from-two-triangles (above) as an example. How do you know which face to eliminate? It's obviously the one going across diagonally from top to bottom, but try to write an algorithm to figure that out. I'll save you some time: it's impossible. You couldn't write an algorithm to figure it out which would work 100% of the time, as there are just too many different situations. It's one of the jobs of a map compiler to split up map geometry into triangles; to take the top of that 20-sided cylinder, and split it into 20 individual triangles. After all, it's only in your level editor that you care about objects; in the game, it's all just triangles.

I used to use the same method as you in my level editor. In fact, MilkShape (the 3D model editor) still uses it. However, I decided to change it after looking at 3DS Max and q3radiant, and deducing how they drew their objects. In my level editor now, I just keep a list of vertices for each object, and all the object's faces reference that master list. I use glBegin(GL_POLYGONS); to draw each of my faces, which can have as many sides as is required. Plus, it looks good in wireframe mode. I don't know how this equates to Direct3D, but there must be a way of doing it...

Insert [CENSORED] here.

[edited by - iNsAn1tY on November 18, 2003 2:08:22 PM]

1. 1
Rutin
22
2. 2
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633308
• Total Posts
3011293
• ### Who's Online (See full list)

There are no registered users currently online

×