To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.dat.partsOpen lugnet.cad.dat.parts in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / LDraw Files / Parts / 5794
5793  |  5795
Subject: 
Re: New Part: x784 Technic Gear Hailfire Droid Wheel
Newsgroups: 
lugnet.cad.dat.parts
Date: 
Fri, 2 Dec 2005 22:51:03 GMT
Viewed: 
3958 times
  
----- CUT HERE   LISTING 1 of 2 ------------

-- 3DS Max Exporting with rounded-off precision -----

close out_file

tmesh = snapshotAsMesh selection[1]

out_name = ((GetDir #export)+"/testmesh.dat")

out_file = createfile out_name

num_verts = tmesh.numverts

num_faces = tmesh.numfaces

format "0 Export from 3DS Max\n" to:out_file

fn roundNum n = floor(n*10000+.5)/10000

edges = #(#(0,0,0))
for f = 1 to num_faces do
(
format "3 16 " to:out_file
face = getFace tmesh f
sgroup = getFaceSmoothGroup tmesh f
for c = 1 to 3 do
(
head_vert = face[c]
if (c==3) then
tail_vert = face[1]
else
tail_vert = face[c+1]
if (tail_vert>head_vert) do
(
    temp=tail_vert
tail_vert=head_vert
head_vert=temp
)
append edges #(head_vert,tail_vert,sgroup)
)
for v = 1 to 3 do
(
vert = getVert tmesh face[v]
for c=1 to 3 do
(
round_vert=roundNum(vert[c])
format "% " round_vert to:out_file
)
)
format "\n" to:out_file
)
fn compareFN v1 v2 =
(
case of
(
(v1[1]<v2[1]): -1
(v1[1]>v2[1]): 1
(v1[2]<v2[2]): -1
(v1[2]>v2[2]): 1
default: 0
)
)

qsort edges compareFN

old_edge = #(0,0,0)
for e in edges do
(
if (e[1] == old_edge[1] and e[2] == old_edge[2]) then
(
if (e[3] != old_edge[3]) do (
-- Visible Edge
format "2 24 " to:out_file
head_vert = getVert tmesh e[1]
tail_vert = getVert tmesh e[2]
for v=1 to 3 do (
round_vert = roundNum(head_vert[v])
format "% " round_vert  to:out_file
)
for v=1 to 3 do (
round_vert = roundNum(tail_vert[v])
format "% " round_vert  to:out_file
)
format "\n" to:out_file
)

)
else (
old_edge=e
)
)
close out_file

edit out_name


----- CUT HERE   LISTING 2 of 2 ------------

// Hailfire gear drawing without trailing zeros

// GenGear.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "math.h"

#define precision 4

void shortprint(double x)
{
// Prints a short version of the number
// Skips the decimal if not needed and trailing zeros

int decimals=precision;
double head;
if (x<0){
printf("-");
x=-x;
}
x+=5/pow(10,decimals+1); //Add .5 to make floor roundoff
head=floor(x);
printf("%d",(int)head);
x-=head;
if (floor(x*pow(10,decimals))>0) printf(".",x);
while ( (floor(x*pow(10,decimals))>0) && (decimals-->0)){
x*=10;
head=floor(x);
printf("%d",(int)head);
x-=head;
}
printf(" ");
}

void matrixprint(double ang)
{
// xy rotation by ang
shortprint(cos(ang)); shortprint(-sin(ang)); printf("0 ");
shortprint(sin(ang)); shortprint(cos(ang));  printf("0 ");
printf("0 ");         printf("0 ");          printf("1 ");
}

int main(int argc, char* argv[])
{
double x;
double pi=3.14159;
const double ToothCount=168;
const double FinCount=96;

printf("\n\n\n0 Technic Gear Hailfire Droid Wheel Segment of 8 fin units and 14
teeth\n");
printf("0 Name: x784s02.dat\n");
for (x=0; x<8;x++){
double ang;
ang=-(x/FinCount*pi*2.0);
printf("1 16 0 0 0 ");
matrixprint(ang);
printf("s\\x784s01.dat\n");
}
double teeth_radius = 215.25;
double tooth_x,tooth_y;
for (x=0; x<14;x++){
double ang;
ang=pi-(x/ToothCount*pi*2.0);
tooth_x=sin(ang)*teeth_radius;
tooth_y=-cos(ang)*teeth_radius;
printf("1 16 ");
shortprint(tooth_x);
shortprint(tooth_y);
printf("0 ");
matrixprint(ang);
printf("tooth24.dat\n");
}
printf("\n\n\n0 Technic Gear Hailfire Droid Wheel\n");
printf("0 Name: x784.dat\n");
// Fins
for (x=0; x<12;x++){
double ang;
ang=x/12.0*pi*2.0;
printf("1 16 0 0 0 ");
matrixprint(ang);
printf("s\\x784s02.dat\n");
}

return 0;
}



Message is in Reply To:
  Re: New Part: x784 Technic Gear Hailfire Droid Wheel  [DAT]
 
Version 3 follows. All parts need to be replaced. I fixed the cracks. I removed trailing zeros. I changed the precision to 4 decimals. I inset the teeth a tiny little bit to hide the convex backside. I removed two extra faces that were just adding a (...) (19 years ago, 2-Dec-05, to lugnet.cad.dat.parts)

25 Messages in This Thread:












Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR